From 33ddc0079d43a13adf5c675358e81dbb418824c6 Mon Sep 17 00:00:00 2001 From: arcan1s Date: Tue, 19 Jan 2016 18:18:10 +0300 Subject: [PATCH] add new type to xvg converter --- xvg2csv/xvg2csv.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/xvg2csv/xvg2csv.py b/xvg2csv/xvg2csv.py index c4f5d22..4820a0b 100755 --- a/xvg2csv/xvg2csv.py +++ b/xvg2csv/xvg2csv.py @@ -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