def helixOrSheet(filename, secondaryType, helixOrsheet): if (helixOrsheet == "helix"): helixList = buildHelix(filename, buildProtein(filename)) atomNumber = setSecondaryType(secondaryType) for helix in helixList: if helix.helixType == secondaryType: helixangles.evaluateAngles(helix, filename, atomNumber) elif (helixOrsheet == "sheet"): sheetList = buildSheet(filename, buildProtein(filename)) for sheet in sheetList: if sheet.sheetType == secondaryType: #vector.orthogonalVectorCalculation([1,3,2], [-6,-3,2], [-1,-5,2]) sheetangles.evaluateAngles(sheet, filename)
def pdb(request, pdb_name_slug): context_dict, sheetDict = {}, {} sheetList, algList = [], [] try: pdb = PDB.objects.get(slug=pdb_name_slug) context_dict['pdb_iden'] = pdb.pdb_iden url_target = "https://www.rcsb.org/pdb/files/{0}.pdb".format(pdb.pdb_iden) p = protein.buildProtein(url_target) sheetList += sheet.buildSheet(url_target, p, pdb.pdb_iden) algorithms = pdb.algorithmdetail_set.all() for s in sheetList: for alg in algorithms: if str(s.sheetIden.replace(" ", "")) == alg.sheet_iden: algList.append(alg.algorithm) else: algList.append("No matching algorithms.") break sheetDict[str(s.sheetIden.replace(" ", ""))] = algList algList = [] context_dict['sheetAlg'] = sheetDict context_dict['algorithms'] = algorithms context_dict['pdb'] = pdb context_dict['pdb_name_slug'] = pdb_name_slug except PDB.DoesNotExist: pass return render(request, 'pdb.html', context_dict)
def computeAll(path): only100 = 0 count = 0 for filename in glob.glob(os.path.join(path, '*.pdb')): drive, pathAndFile = os.path.splitdrive( filename ) #http://stackoverflow.com/questions/3167154/how-to-split-a-dos-path-into-its-components-in-python filePath, file = os.path.split(pathAndFile) if (only100 == MAXVALUE): break else: only100 += 1 p = protein.buildProtein(filename) sheetList = sheet.buildSheet(filename, p) print "{0} files completed...".format(only100) listOfBridges = detectBridge(sheetList) if listOfBridges: print "{0} is BRIDGE".format(file) toHTML(listOfBridges, file) count += 1 else: print "{0} is NOT BRIDGE".format(file) with open("bridges.html", 'a') as output: #My quick solution to ending HTML file output.write("</body>\n</html>") print count
def transFunction(filename, secondaryType, helixOrsheet): p = buildProtein(filename) atomNumber = setSecondaryType(secondaryType) helixangles.evaluateAngles(p, filename, atomNumber) #This one has to be the whole protein because we're doing TRANSITIONS #The type of Helix does matter in this case because the angles are calculated differently helixangles.transitionAngle("{0}N.txt".format(filename.split('.')[0]), filename, secondaryType, helixOrsheet) helixangles.transitionAngle("{0}CA.txt".format(filename.split('.')[0]), filename, secondaryType, helixOrsheet) helixangles.transitionAngle("{0}C.txt".format(filename.split('.')[0]), filename, secondaryType, helixOrsheet)
def computeOne(filename): p = protein.buildProtein(filename) sheetList = sheet.buildSheet(filename, p) listOfBridges = detectBridge(sheetList) if listOfBridges: print "{0} is BRIDGE".format(filename) toHTML(listOfBridges, filename) else: print "{0} is NOT BRIDGE".format(filename) with open("bridges.html", 'a') as output: #My quick solution to ending HTML file output.write("</body>\n</html>")
def computeOne(filename): p = protein.buildProtein(filename) sheetList = sheet.buildSheet(filename, p) listOfTwist = detectTwist(sheetList) if listOfTwist: print "{0} has a Twist".format(filename) toHTML(listOfTwist, filename) else: print "{0} is NOT a Twist".format(filename) with open("twist.html", 'a') as output: #My quick solution to ending HTML file output.write("</body>\n</html>")
def testAlgorithm(alg): sheetList = [] url_target = "https://www.rcsb.org/pdb/files/1a1r.pdb" p = protein.buildProtein(url_target) sheetList += sheet.buildSheet(url_target, p, '1a1r') algName = os.path.splitext(os.path.basename(alg.filePath.name))[0] sys.path.append(os.path.realpath("media/content/{0}".format(alg.author))) new_module = __import__(algName) try: new_module.detect(sheetList) return True except: print "Unexpected Error: Probably not proper file format" print sys.exc_info()[0] return False
def runAlgorithm(alg, PDBList, pdb_used_testing, example_information): sheetList = [] returnPDBSheetList = [] for pdb in PDBList: try: url_target = "https://www.rcsb.org/pdb/files/{0}.pdb".format( pdb.pdb_iden) p = protein.buildProtein(url_target) sheetList += sheet.buildSheet(url_target, p, pdb.pdb_iden) algName = os.path.splitext(os.path.basename(alg.filePath.name))[0] sys.path.append( os.path.realpath("media/content/{0}".format(alg.author))) new_module = __import__(algName) print "Working... {0}".format(pdb.pdb_iden) try: returnPDBSheetList += new_module.detect(sheetList) sheetList = [] except: print "Unexpected Error: Probably something went wrong with their logic" print sys.exc_info()[0] for PDBsheet in returnPDBSheetList: ad = AlgorithmDetail.objects.get_or_create( algorithm=alg, pdb=pdb, sheet_iden=PDBsheet.sheetIden, test_set=False, example=False)[0] ad.save() returnPDBSheetList = [] pdbDetails = pdb.algorithmdetail_set.all().filter(algorithm=alg) for pdbDet in pdbDetails: for each_pdb in pdb_used_testing: if pdbDet.pdb.pdb_iden == each_pdb.pdb_iden: pdbDet.test_set = True for example_pdb in example_information: if pdbDet.pdb.pdb_iden == example_pdb[ 0] and pdbDet.pdb.sheet_iden == example_pdb[1]: pdbDet.example = True except: print pdb.pdb_iden
def prepare(file_name): p = protein.buildProtein(file_name) cenx, ceny, cenz = protein.weightedAverage(p) center = [cenx, ceny, cenz] return p, center
print "\nComputing Using File: {0}".format(sys.argv[1]) p, center = prepare(sys.argv[1]) calculatePhiPsi(p, center, sys.argv[1]) #Multiple file Ramachandran Plot elif (sys.argv[1] == "all" and len(sys.argv) > 2): path += sys.argv[2] print "\nComputing All Files." if (os.path.isdir(path) == True): computeAll(sys.argv[2]) else: print "\nERROR: This folder does not exist" print "\nERROR: Please make sure directory format is correct" print "\nFORMAT: all \Directory" #New Geometric Calculations elif (sys.argv[1] == "new" and len(sys.argv) > 2 and format(sys.argv[2])): p = protein.buildProtein(sys.argv[2]) coilList = extra.buildCoil(sys.argv[2], p) if (len(coilList)<1): print "\nThere were no COILS in this protein" else: for coil in coilList: newCalculate(coil, sys.argv[2]) #Utilizes Smith-Waterman Algorithm to Locally Align two proteins elif (sys.argv[1] == "align" and len(sys.argv) > 3): print "\nAligning your two files." mainSeq, targetSeq = check(sys.argv[2], sys.argv[3]) if (mainSeq == False or targetSeq == False): print "\nERROR: Please make sure the file type is correct" print "\nFORMAT: align File1[.pdb.txt] File2[.pdb.txt]" else: smithwaterman.align(mainSeq, targetSeq, sys.argv[2], sys.argv[3])