| 1 |
"""
|
| 2 |
IproHelperTools
|
| 3 |
|
| 4 |
Created by
|
| 5 |
E. Borges
|
| 6 |
20121025
|
| 7 |
|
| 8 |
This is a collection of methods that work in ipro.
|
| 9 |
|
| 10 |
"""
|
| 11 |
|
| 12 |
def LFPtoDict(pathToLFP):
|
| 13 |
"""This method creates a dictionary, from an lfp, where the parent is the key."""
|
| 14 |
matrix = {}
|
| 15 |
count = 0
|
| 16 |
contents = open(pathToLFP).readlines()
|
| 17 |
for line in contents:
|
| 18 |
try:
|
| 19 |
(nul, bates, parentFlag, nul, nul) = line.split(",")
|
| 20 |
except:
|
| 21 |
(nul, bates, parentFlag, nul, nul, nul) = line.split(",")
|
| 22 |
if parentFlag:
|
| 23 |
count = 1
|
| 24 |
parentBates = bates
|
| 25 |
else:
|
| 26 |
count +=1
|
| 27 |
matrix[parentBates] = count
|
| 28 |
return matrix
|
| 29 |
|
| 30 |
def LFPtoDictReversed(pathToLFP):
|
| 31 |
"""This method creates a dictionary, from an lfp, where the child is the key."""
|
| 32 |
matrix = {}
|
| 33 |
contents = open(pathToLFP).readlines()
|
| 34 |
for line in contents:
|
| 35 |
try:
|
| 36 |
(nul, bates, parentFlag, nul, nul) = line.split(",")
|
| 37 |
except:
|
| 38 |
(nul, bates, parentFlag, nul, nul, nul) = line.split(",")
|
| 39 |
parentFlag = parentFlag.strip()
|
| 40 |
if parentFlag:
|
| 41 |
parent = bates
|
| 42 |
matrix[bates] = parent
|
| 43 |
else:
|
| 44 |
matrix[bates] = parent
|
| 45 |
return matrix |