Beispiel #1
0
def InitDB(filename = None):
	"""
	By default, it will reuse the database already loaded-however, it will instantiate a new one, 
	if there hasn't been one loaded so far.
	"""
	global biodb
	if biodb == None:
		biodb = biosettings.BioSettings(filename)
		biodb.InitDB()
	return biodb
Beispiel #2
0
					pathway.AddGene(geneA)
					pathway.AddGene(geneB)
					pathway.Commit(self.biosettings)
					self.biosettings.RelatePathways(self.groupID, groupID, "PFAM", "")
					success			= True
			else:
				if len(idsA) == 0:
					self.missingUni.add(uniA)
				else:
					self.ambiguousUni.add(uniA)
				if len(idsB) == 0:
					self.missingUni.add(uniB)
				else:
					self.ambiguousUni.add(uniB)
		else:
			print >> sys.stdout, "Misaligned Taxonomy (%s), %s %s  : %s" % (name, taxA, taxB, comment)
		return success
	def Commit(self):
		self.biosettings.Commit()

if __name__ == '__main__':
	filename = None
	if len(sys.argv) > 1:
		filename 			= sys.argv[1]
		
	bioDB					= biosettings.BioSettings(filename)
	bioDB.OpenDB()
	loader					= DIPLoader(bioDB)
	loader.Load()

	bioDB.Commit()
Beispiel #3
0
def LoadKB(dbFilename, kbLoads, doReset=False, refreshEnsembl=False):
    global loadables
    chromosomes = ('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11',
                   '12', '13', '14', '15', '16', '17', '18', '19', '20', '21',
                   '22', 'X', 'Y', 'MT')
    bioDB = biosettings.BioSettings(dbFilename)
    bioDB.OpenDB()

    if doReset:
        bioDB.ResetDB()

    os.system("mkdir -p download")
    os.chdir("download")

    #variations 				= bioDB.BuildDbFilename(bioDB.filename, "var")
    ncbiLoader = ncbi_loader.NCBI_Loader(bioDB)

    if kbLoads[0] == "ALL":
        kbLoads = allgroups

    for kb in kbLoads:
        kb = kb.strip().lower()
        if kb == "snps":
            ncbiLoader.InitLog("snps.log")
            cwd = os.getcwd()
            ensembl = GetEnsembl(bioDB, refreshEnsembl)
            os.system("mkdir -p NCBI")
            os.chdir("NCBI")
            #ncbiLoader.UpdateSNPs(chromosomes, "variations", ensembl)
            os.chdir(cwd)
            ensembl.InitVariations("variations", chromosomes)
            ncbiLoader.CloseLog()
        elif kb == "genes":
            ncbiLoader.InitLog("genes.log")
            ensembl = GetEnsembl(bioDB, refreshEnsembl)
            #ensembl.ConnectToEnsemblDB(bioDB)
            ncbiLoader.UpdateGenes(ensembl, chromosomes)
            ncbiLoader.CloseLog()
        elif kb == "go":
            loader = load_go.GoLoader(bioDB)
            loader.InitLog()
            loader.Load()
            loader.CloseLog()
        elif kb == "kegg":
            loader = load_kegg.KeggLoader(bioDB)
            loader.InitLog()
            loader.Load()
            loader.CloseLog()
        elif kb == "reactome":
            loader = load_reactome.ReactomeLoader(bioDB)
            loader.InitLog()
            ensembl = GetEnsembl(bioDB, refreshEnsembl)
            loader.Load(ensembl)
            loader.Commit()
            bioDB.Commit()
            loader.CloseLog()
        elif kb == "netpath":
            loader = load_netpath.NetPathLoader(bioDB)
            loader.InitLog()
            loader.Load(False)
            loader.CloseLog()
        elif kb == "pfam":
            loader = load_pfam.PFamLoader(bioDB)
            loader.InitLog()
            loader.Load()
            bioDB.Commit()
            loader.CloseLog()
        elif kb == "dip":
            loader = load_dip.DIPLoader(bioDB)
            loader.InitLog()
            #loader.Load()
            #bioDB.Commit()
            loader.CloseLog()
        elif kb == "mint":
            loader = load_mint.MintLoader(bioDB)
            loader.InitLog()
            loader.Load()
            bioDB.Commit()
            loader.CloseLog()
        elif kb == "biogrid":
            loader = load_biogrid.BioGridLoader(bioDB)
            loader.InitLog()
            loader.Load()
            bioDB.Commit()
            loader.CloseLog()
        elif kb == "pharmgkb":
            print "Loading PharmGKB"
            loader = load_pharmgkb.PharmGKBLoader(bioDB)
            loader.InitLog()
            loader.Load()
            print "Attempting to Commit the data"
            loader.Commit()
            bioDB.Commit()
            loader.CloseLog()
        elif kb == "chainfiles":
            print "Loading Chain files"
            loader = load_chainfiles.ChainLoader(bioDB)
            loader.InitLog()
            loader.Load()
            loader.Commit()
            bioDB.Commit()
            loader.Commit()
        else:
            print >> sys.stderr, "Unknown kb name: %s. Options include: %s" % (
                kb, ",".join(loadables))