X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=erange.git;a=blobdiff_plain;f=cistematic%2Fgenomes%2Fggallus.py;fp=cistematic%2Fgenomes%2Fggallus.py;h=eb0f5f30eae656dbf5fcd936030fd1f04f0d7a72;hp=551a116654fbf1cd5a72cf944ba253ca3f777eed;hb=4522d28194e3d1c048bced84038760d394038285;hpb=4ad5495359e4322da39868020a7398676261679e diff --git a/cistematic/genomes/ggallus.py b/cistematic/genomes/ggallus.py index 551a116..eb0f5f3 100644 --- a/cistematic/genomes/ggallus.py +++ b/cistematic/genomes/ggallus.py @@ -1,7 +1,7 @@ ########################################################################### # # # C O P Y R I G H T N O T I C E # -# Copyright (c) 2003-10 by: # +# Copyright (c) 2003-13 by: # # * California Institute of Technology # # # # All Rights Reserved. # @@ -34,36 +34,62 @@ from cistematic.core.geneinfo import geneinfoDB from os import environ if environ.get("CISTEMATIC_ROOT"): - cisRoot = environ.get("CISTEMATIC_ROOT") + cisRoot = environ.get("CISTEMATIC_ROOT") else: cisRoot = "/proj/genome" geneDB = "%s/G_gallus/ggallus.genedb" % cisRoot -def loadChromosome(db, chromID, chromPath, chromOut): - seqArray = [] - ggGenome = Genome("ggallus", dbFile=db) - inFile = open(chromPath, "r") - line = inFile.readline() - for line in inFile: - seqArray.append(line.strip()) +def buildChickenDB(db=geneDB): + genePath = "%s/download/seq_gene.md" % cisRoot + goDefPath = "%s/download/GO.terms_and_ids" % cisRoot # ftp://ftp.geneontology.org/pub/go/doc/GO.terms_and_ids + goPath = "%s/download/gene2go" % cisRoot # ftp://ftp.ncbi.nih.gov/gene/DATA/gene2go.gz - seq = string.join(seqArray, "") - seqLen = len(seq) - if seqLen < 1: - print "Problems reading sequence from file" + print "Creating database %s" % db + createDBFile(db) - print "writing to file %s" % chromOut - outFile = open("%s%s" % (cisRoot, chromOut), "w") - outFile.write(seq) - outFile.close() - ggGenome.addChromosomeEntry(chromID, chromOut, "file") + print "Adding gene entries" + loadGeneEntries(db, genePath) + + #print "Adding gene annotations" + #loadGeneAnnotations(db, annotPath) + + print "Adding gene features" + loadGeneFeatures(db, genePath) + + chromList = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", + "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", + "21", "22", "23", "24", "25", "26", "27", "28", + "32", "W", "Z", "M", "E22C19W28_E50C23", "E64", + "1_random", "2_random", "4_random", "5_random", "6_random", + "7_random", "8_random", "10_random", "11_random", "12_random", + "13_random", "16_random", "17_random", "18_random", "20_random", + "22_random", "25_random", "28_random", "Un_random", "W_random", + "E64_random", "Z_random", "E22C19W28_E50C23_random" + ] + for chromID in chromList: + print "Loading chromosome %s" % chromID + chromPath = "%s/download/chr%s.fa" % (cisRoot, chromID) + loadChromosome(db, chromID, chromPath, "/G_gallus/chromo%s.bin" % chromID) + + print "Adding gene ontology" + loadGeneOntology(db, goPath, goDefPath) + + print "Creating Indices" + createDBindices(db) + + print "Finished creating database %s" % db + + +def createDBFile(db): + ggGenome = Genome("ggallus", dbFile=db) + ggGenome.createGeneDB(db) def loadGeneEntries(db, gFile): - """ FIXME - NEED TO DEAL WITH ALTERNATIVE SPLICING ENTRIES - """ + #TODO: - NEED TO DEAL WITH ALTERNATIVE SPLICING ENTRIES + geneEntries = [] alreadySeen = [] ggGenome = Genome("ggallus", dbFile=db) @@ -138,6 +164,26 @@ def loadGeneFeatures(db, gFile): ggGenome.addFeatureEntryBatch(featureEntries) +def loadChromosome(db, chromID, chromPath, chromOut): + seqArray = [] + ggGenome = Genome("ggallus", dbFile=db) + inFile = open(chromPath, "r") + line = inFile.readline() + for line in inFile: + seqArray.append(line.strip()) + + seq = string.join(seqArray, "") + seqLen = len(seq) + if seqLen < 1: + print "Problems reading sequence from file" + + print "writing to file %s" % chromOut + outFile = open("%s%s" % (cisRoot, chromOut), "w") + outFile.write(seq) + outFile.close() + ggGenome.addChromosomeEntry(chromID, chromOut, "file") + + def loadGeneOntology(db, goPath, goDefPath): ggGenome = Genome("ggallus", dbFile=db) goDefFile = open(goDefPath, "r") @@ -176,99 +222,6 @@ def loadGeneOntology(db, goPath, goDefPath): ggGenome.addGoInfoBatch(goArray) -def createDBFile(db): - ggGenome = Genome("ggallus", dbFile=db) - ggGenome.createGeneDB(db) - - def createDBindices(db): ggGenome = Genome("ggallus", dbFile=db) ggGenome.createIndices() - - -def buildChickenDB(db=geneDB): - genePath = "%s/download/seq_gene.md" % cisRoot - goDefPath = "%s/download/GO.terms_and_ids" % cisRoot # ftp://ftp.geneontology.org/pub/go/doc/GO.terms_and_ids - goPath = "%s/download/gene2go" % cisRoot # ftp://ftp.ncbi.nih.gov/gene/DATA/gene2go.gz - chromos = {"1": "%s/download/chr1.fa" % cisRoot, - "2": "%s/download/chr2.fa" % cisRoot, - "3": "%s/download/chr3.fa" % cisRoot, - "4": "%s/download/chr4.fa" % cisRoot, - "5": "%s/download/chr5.fa" % cisRoot, - "6": "%s/download/chr6.fa" % cisRoot, - "7": "%s/download/chr7.fa" % cisRoot, - "8": "%s/download/chr8.fa" % cisRoot, - "9": "%s/download/chr9.fa" % cisRoot, - "10": "%s/download/chr10.fa" % cisRoot, - "11": "%s/download/chr11.fa" % cisRoot, - "12": "%s/download/chr12.fa" % cisRoot, - "13": "%s/download/chr13.fa" % cisRoot, - "14": "%s/download/chr14.fa" % cisRoot, - "15": "%s/download/chr15.fa" % cisRoot, - "16": "%s/download/chr16.fa" % cisRoot, - "17": "%s/download/chr17.fa" % cisRoot, - "18": "%s/download/chr18.fa" % cisRoot, - "19": "%s/download/chr19.fa" % cisRoot, - "20": "%s/download/chr20.fa" % cisRoot, - "21": "%s/download/chr21.fa" % cisRoot, - "22": "%s/download/chr22.fa" % cisRoot, - "23": "%s/download/chr23.fa" % cisRoot, - "24": "%s/download/chr24.fa" % cisRoot, - "25": "%s/download/chr25.fa" % cisRoot, - "26": "%s/download/chr26.fa" % cisRoot, - "27": "%s/download/chr27.fa" % cisRoot, - "28": "%s/download/chr28.fa" % cisRoot, - "32": "%s/download/chr32.fa" % cisRoot, - "W": "%s/download/chrW.fa" % cisRoot, - "Z": "%s/download/chrZ.fa" % cisRoot, - "M": "%s/download/chrM.fa" % cisRoot, - "E22C19W28_E50C23": "%s/download/chrE22C19W28_E50C23.fa" % cisRoot, - "E64": "%s/download/chrE64.fa" % cisRoot, - "1_random": "%s/download/chr1_random.fa" % cisRoot, - "2_random": "%s/download/chr2_random.fa" % cisRoot, - "4_random": "%s/download/chr4_random.fa" % cisRoot, - "5_random": "%s/download/chr5_random.fa" % cisRoot, - "6_random": "%s/download/chr6_random.fa" % cisRoot, - "7_random": "%s/download/chr7_random.fa" % cisRoot, - "8_random": "%s/download/chr8_random.fa" % cisRoot, - "10_random": "%s/download/chr10_random.fa" % cisRoot, - "11_random": "%s/download/chr11_random.fa" % cisRoot, - "12_random": "%s/download/chr12_random.fa" % cisRoot, - "13_random": "%s/download/chr13_random.fa" % cisRoot, - "16_random": "%s/download/chr16_random.fa" % cisRoot, - "17_random": "%s/download/chr17_random.fa" % cisRoot, - "18_random": "%s/download/chr18_random.fa" % cisRoot, - "20_random": "%s/download/chr20_random.fa" % cisRoot, - "22_random": "%s/download/chr22_random.fa" % cisRoot, - "25_random": "%s/download/chr25_random.fa" % cisRoot, - "28_random": "%s/download/chr28_random.fa" % cisRoot, - "Un_random": "%s/download/chrUn_random.fa" % cisRoot, - "W_random": "%s/download/chrW_random.fa" % cisRoot, - "E64_random": "%s/download/chrE64_random.fa" % cisRoot, - "Z_random": "%s/download/chrZ_random.fa" % cisRoot, - "E22C19W28_E50C23_random": "%s/download/chrE22C19W28_E50C23_random.fa" % cisRoot - } - - print "Creating database %s" % db - createDBFile(db) - - print "Adding gene entries" - loadGeneEntries(db, genePath) - - #print "Adding gene annotations" - #loadGeneAnnotations(db, annotPath) - - print "Adding gene features" - loadGeneFeatures(db, genePath) - - for chromID in chromos.keys(): - print "Loading chromosome %s" % chromID - loadChromosome(db, chromID, chromos[chromID], "/G_gallus/chromo%s.bin" % chromID) - - print "Adding gene ontology" - loadGeneOntology(db, goPath, goDefPath) - - print "Creating Indices" - createDBindices(db) - - print "Finished creating database %s" % db \ No newline at end of file