X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=erange.git;a=blobdiff_plain;f=cistematic%2Fgenomes%2Fecaballus.py;h=f2ac6d0da6369476e726500af3de550f638f2f6f;hp=e845c426500550ef1169df4a3d4bf33fc99690d8;hb=HEAD;hpb=4ad5495359e4322da39868020a7398676261679e diff --git a/cistematic/genomes/ecaballus.py b/cistematic/genomes/ecaballus.py index e845c42..f2ac6d0 100644 --- a/cistematic/genomes/ecaballus.py +++ b/cistematic/genomes/ecaballus.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. # @@ -33,36 +33,49 @@ from cistematic.genomes import Genome 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/E_caballus/ecaballus.genedb" % cisRoot -def loadChromosome(db, chromID, chromPath, chromOut): - seqArray = [] - ecGenome = Genome("ecaballus", dbFile=db) - inFile = open(chromPath, "r") - line = inFile.readline() - for line in inFile: - seqArray.append(line.strip()) +def buildHorseDB(db=geneDB): + genePath = "%s/download/seq_gene.md" % cisRoot - 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() - ecGenome.addChromosomeEntry(chromID, chromOut, "file") + print "Adding gene entries" + loadGeneEntries(db, genePath) + + 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", "29", "30", + "31", "M", "X", "Un" + ] + for chromID in chromList: + print "Loading chromosome %s" % chromID + chromPath = "%s/download/chr%s.fa" % (cisRoot, chromID) + loadChromosome(db, chromID, chromPath, "/E_caballus/chromo%s.bin" % chromID) + + print "Creating Indices" + createDBindices(db) + + print "Finished creating database %s" % db + + +def createDBFile(db): + ecGenome = Genome("ecaballus", dbFile=db) + ecGenome.createGeneDB(db) def loadGeneEntries(db, gFile): - """ FIXME - NEED TO DEAL WITH ALTERNATIVE SPLICING ENTRIES - """ + #TODO: - NEED TO DEAL WITH ALTERNATIVE SPLICING ENTRIES + geneEntries = [] alreadySeen = [] ecGenome = Genome("ecaballus", dbFile=db) @@ -131,68 +144,26 @@ def loadGeneFeatures(db, gFile): ecGenome.addFeatureEntryBatch(featureEntries) -def createDBFile(db): - ecGenome = Genome("ecaballus", dbFile=db) - ecGenome.createGeneDB(db) - - -def createDBindices(db): +def loadChromosome(db, chromID, chromPath, chromOut): + seqArray = [] ecGenome = Genome("ecaballus", dbFile=db) - ecGenome.createIndices() - - -def buildHorseDB(db=geneDB): - genePath = "%s/download/seq_gene.md" % cisRoot - 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, - "29": "%s/download/chr29.fa" % cisRoot, - "30": "%s/download/chr30.fa" % cisRoot, - "31": "%s/download/chr31.fa" % cisRoot, - "M": "%s/download/chrM.fa" % cisRoot, - "X": "%s/download/chrX.fa" % cisRoot, - "Un": "%s/download/chrUn.fa" % cisRoot - } - - print "Creating database %s" % db - createDBFile(db) - - print "Adding gene entries" - loadGeneEntries(db, genePath) + inFile = open(chromPath, "r") + line = inFile.readline() + for line in inFile: + seqArray.append(line.strip()) - print "Adding gene features" - loadGeneFeatures(db, genePath) + seq = string.join(seqArray, "") + seqLen = len(seq) + if seqLen < 1: + print "Problems reading sequence from file" - for chromID in chromos.keys(): - print "Loading chromosome %s" % chromID - loadChromosome(db, chromID, chromos[chromID], "/E_caballus/chromo%s.bin" % chromID) + print "writing to file %s" % chromOut + outFile = open("%s%s" % (cisRoot, chromOut), "w") + outFile.write(seq) + outFile.close() + ecGenome.addChromosomeEntry(chromID, chromOut, "file") - print "Creating Indices" - createDBindices(db) - print "Finished creating database %s" % db \ No newline at end of file +def createDBindices(db): + ecGenome = Genome("ecaballus", dbFile=db) + ecGenome.createIndices()