<s> import logging <EOL> from django . db import models <EOL> logger = logging . getLogger ( __name__ ) <EOL> class Taxon ( models . Model ) : <EOL> """<STR_LIT>""" <EOL> taxon_id = models . IntegerField ( db_index = True ) <EOL> name = models . CharField ( max_length = <NUM_LIT> ) <EOL> unique_name = models . CharField ( max_length = <NUM_LIT> , blank = True , null = True ) <EOL> type = models . CharField ( max_length = <NUM_LIT:255> , db_index = True ) <EOL> class Meta : <EOL> unique_together = ( "<STR_LIT>" , "<STR_LIT:name>" ) <EOL> def __unicode__ ( self ) : <EOL> return "<STR_LIT>" % ( self . taxon_id , self . name ) <EOL> class GenomeBuild ( models . Model ) : <EOL> """<STR_LIT>""" <EOL> name = models . CharField ( max_length = <NUM_LIT:255> , unique = True ) <EOL> affiliation = models . CharField ( max_length = <NUM_LIT:255> , default = '<STR_LIT>' ) <EOL> description = models . CharField ( max_length = <NUM_LIT:255> ) <EOL> species = models . ForeignKey ( Taxon ) <EOL> html_path = models . CharField ( max_length = <NUM_LIT> , blank = True , null = True ) <EOL> source_name = models . CharField ( max_length = <NUM_LIT> , blank = True , null = True ) <EOL> available = models . BooleanField ( default = True ) <EOL> default_build = models . BooleanField ( default = False ) <EOL> ucsc_equivalent = models . ForeignKey ( '<STR_LIT>' , blank = True , null = True ) <EOL> def __unicode__ ( self ) : <EOL> return "<STR_LIT>" % ( self . name , self . description ) <EOL> def species_to_taxon_id ( species_name ) : <EOL> """<STR_LIT>""" <EOL> ret_list = list ( ) <EOL> query_list = Taxon . objects . filter ( name__iexact = species_name ) <EOL> if not query_list . count ( ) : <EOL> raise Taxon . DoesNotExist <EOL> query_set = set ( ) <EOL> for item in query_list : <EOL> query_set . add ( item . taxon_id ) <EOL> for id in query_set : <EOL> item = Taxon . objects . get ( taxon_id = id , type = '<STR_LIT>' ) <EOL> ret_list . append ( ( item . name , item . taxon_id ) ) <EOL> return ret_list <EOL> def taxon_id_to_genome_build ( taxon_id ) : <EOL> """<STR_LIT>""" <EOL> org = Taxon . objects . get ( taxon_id = taxon_id , type = '<STR_LIT>' ) <EOL> default_gb = GenomeBuild . objects . get ( default_build = True , species = org ) . name <EOL> return default_gb <EOL> def species_to_genome_build ( species_name ) : <EOL> """<STR_LIT>""" <EOL> ret_list = list ( ) <EOL> query_list = Taxon . objects . filter ( name__iexact = species_name ) <EOL> if not query_list . count ( ) : <EOL> raise Taxon . DoesNotExist <EOL> query_set = set ( ) <EOL> for item in query_list : <EOL> query_set . add ( item . taxon_id ) <EOL> for id in query_set : <EOL> try : <EOL> org = Taxon . objects . get ( taxon_id = id , type = '<STR_LIT>' ) <EOL> default_gb = GenomeBuild . objects . get ( <EOL> default_build = True , species = org ) . name <EOL> ret_list . append ( ( org . name , default_gb ) ) <EOL> except GenomeBuild . DoesNotExist : <EOL> pass <EOL> if not len ( ret_list ) : <EOL> raise GenomeBuild . DoesNotExist <EOL> return ret_list <EOL> def resolve_to_ucsc_genome_build ( alt_genome_build ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> genome_build = GenomeBuild . objects . exclude ( affiliation = '<STR_LIT>' ) . get ( <EOL> name__icontains = alt_genome_build ) <EOL> except : <EOL> raise <EOL> try : <EOL> return genome_build . ucsc_equivalent . name <EOL> except : <EOL> raise GenomeBuild . DoesNotExist <EOL> def genome_build_to_species ( genome_build ) : <EOL> """<STR_LIT>""" <EOL> gb = GenomeBuild . objects . get ( name__icontains = genome_build ) <EOL> return gb . species . name , gb . species . taxon_id <EOL> class CytoBand ( models . Model ) : <EOL> """<STR_LIT>""" <EOL> genomebuild = models . ForeignKey ( '<STR_LIT>' , null = True , default = None ) <EOL> chrom = models . CharField ( max_length = <NUM_LIT:255> ) <EOL> chromStart = models . IntegerField ( db_index = True ) <EOL> chromEnd = models . IntegerField ( db_index = True ) <EOL> name = models . CharField ( max_length = <NUM_LIT:255> , db_index = True ) <EOL> gieStain = models . CharField ( max_length = <NUM_LIT:255> ) <EOL> def __unicode__ ( self ) : <EOL> return self . chrom + "<STR_LIT>" + self . name <EOL> class Meta : <EOL> ordering = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> class ChromInfo ( models . Model ) : <EOL> """<STR_LIT>""" <EOL> genomebuild = models . ForeignKey ( '<STR_LIT>' , null = True , default = None ) <EOL> chrom = models . CharField ( max_length = <NUM_LIT:255> , db_index = True ) <EOL> size = models . IntegerField ( ) <EOL> fileName = models . CharField ( max_length = <NUM_LIT:255> ) <EOL> class Meta : <EOL> ordering = [ '<STR_LIT>' ] <EOL> class Gene ( models . Model ) : <EOL> """<STR_LIT>""" <EOL> genomebuild = models . ForeignKey ( '<STR_LIT>' , null = True , default = None ) <EOL> bin = models . IntegerField ( ) <EOL> name = models . CharField ( max_length = <NUM_LIT:255> , db_index = True ) <EOL> chrom = models . CharField ( max_length = <NUM_LIT:255> , db_index = True ) <EOL> strand = models . CharField ( max_length = <NUM_LIT:1> ) <EOL> txStart = models . IntegerField ( db_index = True ) <EOL> txEnd = models . IntegerField ( db_index = True ) <EOL> cdsStart = models . IntegerField ( db_index = True ) <EOL> cdsEnd = models . IntegerField ( db_index = True ) <EOL> exonCount = models . IntegerField ( ) <EOL> exonStarts = models . CommaSeparatedIntegerField ( max_length = <NUM_LIT> , <EOL> db_index = True ) <EOL> exonEnds = models . CommaSeparatedIntegerField ( max_length = <NUM_LIT> , <EOL> db_index = True ) <EOL> score = models . IntegerField ( ) <EOL> name2 = models . CharField ( max_length = <NUM_LIT:255> , db_index = True ) <EOL> cdsStartStat = models . CharField ( max_length = <NUM_LIT:10> , db_index = True ) <EOL> cdsEndStat = models . CharField ( max_length = <NUM_LIT:10> , db_index = True ) <EOL> exonFrames = models . CommaSeparatedIntegerField ( max_length = <NUM_LIT> ) <EOL> def __unicode__ ( self ) : <EOL> return self . name + "<STR_LIT>" + self . chrom <EOL> class Meta : <EOL> ordering = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> class GapRegionFile ( models . Model ) : <EOL> """<STR_LIT>""" <EOL> genomebuild = models . ForeignKey ( '<STR_LIT>' , null = True , default = None ) <EOL> bin = models . IntegerField ( ) <EOL> chrom = models . CharField ( max_length = <NUM_LIT:255> , db_index = True ) <EOL> chromStart = models . IntegerField ( db_index = True ) <EOL> chromEnd = models . IntegerField ( db_index = True ) <EOL> ix = models . IntegerField ( db_index = True ) <EOL> n = models . CharField ( max_length = <NUM_LIT:255> ) <EOL> size = models . IntegerField ( db_index = True ) <EOL> type = models . CharField ( max_length = <NUM_LIT:255> ) <EOL> bridge = models . CharField ( max_length = <NUM_LIT:255> ) <EOL> def __unicode__ ( self ) : <EOL> return self . chrom + "<STR_LIT::>" + self . chromStart + "<STR_LIT:->" + self . chromEnd <EOL> class Meta : <EOL> ordering = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> class WigDescription ( models . Model ) : <EOL> """<STR_LIT>""" <EOL> genomebuild = models . ForeignKey ( '<STR_LIT>' , null = True , default = None ) <EOL> annotation_type = models . CharField ( max_length = <NUM_LIT:255> ) <EOL> name = models . CharField ( max_length = <NUM_LIT> ) <EOL> altColor = models . CharField ( max_length = <NUM_LIT:255> ) <EOL> color = models . CharField ( max_length = <NUM_LIT:255> ) <EOL> visibility = models . CharField ( max_length = <NUM_LIT:255> ) <EOL> priority = models . IntegerField ( ) <EOL> type = models . CharField ( max_length = <NUM_LIT:255> ) <EOL> description = models . TextField ( ) <EOL> def __unicode__ ( self ) : <EOL> return self . name + "<STR_LIT:=>" + self . description + "<STR_LIT:U+002CU+0020>" + self . type <EOL> class BedFile ( models . Model ) : <EOL> """<STR_LIT>""" <EOL> genomebuild = models . ForeignKey ( '<STR_LIT>' , null = True , default = None ) <EOL> chrom = models . CharField ( max_length = <NUM_LIT:255> , db_index = True ) <EOL> chromStart = models . IntegerField ( db_index = True ) <EOL> chromEnd = models . IntegerField ( db_index = True ) <EOL> name = models . CharField ( max_length = <NUM_LIT:255> ) <EOL> score = models . CharField ( max_length = <NUM_LIT:255> ) <EOL> strand = models . CharField ( max_length = <NUM_LIT:1> ) <EOL> thickStart = models . IntegerField ( null = True ) <EOL> thickEnd = models . IntegerField ( null = True ) <EOL> itemRgb = models . CharField ( max_length = <NUM_LIT:255> ) <EOL> blockCount = models . IntegerField ( null = True ) <EOL> blockSizes = models . CommaSeparatedIntegerField ( max_length = <NUM_LIT> ) <EOL> blockStarts = models . CommaSeparatedIntegerField ( max_length = <NUM_LIT> ) <EOL> def __unicode__ ( self ) : <EOL> return self . name + "<STR_LIT>" + self . chrom + "<STR_LIT::>" + self . chromStart + "<STR_LIT:->" + self . chromEnd <EOL> class Meta : <EOL> abstract = True <EOL> ordering = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> class GffFile ( models . Model ) : <EOL> """<STR_LIT>""" <EOL> genomebuild = models . ForeignKey ( '<STR_LIT>' , null = True , default = None ) <EOL> chrom = models . CharField ( max_length = <NUM_LIT:255> , db_index = True ) <EOL> source = models . CharField ( max_length = <NUM_LIT:100> ) <EOL> feature = models . CharField ( max_length = <NUM_LIT:100> ) <EOL> start = models . IntegerField ( db_index = True ) <EOL> end = models . IntegerField ( db_index = True ) <EOL> score = models . CharField ( max_length = <NUM_LIT:100> ) <EOL> strand = models . CharField ( max_length = <NUM_LIT:1> ) <EOL> frame = models . CharField ( max_length = <NUM_LIT:100> ) <EOL> attribute = models . TextField ( ) <EOL> def __unicode__ ( self ) : <EOL> return self . feature + "<STR_LIT>" + self . chrom + "<STR_LIT::>" + self . start + "<STR_LIT:->" + self . end <EOL> class Meta : <EOL> abstract = True <EOL> ordering = [ '<STR_LIT>' , '<STR_LIT:start>' ] <EOL> class GtfFile ( GffFile ) : <EOL> """<STR_LIT>""" <EOL> gene_id = models . CharField ( max_length = <NUM_LIT:255> , db_index = True ) <EOL> transcript_id = models . CharField ( max_length = <NUM_LIT:255> , db_index = True ) <EOL> def __unicode__ ( self ) : <EOL> return self . gene_id + "<STR_LIT>" + self . chrom + "<STR_LIT::>" + self . start + "<STR_LIT:->" + self . end <EOL> class Meta : <EOL> abstract = True <EOL> class WigFile ( models . Model ) : <EOL> """<STR_LIT>""" <EOL> genomebuild = models . ForeignKey ( '<STR_LIT>' , null = True , default = None ) <EOL> chrom = models . CharField ( max_length = <NUM_LIT:255> , db_index = True ) <EOL> position = models . IntegerField ( db_index = True ) <EOL> value = models . FloatField ( ) <EOL> def __unicode__ ( self ) : <EOL> return self . chrom + "<STR_LIT::>" + self . position + "<STR_LIT>" + self . value <EOL> class Meta : <EOL> abstract = True <EOL> ordering = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> class EmpiricalMappability ( BedFile ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class TheoreticalMappability ( BedFile ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class GCContent ( WigFile ) : <EOL> """<STR_LIT>""" <EOL> annot = models . ForeignKey ( WigDescription ) <EOL> class ConservationTrack ( WigFile ) : <EOL> """<STR_LIT>""" <EOL> annot = models . ForeignKey ( WigDescription ) <EOL> class hg19_GenCode ( GtfFile ) : <EOL> """<STR_LIT>""" <EOL> gene_type = models . CharField ( max_length = <NUM_LIT:100> , db_index = True ) <EOL> gene_status = models . CharField ( max_length = <NUM_LIT:100> , db_index = True ) <EOL> gene_name = models . CharField ( max_length = <NUM_LIT:100> , db_index = True ) <EOL> transcript_type = models . CharField ( max_length = <NUM_LIT:100> , db_index = True ) <EOL> transcript_status = models . CharField ( max_length = <NUM_LIT:100> , db_index = True ) <EOL> transcript_name = models . CharField ( max_length = <NUM_LIT:100> , db_index = True ) <EOL> class ce10_WormBase ( GffFile ) : <EOL> """<STR_LIT>""" <EOL> cds = models . CharField ( max_length = <NUM_LIT:100> ) <EOL> clone = models . CharField ( max_length = <NUM_LIT:100> ) <EOL> gene = models . CharField ( max_length = <NUM_LIT:100> ) <EOL> class dm3_FlyBase ( GffFile ) : <EOL> """<STR_LIT>""" <EOL> name = models . CharField ( max_length = <NUM_LIT:100> ) <EOL> Alias = models . TextField ( ) <EOL> description = models . CharField ( max_length = <NUM_LIT:255> ) <EOL> fullname = models . CharField ( max_length = <NUM_LIT:100> ) <EOL> symbol = models . CharField ( max_length = <NUM_LIT:100> ) </s>
