Print

Gromacs trjconv structures look odd ?

Written by Super User. Posted in Uncategorised

vmdscene

If converting from different formats, trjconv does not correctly format the coordinates. I noticed that one digit is too much. Here is a simple python script that will rewrite the files with the right number of digits.

import sys 

file=open(sys.argv[1],"r")
lines=file.readlines()
file2=open(("correct."+sys.argv[1]),"w")
file.close()
for i in range(len(lines)):
	splitl=lines[i].strip().split()
	print splitl 
	if (len(splitl) > 3 ) and ("Generated" not in lines[i]):
		firstpart=lines[i][0:20]
		secondpart=lines[i][20:].split()
		print secondpart 
		file2.write("%s%07.3f%07.3f%07.3f\n"%(firstpart,float(secondpart[0]),float(secondpart[1]),float(secondpart[2])))
	else:
		file2.write(lines[i])