def printFile(table, outfilename): outStream = open(outfilename, "w") # printHeader(outStream) printHeader(outStream) for item in table: outStream.write("<%s/%s> \n\ta VP:GeneAnnotation ;\n" % (visumpointGene.GO, item)) outStream.write("\trdfs:subClassOf VP:GeneConcept ;\n") for symbol in table[item]: outStream.write("\tVP:GeneSymbol %s;\n" % (visumpointGene.symbol(visumpointGene.strip(symbol)))) for go in table[item][symbol]: row = table[item][symbol][go] outStream.write("%sVP:hasReference [\n" % ("\t")) outStream.write("\t\ta\tVP:GO;\n") outStream.write( "\t\tVP:ID %s;\n" % (visumpointGene.urlGO(visumpointGene.strip("GO_" + go[3 : len(go)]))) ) if row[0].startswith("GO_REF"): outStream.write( "\t\tVP:GO_REF %s;\n" % (visumpointGene.urlGO(visumpointGene.strip("GO_" + row[0][7 : len(row[0])]))) ) outStream.write("\t];\n") outStream.write(".\n\n")
def printClass(outStream, line): outStream.write("<%s/%s> \n\ta owl:Class ;\n" % (visumpointGene.GO, line[1])) outStream.write("\tVP:Symbol %s;\n" % (visumpointGene.symbol(visumpointGene.strip(line[2])))) outStream.write("\tVP:Symbol %s;\n" % (visumpointGene.symbol(visumpointGene.strip(line[2])))) # outStream.write('\trdfs:label "%s"^^xsd:string ;\n' % (visumpointGene.strip(line[2]))) # outStream.write('\trdfs:subClassOf VP:HUGO ;\n') outStream.write(".\n\n")
def printDiseaseClass(outStream,line): outStream.write('<%s/%s> \n\ta %s;\n' % (Namespace, line[0], visumpointGene.VP_PharmGKBDisease)) outStream.write('\trdfs:label "%s"^^xsd:string ;\n' % (visumpointGene.strip(line[1]))) outStream.write('\tskos:prefLabel "%s"^^xsd:string ;\n' % (visumpointGene.strip(line[1]))) trip = "" useName = "" if len(line[2]) > 0 : for name in line[2].split(','): if name.startswith("\"") and name.endswith("\""): useName = name elif name.startswith("\""): trip = name elif name.endswith("\""): useName = (trip + "," +name).strip("\"") trip = "" else : useName = name if len(useName) > 0: visumpointGene.printAlternativeName(outStream, "", visumpointGene.strip(useName), visumpointGene.VP_PharmGKB,"\t\t") useName = "" db_id_type_strB = "(.+):(.+)\((.+)\[(.+)/(.+)\]" db_id_PP = r'(.+):(.+)\(([^()]++)\((.*)\)+' strExp = "(.+):(.+)\((.+)" if len(line[4]) > 0 : for name in line[4].split('),'): #db_id_type_strB = "(.+):(.+)\((.+)\[(.+)/(.+)\]" try: match = regex.match(db_id_type_strB, name, regex.M|regex.I) if (match): visumpointGene.printCrossReference(outStream, dbReference(match.group(1)), visumpointGene.strip(match.group(2)), visumpointGene.VP_PharmGKB,"\t\t") else : #db_id_PP = r'(.+):(.+)\(([^()]++)\((.*)\)+' try: match1 = regex.match( db_id_PP, name, re.M|re.I) if (match1): visumpointGene.printCrossReference(outStream, dbReference(match1.group(1)), visumpointGene.strip(match1.group(2)), visumpointGene.VP_PharmGKB,"\t\t") else : #strExp = "(.+):(.+)\((.+)" try: match2 = regex.match( strExp, name, re.M|re.I) if(match2): visumpointGene.printCrossReference(outStream, dbReference(match2.group(1)), visumpointGene.strip(match2.group(2)), visumpointGene.VP_PharmGKB,"\t\t") else : outStream.write("#ERROR : processing External References : %s\n" % name) outStream.write("#\t\t %s\n" % line[4]) except: e = sys.exc_info()[0] print( "Error: %s" % e ) except: e = sys.exc_info()[0] print( "Error: %s" % e ) except: e = sys.exc_info()[0] print( "Error: %s" % e ) outStream.write('\t. # %s %s\n\n' % (line[1], line[0]))
def printDrugClass(outStream,line, table): drugName = visumpointGene.strip(line[1]) outStream.write('<%s/%s> \n\ta %s;\n' % (Namespace, line[0], visumpointGene.VP_PharmGKBDrug)) try : outStream.write('\trdfs:label "%s"^^xsd:string ;\n' % (drugName)) if(len(line[7])): outStream.write('\t%s %s;\n' % (visumpointGene.VP_SMILES, visumpointGene.smiles(line[7]))) if len(line[2]) > 0 : for name in line[2].split(','): visumpointGene.printGenericName(outStream, "", visumpointGene.strip(name), visumpointGene.VP_PharmGKB,"\t") if len(line[3]) > 0 : for name in line[2].split(','): visumpointGene.printTradeName(outStream, "", visumpointGene.strip(name), visumpointGene.VP_PharmGKB,"\t") try: if len(line[6]) > 0 : for xref in line[6].split(','): try : db = xref.split(":")[0] if db == "go": id = xref.split(":")[2] elif db =="url": id = xref.split(":")[1] + ":" + xref.split(":")[2] else: id = xref.split(":")[1] visumpointGene.printCrossReference(outStream,dbReference(db),visumpointGene.strip(id),visumpointGene.VP_PharmGKB, "\t") except : outStream.write('# ERROR PROCESSING printDrugClass - %s %s %s\n\n' % (line[1], line[0], xref)) except: outStream.write('# ERROR PROCESSING printDrugClass - %s %s\n\n' % (line[1], line[0])) if drugName in table: for gene in table[drugName]: if not gene == NO_GENE: visumpointGene.printHasGeneRelationship(outStream, visumpointGene.VP_Unknown , visumpointGene.strip(gene), visumpointGene.VP_PharmGKB,"\t") except: outStream.write('# ERROR PROCESSING printDrugClass - %s %s\n\n' % (line[1], line[0])) outStream.write('\t. # %s %s\n\n' % (line[1], line[0]))
def printGeneClass(outStream,line): outStream.write('<%s/%s> \n\ta %s;\n' % (Namespace, line[0], visumpointGene.VP_PharmGKBGene)) outStream.write('\trdfs:label "%s"^^xsd:string ;\n' % (visumpointGene.strip(line[3]))) visumpointGene.printCrossReference(outStream, visumpointGene.EntrezGene_ID , visumpointGene.strip(line[1]), visumpointGene.VP_PharmGKB, "\t\t") visumpointGene.printCrossReference(outStream, visumpointGene.Ensembl_ID , visumpointGene.strip(line[2]), visumpointGene.VP_PharmGKB, "\t\t") visumpointGene.printHasSymbol(outStream, visumpointGene.Ensembl_ID , visumpointGene.strip(line[4]), visumpointGene.VP_PharmGKB,"\t\t") try: if line[0] == "PA134868213": x = 0 if len(line[10]) and line[10] != 'null' : outStream.write('\tVP:CPIC "%s"^^xsd:boolean ;\n' % (visumpointGene.trueFalse(visumpointGene.strip(line[10])))) if len(line[11]) > 0 and line[11] != 'null' : outStream.write('\tVP:Chromosome "%s"^^xsd:string;\n' % (visumpointGene.strip(line[11]))) if len(line[12]) > 0 and line[12] != 'null' : outStream.write('\tVP:Start "%s"^^xsd:integer;\n' % (visumpointGene.strip(line[12]))) if len(line[13]) > 0 and line[13] != 'null' : outStream.write('\tVP:End "%s"^^xsd:integer ;\n' % (visumpointGene.strip(line[13]))) except: outStream.write('# Error XREF %s\n\n\n' % (line[0])) try: if len(line[9]) > 0 : for xref in line[9].split(','): db ="" id = "" try: db = xref.split(":")[0] if db == "go": id = xref.split(":")[2] elif db =="url": id = xref.split(":")[1] + ":" + xref.split(":")[2] else: id = xref.split(":")[1] if len(db) > 0 and len(id) > 0: visumpointGene.printCrossReference(outStream,dbReference(visumpointGene.strip(db)),visumpointGene.strip(id),visumpointGene.VP_PharmGKB, "\t\t") except: outStream.write('#Error XREF -> %s - %s\n\n\n' % (line[0], xref)) except: outStream.write('# Error XREF %s\n\n\n' % (line[0])) #outStream.write('\t\t\t # %s\n' % (visumpointGene.strip(xref))) outStream.write('\t. # %s\n\n\n' % (line[0]))
def dbReference(inStr): str = visumpointGene.strip(inStr.lower()) if str == "snomedct": return visumpointGene.VP_SnoMedCT if str == "umls": return visumpointGene.VP_UMLS if str == "ndfrt": return visumpointGene.VP_NDFRT if str == "meddra": return visumpointGene.VP_MedDRA if str == "mesh": return visumpointGene.VP_Mesh if str == "humancycgene": return visumpointGene.VP_HumanCycGene if str == "alfred": return visumpointGene.VP_Alfred if str == "ctd": return visumpointGene.VP_CTD if str == "ensembl": return visumpointGene.VP_Ensembl if str == "entrezgene": return visumpointGene.VP_EntrezGene if str == "genatlas": return visumpointGene.VP_GenAtlas if str == "genecard": return visumpointGene.VP_GeneCard if str == "go": return visumpointGene.VP_GO if str == "hgnc": return visumpointGene.VP_HGNC if str == "hugo": return visumpointGene.VP_HUGO if str == "huge": return visumpointGene.VP_HUGE if str == "dBase": return visumpointGene.VP_DBase if str == "hgnc": return visumpointGene.VP_HGNC if str == "hugo": return visumpointGene.VP_HUGO if str == "modbase": return visumpointGene.VP_ModBas if str == "mutdb": return visumpointGene.VP_MutDb if str.startswith("refseq"): return visumpointGene.VP_RefSeq if str == "omim": return visumpointGene.VP_OMIM if str == "uniprotkb": return visumpointGene.VP_UniProtKb if str == "ucscgenomebrowser": return visumpointGene.VP_UCSCGenomeBrowser if str == "iupharreceptor": return visumpointGene.VP_IupharReceptor if str == "url": return visumpointGene.VP_URL if str == "ttd": return visumpointGene.VP_TTD if str == "bindingdb": return visumpointGene.VP_BindingDb if str == "chemspider": return visumpointGene.VP_ChemSpider if str == "drugbank": return visumpointGene.VP_DrugBank if str == "keggcompound": return visumpointGene.VP_KeggCompound if str == "pubchemcompound": return visumpointGene.VP_PubChemCompound if str == "pubchemsubstance": return visumpointGene.VP_SubChemSubstance if str == "dailymed": return visumpointGene.VP_DailyMed if str == "het": return visumpointGene.VP_HET if str == "clinicaltrials": return visumpointGene.VP_ClinicalTrials if str == "dpd": return visumpointGene.VP_DPD if str == "chebi": return visumpointGene.VP_Chebi if str == "genbank": return visumpointGene.VP_Genbank if str == "ndc": return visumpointGene.VP_NDC if str == "iupharligand": return visumpointGene.VP_Iupharligand if str == "keggdrug": return visumpointGene.VP_Keggdrug if str == "pdb": return visumpointGene.VP_PDB if str == "refseqprot": return visumpointGene.VP_RefSeqProt return "ERROR %s" % inStr
def printRSIDClass(outStream,line): outStream.write('<%s/%s>\n' % (Namespace, line[1])) visumpointGene.printCrossReference(outStream,visumpointGene.VP_dbSNP,visumpointGene.strip(line[0]),visumpointGene.VP_PharmGKB,"\t\t") outStream.write('\t. # %s %s\n\n' % (line[1], line[0]))
def printHUGOClass(outStream,line): outStream.write('<%s/%s> \n\ta VP:HUGO ;\n' % (HUGO_NAMESPACE, (line[0])[5:len(line[0])])) outStream.write('\trdfs:label "%s"^^xsd:string ;\n' % (stripStuff(line[2]))) #outStream.write('\trdfs:subClassOf VP:HUGO ;\n') outStream.write('\tskos:prefLabel "%s"^^xsd:string ;\n' % (stripStuff(line[2]))) #outStream.write('\trdfs:subClassOf hugo:%s ;\n' % (line[0])) #outStream.write('\thugo:Accession_Numbers BC022009"^^xsd:string ;\n') outStream.write('\tVP:ApprovedName "%s"^^xsd:string ;\n' % (stripStuff(line[2]))) outStream.write('\tVP:ApprovedSymbol %s;\n' % (visumpointGene.symbol(visumpointGene.strip(line[1])))) outStream.write('\tVP:ApprovedSymbolString "%s"^^xsd:string;\n' % (visumpointGene.strip(line[1]))) #outStream.write('\thugo:CCDS_IDs "CCDS31071.1"^^xsd:string;\n') #outStream.write('\thugo:COSMIC_ID "RGS7"^^rdf:XMLLiteral ;\n') #outStream.write('\thugo:COSMIC_LINK "<a href=\"http://www.sanger.ac.ukz/perl/genetics/CGP/cosmic?action=gene&ln=RGS7\">COSMIC</a>"^^rdf:XMLLiteral ;\n') outStream.write('\tVP:Chromosome_Sym "%s"^^xsd:string ;\n' % (line[10])) outStream.write('\tVP:Chromosome "%s"^^xsd:string;\n' % (line[10])) outStream.write('\tSO:SO_0000105 %s;\n' % (getChromosome(line[10]))) # Chromosome Arm http://en.wikipedia.org/wiki/Locus_(genetics) outStream.write('\tSO:SO_0000341 %s;\n' % (getChromosome(line[10]))) # Band outStream.write('\tSO:SO_0000001 %s;\n' % (getChromosome(line[10]))) # Region if len(line[11]) > 0: outStream.write('\tVP:ApprovalDate "%s"^^xsd:date ;\n' % (line[11])) if len(line[12]) > 0: outStream.write('\tVP:DateModified "%s"^^xsd:date ;\n'% (line[12])) if len(line[13]) > 0: outStream.write('\tVP:DateSymbolChanged "%s"^^xsd:date ;\n' % (line[13])) if len(line[14]) > 0: outStream.write('\tVP:DateNameChanged "%s"^^xsd:date ;\n' % (line[14])) #outStream.write('\thugo:Ensembl_ID__mapped_data_supplied_by_Ensembl "ENSG00000182901"^^xsd:string ;\n') #outStream.write('\thugo:Entrez_Gene_ID "6000"^^xsd:string ;\n') #outStream.write('\thugo:Entrez_Gene_ID__mapped_data_supplied_by_NCBI "6000"^^xsd:string ;\n') #outStream.write('\thugo:GDB_ID__mapped_data "GDB:5912686"^^xsd:string ;\n') #outStream.write('\thugo:Gene_Family_Tag "RGS"^^xsd:string ;\n') #outStream.write('\thugo:HGNC_ID "HGNC:10003"^^xsd:string ;\n') outStream.write('\tVP:hasLocusGroup %s;\n' % (LocusGroup(line[5]))) #outStream.write('\thugo:Locus_Specific_Databases "<strong></strong>"^^xsd:string ;\n') outStream.write('\tVP:hasLocusType %s ;\n' % (LocusType(line[4]))) #outStream.write('\thugo:Mouse_Genome_Database_ID "MGI:1346089"^^xsd:string ;\n') #outStream.write('\thugo:Mouse_Genome_Database_ID__mapped_data_supplied_by_MGI "MGI:1346089"^^xsd:string ;\n') #outStream.write('\thugo:OMIM_ID__mapped_data_supplied_by_NCBI "602517"^^xsd:string ;\n') if len(line[6]) > 0 : for previousSymbol in line[6].split(','): outStream.write('\tVP:PreviousSymbol %s ;\n ' % (visumpointGene.symbol(visumpointGene.strip(previousSymbol)))) outStream.write('\tVP:PreviousSymbolString \"%s\"^^xsd:string ;\n' % (stripStuff(previousSymbol))) if len(line[7]) > 0 : for previousNames in line[7].split(','): outStream.write('\tVP:PreviousName \"%s\"^^xsd:string ;\n' % (stripStuff(previousNames))) if len(line[8]) > 0 : for synonyms in line[8].split(','): outStream.write('\tVP:Synonym %s ;\n' % (visumpointGene.symbol(visumpointGene.strip(synonyms)))) outStream.write('\tVP:SynonymString \"%s\"^^xsd:string ;\n' % (stripStuff(synonyms))) if len(line[22]) > 0 : for pubmedID in line[22].split(','): visumpointGene.printCitation(outStream,visumpointGene.PubMed,stripStuff(stripStuff(pubmedID)),"\t") if len(line[23]) > 0 : for RefSeq in line[23].split(','): visumpointGene.printCrossReference(outStream,visumpointGene.RefSeq,stripStuff(RefSeq),"\t") if len(line[34]) > 0 : visumpointGene.printCrossReference(outStream,visumpointGene.RefSeq,stripStuff(line[34]),"\t") if len(line[32]) > 0 : for eg in line[32].split(','): visumpointGene.printCrossReference(outStream,visumpointGene.Ensembl_ID,stripStuff(eg),"\t") if len(line[15]) > 0 : for an in line[15].split(','): outStream.write('\tVP:hasAccessionNumber [\n') outStream.write('\t\t\ta\tVP:AccessionNumber;\n') outStream.write('\t\t\tVP:ID "%s"^^xsd:string;\n' % (an)) outStream.write('\t\t];\n') if len(line[16]) > 0 : visumpointGene.printCrossReference(outStream,visumpointGene.Enzyme_ID,stripStuff(line[16]),"\t") if len(line[17]) > 0 : visumpointGene.printCrossReference(outStream,visumpointGene.EntrezGene_ID,stripStuff(line[17]),"\t") if len(line[18]) > 0 : visumpointGene.printCrossReference(outStream,visumpointGene.Ensembl_ID,stripStuff(line[18]),"\t") if len(line[19]) > 0 : visumpointGene.printCrossReference(outStream,"MouseGenomeID",stripStuff(line[19]),"\t") if len(line[29]) > 0 : for an in line[29].split(','): visumpointGene.printCrossReference(outStream,"CCSDID",stripStuff(an),"\t") if len(line[30]) > 0 : for an in line[30].split(','): visumpointGene.printCrossReference(outStream,visumpointGene.Vega_ID,stripStuff(an),"\t") if len(line[33]) > 0 : visumpointGene.printCrossReference(outStream,visumpointGene.OMIM_ID,stripStuff(line[33]),"\t") if len(line[36]) > 0 : visumpointGene.printCrossReference(outStream,visumpointGene.Ensembl_ID,stripStuff(line[36]),"\t") if len(line[37]) > 0 : visumpointGene.printCrossReference(outStream,"UCSCID",stripStuff(line[37]),"\t") if len(line[38]) > 0 : visumpointGene.printCrossReference(outStream,"MouseGenomeID",stripStuff(line[38]),"\t") if len(line[39]) > 0 : visumpointGene.printCrossReference(outStream,"RatGenomeID",stripStuff(line[39]),"\t") #outStream.write('\thugo:Rat_Genome_Database_ID__mapped_data_supplied_by_RGD "RGD:3570"^^xsd:string ;\n') #outStream.write('\thugo:Record_Type "Standard"^^xsd:string ;\n') #outStream.write('\thugo:RefSeq__mapped_data_supplied_by_NCBI "NM_002924"^^xsd:string ;\n') outStream.write('\tVP:Status %s;\n' % (Status(line[3]))) #outStream.write('\thugo:UCSC_ID__mapped_data_supplied_by_UCSC "uc001hyv.2"^^xsd:string ;\n') #outStream.write('\thugo:UniProt_ID__mapped_data_supplied_by_UniProt "P49802"^^xsd:string ;\n') #outStream.write('\thugo:VEGA_IDs "OTTHUMG00000040107"^^xsd:string .\n') outStream.write('.\n')