#!/usr/bin/env python ####################################################################### # Script to add the missing substructure fields to MOL2 format files # # Usage: python fix_substructure.py inputfile.mol2 outputfile.mol2 # # Demetri Moustakas 7/15/2002 # ####################################################################### import sys import string fin = open(sys.argv[1],"r") fout = open(sys.argv[2], "w") line = " " while line: line = fin.readline() if line == "@MOLECULE\n": fout.write(line) line = fin.readline() fout.write(line) temp_line = fin.readline() num_bonds = string.atoi(string.split(temp_line)[1]) line = "" line = line + " " + string.split(temp_line)[0] + " " + string.split(temp_line)[1] line = line + " 1 " + string.split(temp_line)[3] + " " + string.split(temp_line)[4] + "\n" fout.write(line) elif line == "@BOND\n": fout.write(line) for i in range(num_bonds): line = fin.readline() fout.write(line) fout.write("@SUBSTRUCTURE\n") fout.write("1 **** 1 TEMP 0 **** ****\n") else: fout.write(line) fin.close() fout.close()