def main(): # Get the protein codes (these can also be stored in a file and retrieved) keyCodes = hlp.getProtienCodes('E.Coli.txt') for keyCode in keyCodes: pdbSearchCode = keyCode[1:5] pdbPath = 'protiens/' + pdbSearchCode + '/' + pdbSearchCode + '.pdb' dsspPath = 'protiens/' + pdbSearchCode + '/' + pdbSearchCode + '.dssp' if not os.path.exists(dsspPath): print dsspPath + " doesn't exists \n" pass else : csvPath = 'protiens/' + pdbSearchCode + '/' + pdbSearchCode purgePath = 'protiens/' + pdbSearchCode + '/' hlp.purgeFiles(purgePath, ".csv") infile = open(dsspPath, "r") for line in infile: if(re.match(".*#.*",line)): #line = infile.next() # c = csv.writer(open(csvPath,"wb+")) # c.writerow(["Residue No.","Amino Acid","Structure"]) for line in infile: suffix = re.split("\W+", line)[3] + '.csv' # print csvPath if not os.path.exists(csvPath + '_' + suffix): c = csv.writer(open(csvPath + '_' + suffix,"wb+")) c.writerow(["Residue No.", "Residue Class", "Amino Acid", "Structure"]) splitLine = re.split("\W+",line) if( not (splitLine[3].isdigit() or splitLine[4].isdigit())): # print splitLine[2]+" "+splitLine[4]+" "+splitLine[5] c.writerow([splitLine[2], splitLine[3], splitLine[4], splitLine[5]]) infile.close() sys.exit(0)
def main(): residueClass = raw_input("Please enter the Residue class: (Eg. A,B,C.....) ") residueClass = residueClass.upper() groupCount = int(raw_input("Please enter the grouping constant: ")) # print residueClass # print groupCount keyCodes = hlp.getProtienCodes("E.Coli.txt") keyCodes = hlp.cleanProtienCodes(keyCodes) keyCodes = list(set(keyCodes)) for keyCode in keyCodes: targetFile = 'protiens/' + keyCode + '/' + keyCode + '_' + residueClass + '.csv' if os.path.exists(targetFile): infile = open(targetFile, 'r') infile.next() residueNum = [] aminoAcid = [] structure = [] codons = [] for line in infile: # print line residueNum.append(getResidueNum(line)) aminoAcid.append(getAminoAcids(line)) structure.append(getStructures(line)) codons.append(getCodons(line)) print keyCode, len(residueNum) getGroupedCSV(residueNum, aminoAcid, structure, codons, groupCount, keyCode)
def main(): keyCodes = hlp.getProtienCodes('E.Coli.txt') hlp.makeDirStructure(keyCodes) for keyCode in keyCodes: pdbSearchCode = keyCode[1:5] print pdbSearchCode url = 'http://www.rcsb.org/pdb/files/' + pdbSearchCode + '.pdb' # REST API for fetching pdb files pdbPath = 'protiens/' + pdbSearchCode + '/' + pdbSearchCode + '.pdb' # pdb file for respective protein is fetched only if it doean't exist if not os.path.exists(pdbPath): response = urllib2.urlopen(url) pdbData = response.read() pdbFile = open(pdbPath, 'w') pdbFile.write(pdbData) pdbFile.close() dsspPath = 'protiens/' + pdbSearchCode + '/' + pdbSearchCode + '.dssp' if os.path.exists(pdbPath) and not os.path.exists(dsspPath): pdbToDSSP(pdbPath, pdbSearchCode) # Converting the pdb file to dssp