Example #1
0
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)
Example #2
0
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
Example #3
0
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>")
Example #4
0
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>")
Example #5
0
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
Example #6
0
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