add new type to xvg converter

This commit is contained in:
2016-01-19 18:18:10 +03:00
parent 2c44b229ee
commit 33ddc0079d

View File

@ -31,6 +31,8 @@ def defineType(file):
type = "dist"
elif (line.find("Angle") > -1):
type = "angl"
elif (line.find("Number") > -1):
type = "num"
break
return type
@ -67,6 +69,22 @@ def getDistanceOutput(file, first=True):
return data
def getNumberOutput(file, first=True):
"""function to parse distance file"""
data = []
with open(file, 'r') as input:
for line in input:
if ((line[0] == '@') or (line[0] == '#')):
continue
try:
if ((not first) and (float(line.split()[0]) == 0.0)):
continue
data.append(float(line.split()[1]))
except:
pass
return data
def getRmsdOutput(file, first=True):
"""function to parse rmsd files"""
data = []
@ -149,6 +167,8 @@ def getData(fileList):
rawData[system] = rawData[system] + getDistanceOutput(file, first)
elif (type == "angl"):
rawData[system] = rawData[system] + getAngleOutput(file, first)
elif (type == "num"):
rawData[system] = rawData[system] + getNumberOutput(file, first)
if (first):
first = False
return rawData