Skip to content

Instantly share code, notes, and snippets.

@andersx
Created July 19, 2017 11:38
Show Gist options
  • Select an option

  • Save andersx/063badb0958dfa5c7b21632727abb994 to your computer and use it in GitHub Desktop.

Select an option

Save andersx/063badb0958dfa5c7b21632727abb994 to your computer and use it in GitHub Desktop.
Convert TINKER xyz to regular xyz format.
#!/usr/bin/env python
from __future__ import print_function
import sys
def tinker2xyz(filename):
f = open(filename, "r")
lines = f.readlines()
f.close()
natoms = len(lines) - 1
print(natoms)
print()
for line in lines[1:]:
tokens = line.split()
print(" %-s %12s %12s %12s" % (tokens[1][0], tokens[2], tokens[3], tokens[4]))
return
if __name__ == "__main__":
filename = sys.argv[1]
tinker2xyz(filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment