<s> """<STR_LIT>""" <EOL> from collections import defaultdict <EOL> filename = '<STR_LIT>' <EOL> detailed_out = open ( filename , '<STR_LIT:w>' ) <EOL> file = '<STR_LIT>' <EOL> summary_out = open ( file , '<STR_LIT:w>' ) <EOL> detailed_out . write ( "<STR_LIT:\t>" . join ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) ) <EOL> detailed_out . write ( "<STR_LIT:\n>" ) <EOL> summary_out . write ( "<STR_LIT:\t>" . join ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) ) <EOL> summary_out . write ( "<STR_LIT:\n>" ) <EOL> mouse_phenotype = defaultdict ( list ) <EOL> genic_intolerance = defaultdict ( list ) <EOL> keygene = list_hgnc = [ ] <EOL> transcript_min = defaultdict ( list ) <EOL> transcript_max = defaultdict ( list ) <EOL> lines_seen = set ( ) <EOL> for line in open ( "<STR_LIT>" , '<STR_LIT:r>' ) : <EOL> if line . startswith ( "<STR_LIT:#>" ) is False : <EOL> field = line . strip ( ) . split ( "<STR_LIT:\t>" ) <EOL> name = str ( field [ <NUM_LIT:0> ] ) <EOL> score = str ( field [ <NUM_LIT:1> ] ) <EOL> percentile = str ( field [ <NUM_LIT:2> ] ) <EOL> ( key , value ) = ( name , percentile ) <EOL> genic_intolerance [ name ] . append ( percentile ) <EOL> for row in open ( "<STR_LIT>" , '<STR_LIT:r>' ) : <EOL> col = row . strip ( ) . split ( "<STR_LIT:\t>" ) <EOL> entrez_id = str ( col [ <NUM_LIT:1> ] ) . lstrip ( ) <EOL> mph = str ( col [ <NUM_LIT:5> ] ) . lstrip ( ) . replace ( '<STR_LIT:U+0020>' , '<STR_LIT:U+002C>' ) if str ( col [ <NUM_LIT:5> ] ) != '<STR_LIT>' else None <EOL> ( key , value ) = ( entrez_id , mph ) <EOL> mouse_phenotype [ entrez_id ] . append ( mph ) <EOL> for each in open ( "<STR_LIT>" , '<STR_LIT:r>' ) : <EOL> if each . startswith ( "<STR_LIT>" ) is False : <EOL> k = each . strip ( ) . split ( "<STR_LIT:\t>" ) <EOL> chr = "<STR_LIT>" + str ( ( k [ <NUM_LIT:0> ] ) ) <EOL> ens = str ( k [ <NUM_LIT:2> ] ) <EOL> start = str ( k [ <NUM_LIT:10> ] ) <EOL> end = str ( k [ <NUM_LIT:11> ] ) <EOL> transcript_min [ ( chr , ens ) ] . append ( start ) <EOL> transcript_max [ ( chr , ens ) ] . append ( end ) <EOL> for each in open ( "<STR_LIT>" , '<STR_LIT:r>' ) : <EOL> if each . startswith ( "<STR_LIT>" ) is False : <EOL> k = each . strip ( ) . split ( "<STR_LIT:\t>" ) <EOL> chrom = "<STR_LIT>" + str ( ( k [ <NUM_LIT:0> ] ) ) <EOL> hgnc = str ( k [ <NUM_LIT:1> ] ) <EOL> ens_geneid = str ( k [ <NUM_LIT:2> ] ) <EOL> ens_transid = str ( k [ <NUM_LIT:3> ] ) <EOL> trans_biotype = str ( k [ <NUM_LIT:4> ] ) <EOL> status = str ( k [ <NUM_LIT:5> ] ) <EOL> ccds_id = str ( k [ <NUM_LIT:6> ] ) <EOL> hgnc_id = str ( k [ <NUM_LIT:7> ] ) <EOL> cds_len = str ( k [ <NUM_LIT:8> ] ) <EOL> protein_len = str ( k [ <NUM_LIT:9> ] ) <EOL> transcript_start = str ( k [ <NUM_LIT:10> ] ) <EOL> transcript_end = str ( k [ <NUM_LIT:11> ] ) <EOL> strand = str ( k [ <NUM_LIT:12> ] ) <EOL> previous = str ( k [ <NUM_LIT> ] ) . replace ( "<STR_LIT:U+0020>" , "<STR_LIT>" ) <EOL> synonyms = str ( k [ <NUM_LIT> ] ) . replace ( "<STR_LIT:U+0020>" , "<STR_LIT>" ) <EOL> entrez = str ( k [ <NUM_LIT:15> ] ) <EOL> if ( chrom , ens_geneid ) in transcript_min : <EOL> minmum = sorted ( transcript_min [ ( chrom , ens_geneid ) ] ) [ <NUM_LIT:0> ] <EOL> if ( chrom , ens_geneid ) in transcript_max : <EOL> maxmum = sorted ( transcript_max [ ( chrom , ens_geneid ) ] ) [ - <NUM_LIT:1> ] <EOL> rvis = genic_intolerance [ hgnc ] [ <NUM_LIT:0> ] if hgnc in genic_intolerance else None <EOL> pheno = mouse_phenotype [ entrez ] if entrez in mouse_phenotype else None <EOL> if pheno is not None and len ( pheno ) == <NUM_LIT:1> : <EOL> phenotype = pheno [ <NUM_LIT:0> ] <EOL> elif pheno is None : <EOL> phenotype = "<STR_LIT:None>" <EOL> else : <EOL> if len ( pheno ) > <NUM_LIT:1> : <EOL> string = "<STR_LIT:U+002C>" . join ( pheno ) <EOL> if "<STR_LIT:None>" in string and "<STR_LIT>" not in string : <EOL> phenotype = None <EOL> if "<STR_LIT:None>" not in string and "<STR_LIT>" in string : <EOL> phenotype = "<STR_LIT:U+002C>" . join ( set ( string . split ( "<STR_LIT:U+002C>" ) ) ) <EOL> if "<STR_LIT:None>" in string and "<STR_LIT>" in string : <EOL> phen = string . split ( "<STR_LIT:U+002C>" ) <EOL> phenotype = "<STR_LIT:U+002C>" . join ( [ x for x in phen if x != "<STR_LIT:None>" ] ) <EOL> if hgnc != "<STR_LIT:None>" : <EOL> list_hgnc . append ( hgnc ) <EOL> if "<STR_LIT:None>" in previous and "<STR_LIT:None>" in synonyms and "<STR_LIT:None>" in hgnc : <EOL> string = None <EOL> else : <EOL> gene_string = hgnc + "<STR_LIT:U+002C>" + previous + "<STR_LIT:U+002C>" + synonyms <EOL> if gene_string . startswith ( "<STR_LIT:None>" ) : <EOL> string = gene_string . replace ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> else : <EOL> string = gene_string . replace ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> if string is not None : <EOL> genes = set ( string . split ( "<STR_LIT:U+002C>" ) ) <EOL> if len ( genes ) > <NUM_LIT:1> : <EOL> for each in genes : <EOL> keygene = set ( [ each ] ) <EOL> synonym = genes . difference ( keygene ) <EOL> gene_name = '<STR_LIT:U+002C>' . join ( keygene ) <EOL> other_names = '<STR_LIT:U+002C>' . join ( synonym ) <EOL> hgnc_flag = "<STR_LIT:1>" if gene_name in list_hgnc else "<STR_LIT:0>" <EOL> is_hgnc_id = hgnc_id if gene_name in list_hgnc else "<STR_LIT:None>" <EOL> line = "<STR_LIT:\t>" . join ( [ chrom , gene_name , hgnc_flag , ens_geneid , is_hgnc_id , <EOL> other_names , str ( rvis ) , strand , minmum , maxmum , str ( phenotype ) ] ) <EOL> if line not in lines_seen : <EOL> summary_out . write ( line ) <EOL> summary_out . write ( "<STR_LIT:\n>" ) <EOL> lines_seen . add ( line ) <EOL> detailed_out . write ( "<STR_LIT:\t>" . join ( [ chrom , gene_name , hgnc_flag , ens_geneid , ens_transid , trans_biotype , <EOL> status , ccds_id , is_hgnc_id , cds_len , protein_len , transcript_start , <EOL> transcript_end , strand , other_names , str ( rvis ) , entrez , str ( phenotype ) ] ) ) <EOL> detailed_out . write ( "<STR_LIT:\n>" ) <EOL> elif len ( genes ) == <NUM_LIT:1> : <EOL> gene_name = '<STR_LIT:U+002C>' . join ( genes ) <EOL> other_names = "<STR_LIT:None>" <EOL> hgnc_flag = "<STR_LIT:1>" if gene_name in list_hgnc else "<STR_LIT:0>" <EOL> is_hgnc_id = hgnc_id if gene_name in list_hgnc else "<STR_LIT:None>" <EOL> line = "<STR_LIT:\t>" . join ( [ chrom , str ( gene_name ) , hgnc_flag , ens_geneid , is_hgnc_id , <EOL> other_names , str ( rvis ) , strand , minmum , maxmum , str ( phenotype ) ] ) <EOL> if line not in lines_seen : <EOL> summary_out . write ( line ) <EOL> summary_out . write ( "<STR_LIT:\n>" ) <EOL> lines_seen . add ( line ) <EOL> detailed_out . write ( "<STR_LIT:\t>" . join ( [ chrom , str ( gene_name ) , hgnc_flag , ens_geneid , ens_transid , trans_biotype , <EOL> status , ccds_id , is_hgnc_id , cds_len , protein_len , transcript_start , <EOL> transcript_end , strand , other_names , str ( rvis ) , entrez , str ( phenotype ) ] ) ) <EOL> detailed_out . write ( "<STR_LIT:\n>" ) <EOL> elif string is None : <EOL> gene_name = "<STR_LIT:None>" <EOL> other_names = "<STR_LIT:None>" <EOL> hgnc_flag = "<STR_LIT:0>" <EOL> is_hgnc_id = "<STR_LIT:None>" <EOL> line = "<STR_LIT:\t>" . join ( [ chrom , gene_name , hgnc_flag , ens_geneid , is_hgnc_id , <EOL> other_names , str ( rvis ) , strand , minmum , maxmum , str ( phenotype ) ] ) <EOL> if line not in lines_seen : <EOL> summary_out . write ( line ) <EOL> summary_out . write ( "<STR_LIT:\n>" ) <EOL> lines_seen . add ( line ) <EOL> detailed_out . write ( "<STR_LIT:\t>" . join ( [ chrom , gene_name , hgnc_flag , ens_geneid , ens_transid , trans_biotype , status , <EOL> ccds_id , is_hgnc_id , cds_len , protein_len , transcript_start , transcript_end , <EOL> strand , other_names , str ( rvis ) , entrez , str ( phenotype ) ] ) ) <EOL> detailed_out . write ( "<STR_LIT:\n>" ) <EOL> detailed_out . close ( ) <EOL> summary_out . close ( ) </s>
