import re
import sys
import os
import xmltodict
if len(sys.argv) < 2:
message = '\n Get 7 TM pdb files from a GPCR PDB. \n\n Usage: '+sys.argv[0] + ' [Input csv file with TM info] \n' + ' Example: ' + sys.argv[0] + ' pdbtms7.csv\n' + ' Output Files: pdb_2rh1A_tm1.pdb ... pdb_2rh1A_tm7.pdb'
print (message)
exit()
csvFile=sys.argv[1]
f = open (csvFile,'r')
k = 0
data = f.readlines()
for linedata in data:
line=linedata.strip()
letters = line.split(',')
print (letters)
pdbId=letters[0]
chain=letters[1]
numTMs=int(letters[3])
for i in range(numTMs):
j=((2*i)+4)
k=((2*i)+5)
# print(i,j,k)
print(i+1,letters[j],letters[k])
dump= 'pdb_'+ pdbId + chain + '_tm' + str(i+1) +'.pdb'
pdbFile=pdbId+'.pdb'
wgetcom='wget https://files.rcsb.org/view/'+pdbFile+' -O '+pdbFile
os.system(wgetcom)
p = open (pdbFile,'r')
data =p.readlines()
g = open(dump,'w')
for linedata in data:
line=linedata.strip()
words = line.split()
if (words[0]=='ATOM'):
words[5]=int(line[22:26].strip())
if(words[5] in range(j,k+1)):
g.write(linedata)
g.close()
f.close()
this code is supposed to create 7 other files as an output; the code actually creates them, but it does not write anything inside the files, so is there any way to fix this issue.
Thanks very much in advance!