Created
April 4, 2017 20:53
-
-
Save leelasd/996158d2be9885e3a1caeb25d6f979f9 to your computer and use it in GitHub Desktop.
Combine .ITP files from gromacs into 'combo.itp' file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def read_itp(itp_name): | |
lines = open(itp_name).readlines() | |
impDat = [] | |
for n in range(len(lines)): | |
if '[' in lines[n]: impDat.append(n) | |
atom_def = lines[impDat[0]+1:impDat[1]] | |
rest_mol = lines[impDat[1]:] | |
return(atom_def,rest_mol) | |
a_UNK,r_UNK=read_itp('UNK.itp') | |
a_OCT,r_OCT=read_itp('OCT.itp') | |
a_CYH,r_CYH=read_itp('CYH.itp') | |
atypes = list(set(a_UNK +a_OCT + a_CYH)) | |
moltypes = r_UNK + r_OCT + r_CYH | |
ofile=open('combo.itp','w') | |
ofile.write('[ atomtypes ] \n') | |
for line in atypes: ofile.write('%s'%line) | |
for line in moltypes: ofile.write('%s'%line) | |
ofile.close() | |
print('-maxwarn %d'%(len(a_CYH+a_OCT))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment