def write_references(my_cursor, server_write): print('write_references') query = 'SELECT * FROM OmniSeqKnowledgebase.refs;' my_cursor.execute(query) refs = my_cursor.fetchall() m = '' counter = 0 for ref in refs: # print(ref) s = create_reference_mutation(ref) s += create_AddLiteratureReferenceJournal_mutation(ref[10],ref[3]) au_query = f'SELECT author_id FROM OmniSeqKnowledgebase.author_ref where ref_id="{ref[10]}";' my_cursor.execute(au_query) authors = [] for row in my_cursor.fetchall(): authors.append(row[0]) s += create_AddLiteratureReferenceAuthors_mutation(ref[10],authors) # print(s) m += s counter += 1 if (counter % 100 == 0): send_mutation(m, server_write) m = '' print(counter) send_mutation(m, server_write)
def write_omni_genes(omini_genes:list, server:str,editor_id:str,jax_gene_dict,pmid_extractor:callable,sp_pmid_extractor:callable, reference_dict:dict,journal_dict:dict,author_dict:dict,hgnc_gene_name_dict)->None: hgnc_gene_name_dict = create_hgnc_gene_name_dict() for omni_gene in omini_genes: gene_name: str = omni_gene['symbol'] omni_gene['panel_name'] = gene_name if gene_name in hgnc_gene_name_dict: omni_gene['panel_name'] = gene_name omni_gene['synonym'] = gene_name gene_name = hgnc_gene_name_dict[gene_name] omni_gene['symbol'] = gene_name entrez_gene_id = fetch_gene_id_by_gene_name(gene_name) omni_gene['entrez_gene_id'] = entrez_gene_id if entrez_gene_id is None: print("no entrz gene id for",gene_name) else: gene_info = fetch_gene_info_by_gene_id(entrez_gene_id) if 'genomic_pos_hg19' in gene_info: populate_omni_gene(gene_info, omni_gene) print(gene_name) s = create_myGeneInfo_gene(omni_gene, editor_id, pmid_extractor, reference_dict, journal_dict, author_dict) s += create_uniprot_entry(omni_gene, editor_id, sp_pmid_extractor, reference_dict, journal_dict, author_dict) m, omnigene_id, cat_id, syn_id = create_omniGene(omni_gene, jax_gene_dict, omni_gene['summary'], editor_id, pmid_extractor, reference_dict, journal_dict, author_dict) s += m send_mutation(s,server) else: print('no gene_info for',gene_name)
def write_hot_spot_variants(my_cursor, server_write): print('write_hot_spot_variants') query = 'SELECT * FROM OmniSeqKnowledgebase.hot_spot;' my_cursor.execute(query) rows = my_cursor.fetchall() m = '' counter = 0 for row in rows: s = f'{row[7]}: createHotSpotVariant(begin: \\"{row[4]}\\", end: \\"{row[5]}\\", gene: \\"{row[1]}\\", id: \\"{row[7]}\\", name: \\"{row[0]}\\", position: {row[6]}, referenceAminoAcid: \\"{row[2]}\\", variantAminoAcid: \\"{row[3]}\\", ),' # # createOncoTreeOccurrence(disease: String!id: ID!occurences: Int! oncoTreeCode: String!percentOccurence: String!totalSamples: Int!): String occurrences = '[' occurrences_query = f'SELECT * FROM OmniSeqKnowledgebase.hot_spot_occurrences where hot_spot_id="{row[7]}";' my_cursor.execute(occurrences_query) # id, es_id, ref_id for otc in my_cursor.fetchall(): hso_id = 'hso_' + str(otc[0]) s += f'{hso_id}: createOncoTreeOccurrence(disease: \\"{otc[1]}\\", id: \\"{otc[7]}\\", occurrences: {otc[5]}, oncoTreeCode: \\"{otc[2]}\\", percentOccurrence: \\"{otc[3]}\\", totalSamples: {otc[6]}, perThousandOccurrence: {otc[4]}, ),' occurrences += '\\"' + str(otc[7]) + '\\",' occurrences += ']' # addHotSpotVariantOccurrences(id: ID!occurrences: [ID!]!): String jvd_id = 'hsvo_' + row[7] s += f'{jvd_id}: addHotSpotVariantOccurrences(id:\\"{row[7]}\\", occurrences: {occurrences} ),' m += s counter += 1 if (counter % 100 == 0): send_mutation(m, server_write) m = '' print(counter) if m != '': send_mutation(m, server_write)
def write_omnigene(my_cursor, server_write): print('write_omnigene') query = 'SELECT * FROM OmniSeqKnowledgebase.omnigene;' my_cursor.execute(query) genes = my_cursor.fetchall() m = '' counter = 0 for gene in genes: # 0 1 2 3 4 5 6 7 8 # name, panelName, geneDescription_id, oncogenicCategory_Id, synonymsString_Id, myGeneInfo_gene_Id, jaxGene_gene_Id, uniprot_entry_Id, graph_id s = f'{gene[8]}: createOmniGene(id: \\"{gene[8]}\\", name: \\"{gene[0]}\\", panelName:\\"{gene[1]}\\" ),' jvd_id = 'omni_des_' + str(counter) s += f'{jvd_id}:addOmniGeneGeneDescription(geneDescription:[\\"{gene[2]}\\"], id:\\"{gene[8]}\\" ),' jvd_id = 'omni_cat_' + str(counter) s += f'{jvd_id}:addOmniGeneOncogenicCategory(id:\\"{gene[8]}\\", oncogenicCategory:[\\"{gene[3]}\\"] ),' jvd_id = 'omni_syn_' + str(counter) s += f'{jvd_id}:addOmniGeneSynonymsString(id:\\"{gene[8]}\\", synonymsString:[\\"{gene[4]}\\"] ),' if gene[6] != None: jvd_id = 'omni_jaxg_' + str(counter) s += f'{jvd_id}:addOmniGeneJaxGene(id:\\"{gene[8]}\\", jaxGene:[\\"{gene[6]}\\"] ),' if gene[5] != None: jvd_id = 'omni_myg_' + str(counter) s += f'{jvd_id}:addOmniGeneMyGeneInfoGene(id:\\"{gene[8]}\\", myGeneInfoGene:[\\"{gene[5]}\\"] ),' if gene[7] != None: jvd_id = 'omni_uni_' + str(counter) s += f'{jvd_id}:addOmniGeneUniprotEntry(id:\\"{gene[8]}\\", uniprotEntry:[\\"{gene[7]}\\"] ),' m += s counter += 1 if (counter % 100 == 0): send_mutation(m, server_write) m = '' print(counter) if m != '': send_mutation(m, server_write)
def write_uniprot(my_cursor, server_write): print('write_uniprot') query = 'SELECT * FROM OmniSeqKnowledgebase.uniprot_entry;' my_cursor.execute(query) uniprot = my_cursor.fetchall() m = '' counter = 0 for prot in uniprot: # 0 1 2 3 4 5 # name, accessionNumber, uniprot_id, function_Id, gene_Id, graph_id s = f'{prot[5]}: createUniprotEntry(accessionNumber: \\"{prot[1]}\\", id: \\"{prot[5]}\\", name: \\"{prot[0]}\\", uniprotID:\\"{prot[2]}\\"),' jvd_id = 'upg_' + str(counter) s += f'{jvd_id}:addUniprotEntryGene(gene:[\\"{prot[4]}\\"], id:\\"{prot[5]}\\" ),' jvd_id = 'upf_' + str(counter) s += f'{jvd_id}:addUniprotEntryFunction(function:[\\"{prot[3]}\\"], id:\\"{prot[5]}\\" ),' m += s counter += 1 # send_mutation(m, server_write) if (counter % 100 == 0): send_mutation(m, server_write) m = '' print(counter) if m != '': send_mutation(m, server_write)
def write_jax_genes(my_cursor, server_write): print('write_jax_genes') query = 'SELECT * FROM OmniSeqKnowledgebase.jax_gene;' my_cursor.execute(query) j_genes = my_cursor.fetchall() m = '' counter = 0 for gene in j_genes: syn_query = f'SELECT * FROM OmniSeqKnowledgebase.jax_synonyms where jax_gene_id="{gene[6]}";' my_cursor.execute(syn_query) synonyms = '[' for row in my_cursor.fetchall(): synonyms += '\\"' + str(row[1]) + '\\",' synonyms += ']' # name, canonicalTranscript, chromosome, entrezId, jaxId, description_Id, graph_id s = f'''{gene[6]} : createJaxGene(canonicalTranscript: \\"{gene[1]}\\", chromosome: \\"{gene[2]}\\",entrezId: \\"{gene[3]}\\", id: \\"{gene[6]}\\", jaxId: \\"{gene[4]}\\", name: \\"{gene[0]}\\", synonyms: {synonyms}),''' jvd_id = 'jvd_' + str(counter) s += f'{jvd_id}: addJaxGeneDescription(description:[\\"{gene[5]}\\"], id:\\"{gene[6]}\\"),' m += s counter += 1 if (counter % 100 == 0): send_mutation(m, server_write) m = '' print(counter) if m != '': send_mutation(m, server_write)
def write_indels(my_cursor, server_write): indel_dict = { 'ins':'Insertion', 'del':'Deletion','dup':'Duplication'} query = 'SELECT * FROM OmniSeqKnowledgebase.ocp_variant where variantType="Indel";' my_cursor.execute(query) rows = my_cursor.fetchall() m = '' counter = 0 for row in rows: pre_indel_type = row[7] if pre_indel_type in indel_dict: indel_type = indel_dict[pre_indel_type] else: indel_type = '' non_canonical_transcript = '' variant_type = 'Indel' protein_effect = get_protein_effect(row) graph_id = row[15] s = f'{graph_id}: createVariantSNVIndel(cDot: \\"{row[4]}\\", exon: \\"{row[14]}\\", gDot: \\"{row[5]}\\", id: \\"{graph_id}\\", indelType: {indel_type}, name: \\"{row[0]}\\", nonCanonicalTranscript: \\"{non_canonical_transcript}\\", pDot: \\"{row[3]}\\", proteinEffect: {protein_effect}, variantType: {variant_type}, ),' m += s m_id = 'snv_g_' + graph_id s = f'{m_id}: addVariantSNVIndelGene(id:\\"{graph_id}\\", gene: [\\"{row[1]}\\"]),' m += s m_id = 'snv_d_' + graph_id s = f'{m_id}: addVariantSNVIndelDescription(id:\\"{graph_id}\\", description: [\\"{row[2]}\\"]),' m += s jax_variant_id = row[10] # addVariantSNVIndelJaxVariant(id: ID!jaxVariant: [ID!]!): String if jax_variant_id != None: m_id = 'snv_jax_' + graph_id s = f'{m_id}: addVariantSNVIndelJaxVariant(id:\\"{graph_id}\\", jaxVariant: [\\"{jax_variant_id}\\"]),' m += s go_variant_id = row[11] # addVariantSNVIndelGoVariant(goVariant: [ID!]!id: ID!): String if go_variant_id != None: m_id = 'snv_go_' + graph_id s = f'{m_id}: addVariantSNVIndelGoVariant(id:\\"{graph_id}\\", goVariant: [\\"{go_variant_id}\\"]),' m += s clinVarVariant = row[12] # addVariantSNVIndelClinVarVariant(clinVarVariant: [ID!]!id: ID!): String if clinVarVariant != None: m_id = 'snv_cv_' + graph_id s = f'{m_id}: addVariantSNVIndelClinVarVariant(id:\\"{graph_id}\\", clinVarVariant: [\\"{clinVarVariant}\\"]),' m += s hot_spot_variant_id = row[13] # addVariantSNVIndelHotSpotVariant(hotSpotVariant: [ID!]!id: ID!): String if hot_spot_variant_id != None: m_id = 'snv_hot_spot_' + graph_id s = f'{m_id}: addVariantSNVIndelHotSpotVariant(id:\\"{graph_id}\\", hotSpotVariant: [\\"{hot_spot_variant_id}\\"]),' m += s counter += 1 if (counter % 100 == 0): send_mutation(m, server_write) m = '' print(counter) if m != '': send_mutation(m, server_write)
def write_journals(my_cursor, server_write): print('write_journals') query = 'SELECT * FROM OmniSeqKnowledgebase.journals;' my_cursor.execute(query) journals = my_cursor.fetchall() m = '' for journal in journals: # print(journal) s = create_journal_mutation(journal[0], journal[1]) m += s send_mutation(m, server_write)
def write_cnv(my_cursor, server_write): query = 'SELECT * FROM OmniSeqKnowledgebase.ocp_variant where variantType="CNV";' my_cursor.execute(query) rows = my_cursor.fetchall() m = '' counter = 0 for row in rows: non_canonical_transcript = '' copy_change = 'Indeterminate' if row[3] == 'gain': copy_change = 'Gain' elif row[3] == 'loss': copy_change = 'Loss' graph_id = row[15] s = f'{graph_id}: createVariantCNV(copyChange: {copy_change}, id: \\"{graph_id}\\", name: \\"{row[0]}\\", nonCanonicalTranscript: \\"{non_canonical_transcript}\\", ),' m += s m_id = 'cnv_g_' + graph_id s = f'{m_id}: addVariantCNVGene(id:\\"{graph_id}\\", gene: [\\"{row[1]}\\"]),' m += s m_id = 'cnv_d_' + graph_id s = f'{m_id}: addVariantCNVDescription(id:\\"{graph_id}\\", description: [\\"{row[2]}\\"]),' m += s jax_variant_id = row[10] # addVariantSNVIndelJaxVariant(id: ID!jaxVariant: [ID!]!): String if jax_variant_id != None: m_id = 'cnv_jax_' + graph_id s = f'{m_id}: addVariantCNVJaxVariant(id:\\"{graph_id}\\", jaxVariant: [\\"{jax_variant_id}\\"]),' m += s go_variant_id = row[11] # addVariantSNVIndelGoVariant(goVariant: [ID!]!id: ID!): String if go_variant_id != None: m_id = 'cnv_go_' + graph_id s = f'{m_id}: addVariantCNVGoVariant(id:\\"{graph_id}\\", goVariant: [\\"{go_variant_id}\\"]),' m += s clinVarVariant = row[12] # addVariantSNVIndelClinVarVariant(clinVarVariant: [ID!]!id: ID!): String if clinVarVariant != None: m_id = 'cnv_cv_' + graph_id s = f'{m_id}: addVariantCNVClinVarVariant(id:\\"{graph_id}\\", clinVarVariant: [\\"{clinVarVariant}\\"]),' m += s hot_spot_variant_id = row[13] # addVariantSNVIndelHotSpotVariant(hotSpotVariant: [ID!]!id: ID!): String if hot_spot_variant_id != None: m_id = 'cnv_hot_spot_' + graph_id s = f'{m_id}: addVariantCNVHotSpotVariant(id:\\"{graph_id}\\", hotSpotVariant: [\\"{hot_spot_variant_id}\\"]),' m += s counter += 1 if (counter % 100 == 0): send_mutation(m, server_write) m = '' print(counter) if m != '': send_mutation(m, server_write)
def write_internet_references(my_cursor, server_write): print('write_internet_references') query = 'SELECT * FROM OmniSeqKnowledgebase.internet_refs;' my_cursor.execute(query) irefs = my_cursor.fetchall() m = '' for iref in irefs: # print(iref) # accessed_date, web_address, short_reference, graph_id s = f'{iref[3]}: createInternetReference(accessedDate:\\"{iref[0]}\\", id:\\"{iref[3]}\\", shortReference: \\"{iref[2]}\\", webAddress:\\"{iref[1]}\\" ),' m += s send_mutation(m, server_write)
def write_users(my_cursor, server_write): print('write_users') query = 'SELECT * FROM OmniSeqKnowledgebase.users;' my_cursor.execute(query) users = my_cursor.fetchall() m = '' for user in users: # print(user) # name, password, isAdmin, graph_id s = f'{user[3]}: createUser(id:\\"{user[3]}\\", isAdmin:{return_graphql_boolean_from_sql(user[2])}, name:\\"{user[0]}\\", password:\\"{user[1]}\\"),' m += s send_mutation(m, server_write)
def internet_reference_preflight(url_string:str): m = '' pmid_array: list = [] for web_address_stub in url_string.split(','): web_address_stub = web_address_stub.replace('_','/') web_address_stub = web_address_stub.replace('*', '?') web_address_stub = web_address_stub.replace('|', ',') ref_id,s = graphql_utils_extra.create_internet_reference(web_address_stub) pmid_array.append(ref_id) m += s send_mutation(m, server) data: dict = {'result': 'success', 'refs': pmid_array} return data
def write_jax_genes(server:str,reference_dict: dict,journal_dict: dict,author_dict: dict,auto_user_id:str,PMID_extractor:callable) -> None: # gene_categories = read_oncgenes_tumor_suppressors('data/OCP_oncogenes_tumorsuppressors.csv') json_files = get_list_of_files(JAX_PATH + 'genes') print('total=',len(json_files)) count = 0 last_good = -1 for json_file in json_files: gene: dict = read_one_gene_jax_json(json_file) if gene is not None: if count > last_good: mutation_payload: str = '' # mutation_payload += write_one_jax_gene(gene,auto_user_id,gene_dict,reference_dict,journal_dict,author_dict,{}) mutation_payload += write_one_jax_gene(gene,auto_user_id,PMID_extractor,reference_dict,journal_dict,author_dict,{}) print(count,gene['gene']) send_mutation(mutation_payload, server) count += 1
def write_authors(my_cursor, server_write): print('write_authors') query = 'SELECT * FROM OmniSeqKnowledgebase.authors;' my_cursor.execute(query) authors = my_cursor.fetchall() m = '' counter = 0 for author in authors: s = create_author_mutation(author[2], author[0], author[1]) m += s counter += 1 if (counter % 100 == 0): send_mutation(m, server_write) m = '' print(counter) send_mutation(m, server_write)
def update_jax(server: str): # server:str = 'localhost' # server: str = '165.227.89.140' editor = 'updater' editor_id = get_editor_id(editor, server) print(editor_id) jax_dict = get_jax_descriptions(server) authors_dict = get_authors(server) reference_dict = get_literature_references(server) journals_dict = get_journals(server) omnigene_dict = get_omnigenes(server) json_files = get_list_of_files(JAX_PATH + 'genes') print('total=', len(json_files)) change_count = 0 new_count = 0 for json_file in json_files: jax: dict = read_one_gene_jax_json(json_file) if jax is not None: gene = jax['gene'] description = jax['description'] if gene in jax_dict: item = jax_dict[gene] statement = item['statement'] if description != statement: change_count += 1 print(change_count, 'description changed for', gene) print('new:' + description) print('old:' + statement) # pmid_extractor:callable,reference_dict:dict,journal_dict:dict,author_dict:dict s = create_jax_description(item['id'], item['field'], description, editor_id, PMID_extractor, reference_dict, journals_dict, authors_dict) print(s) send_mutation(s, server) print() else: new_count += 1 print(new_count, '***new entry', gene) s = write_one_jax_gene(jax, editor_id, PMID_extractor, reference_dict, journals_dict, authors_dict, omnigene_dict) print(s) send_mutation(s, server) print()
def write_clinvar_variants(my_cursor, server_write): print('write_clinvar_variants') query = 'SELECT * FROM OmniSeqKnowledgebase.clinvar;' my_cursor.execute(query) rows = my_cursor.fetchall() m = '' counter = 0 for row in rows: s = f'{row[8]}: createClinVarVariant(cDot: \\"{row[3]}\\", gene: \\"{row[1]}\\", id: \\"{row[8]}\\", pDot: \\"{row[2]}\\", signficanceExplanation: \\"{row[5]}\\", significance: \\"{row[4]}\\", variantID: \\"{row[0]}\\",),' m += s counter += 1 if (counter % 100 == 0): send_mutation(m, server_write) m = '' print(counter) if m != '': send_mutation(m, server_write)
def write_go_variants(my_cursor, server_write): print('write_go_variants') query = 'SELECT * FROM OmniSeqKnowledgebase.go_variant;' my_cursor.execute(query) rows = my_cursor.fetchall() m = '' counter = 0 for row in rows: s = f'{row[5]}: createGOVariant(gene: \\"{row[1]}\\", goID: \\"{row[2]}\\", id: \\"{row[5]}\\", mutationType: \\"{row[3]}\\", name: \\"{row[0]}\\", ),' m += s go_jax_id = 'gojaxv_' + row[5] s = f'{go_jax_id}: addGOVariantJaxVariant(id:\\"{row[5]}\\", jaxVariant: [\\"{row[4]}\\"]),' m += s counter += 1 if (counter % 100 == 0): send_mutation(m, server_write) m = '' print(counter) if m != '': send_mutation(m, server_write)
def main(): server: str = 'localhost' # server: str = '165.227.89.140' editor: str = '*****@*****.**' editor_id: str = get_editor_id(editor, server) print(editor_id) edits = read_edits('data/GeneDescriptions2.tsv') authors_dict: dict = get_authors(server) reference_dict: dict = get_literature_references(server) journals_dict: dict = get_journals(server) jax_gene_dict: dict = get_jax_gene_ids(server) omnigene_dict = get_omnigene_descriptions(server) hgnc_gene_name_dict = create_hgnc_gene_name_dict() for edit in edits: gene_name: str = edit['gene'] if gene_name in hgnc_gene_name_dict: gene_name = hgnc_gene_name_dict[gene_name] print(gene_name) # gene_id, old_description_id,field = get_id_old_id_and_field(edit['gene'], server) if gene_name not in omnigene_dict: gene_description: str = edit['description'] s = create_omni_gene(edit['gene'], gene_description, editor_id, jax_gene_dict, PMID_extractor, PubMed_extractor, reference_dict, journals_dict, authors_dict, hgnc_gene_name_dict) print(s) send_mutation(s, server) else: item = omnigene_dict[gene_name] s = write_new_gene_description(item['id'], item['statement'], item['field'], edit['description'], editor_id, PMID_extractor, reference_dict, journals_dict, authors_dict) print(s) send_mutation(s, server) print()
def write_editable_statements(my_cursor, server_write): print('write_editable_statements') query = 'SELECT * FROM OmniSeqKnowledgebase.editable_statements;' my_cursor.execute(query) ess = my_cursor.fetchall() m = '' counter = 0 for es in ess: # field, statement, edit_date, editor_id, deleted, graph_id statement = str(es[1]) statement = statement.replace('\n',' ') s = f'{es[5]} : createEditableStatement(deleted: {return_graphql_boolean_from_sql(es[4])}, editDate: \\"{es[2]}\\", field: \\"{es[0]}\\", id: \\"{es[5]}\\",statement: \\"{statement}\\"),' ede_id: str = 'ese_' + es[2].replace('-', '') s += f'{ede_id}: addEditableStatementEditor(editor:[\\"{es[3]}\\"], id:\\"{es[5]}\\" ),' refs = '[' ref_query = f'SELECT * FROM OmniSeqKnowledgebase.es_ref where es_id="{es[5]}";' my_cursor.execute(ref_query) # id, es_id, ref_id for row in my_cursor.fetchall(): refs += '\\"' + str(row[2]) + '\\",' iref_query = f'SELECT * FROM OmniSeqKnowledgebase.es_internet_refs where es_id="{es[5]}";' my_cursor.execute(iref_query) # id, es_id, ref_id for row in my_cursor.fetchall(): refs += '\\"' + str(row[2]) + '\\",' refs += ']' ref_id = 'ref_' + es[5] s += f'{ref_id}: addEditableStatementReferences(id:\\"{es[5]}\\", references:{refs}),' # print(s) m += s counter += 1 if (counter % 100 == 0): send_mutation(m, server_write) m = '' print(counter) send_mutation(m, server_write)
def write_mygene_genes(my_cursor, server_write): print('write_mygene_genes') query = 'SELECT * FROM OmniSeqKnowledgebase.mygene_info_gene;' my_cursor.execute(query) my_genes = my_cursor.fetchall() m = '' counter = 0 for gene in my_genes: # name, chromosome, strand, start_pos, end_pos, entrezId, description_Id, graph_id synonyms = '[]' strand = 'Forward' if gene[2]=='REVERSE' or gene[2]=='Reverse': strand = 'Reverse' s = f'{gene[7]}: createMyGeneInfoGene(chromosome: \\"{gene[1]}\\", end: {gene[4]}, entrezId: \\"{gene[5]}\\", id: \\"{gene[7]}\\", name: \\"{gene[0]}\\" start: {gene[3]}, strand:{strand},synonyms: {synonyms}),' jvd_id = 'jvd_' + str(counter) s += f'{jvd_id}: addMyGeneInfoGeneDescription(description:[\\"{gene[6]}\\"], id:\\"{gene[7]}\\"),' m += s counter += 1 if (counter % 100 == 0): send_mutation(m, server_write) m = '' print(counter) if m != '': send_mutation(m, server_write)
def write_jax_variants(my_cursor, server_write): print('write_jax_variants') query = 'SELECT * FROM OmniSeqKnowledgebase.jax_variant;' my_cursor.execute(query) variants = my_cursor.fetchall() m = '' counter = 0 for jv in variants: s = f'{jv[10]}: createJaxVariant(cDot: \\"{jv[5]}\\", gDot: \\"{jv[6]}\\",id: \\"{jv[10]}\\",jaxId: \\"{jv[2]}\\",' \ f'name: \\"{jv[0]}\\",pDot: \\"{jv[4]}\\",proteinEffect: \\"{jv[9]}\\",transcript: \\"{jv[7]}\\",variantType: \\"{jv[8]}\\", ),' jvd_id = 'jvd_' + jv[10] + '_' + jv[1] s += f'{jvd_id}: addJaxVariantDescription(description:[\\"{jv[1]}\\"], id:\\"{jv[10]}\\"),' m += s # addJaxVariantGene(gene: [ID!]!id: ID!): String jvg_id = 'jvg_' + jv[10] + '_' + jv[3] s += f'{jvg_id}: addJaxVariantGene(gene:[\\"{jv[3]}\\"], id:\\"{jv[10]}\\"),' m += s counter += 1 if (counter % 100 == 0): send_mutation(m, server_write) m = '' print(counter) if m != '': send_mutation(m, server_write)
def new_gene(gene_name): id = graphql_utils_extra.get_omnigene_ID_by_name(gene_name, server) if id==None: curation_item = {'gene': gene_name, 'description': None, 'oncogenic_category': None, 'synonmyms': None} s = graphql_utils_extra.create_omni_gene(gene_name, curation_item, editor_ids, jax_gene_dict, PMID_extractor, PubMed_extractor, reference_dict, journals_dict, authors_dict, hgnc_gene_name_dict) # print(s) if s != '': m = send_mutation(s, server) if gene_name in hgnc_gene_name_dict: gene_name = hgnc_gene_name_dict[gene_name] id = graphql_utils_extra.get_omnigene_ID_by_name(gene_name, server) data:dict = {'result_id':id, 'result_name': gene_name} return data
def reference_preflight(ref_string:str): ref_string_list = ref_string.split(',') no_dups_ref_string_list = [] for ref in ref_string_list: if ref not in no_dups_ref_string_list: no_dups_ref_string_list.append(ref) reference_string, s = graphql_utils_extra.handle_references(authors_dict, journals_dict, reference_dict, no_dups_ref_string_list) print('mutation:',s) if s != '': m = send_mutation(s, server) print('response:',m) reference_string = reference_string.replace('[','') reference_string = reference_string.replace(']','') reference_string = reference_string.replace('"','') reference_string = reference_string.replace('\\','') # print(reference_string) pmid_array:list = [] for ref in reference_string.split(','): if ref != '': pmid_array.append(ref) data:dict = {'result':'success','refs':pmid_array} return data
def update(server: str): editor_ids: dict = get_editor_ids(server) curation_data = read_curation_data() authors_dict: dict = get_authors(server) reference_dict: dict = get_literature_references(server) journals_dict: dict = get_journals(server) jax_gene_dict: dict = get_jax_gene_ids(server) omnigene_dict = get_omnigene_descriptions(server) hgnc_gene_name_dict = create_hgnc_gene_name_dict() for curation_item in curation_data: gene_name: str = curation_item['gene'] if gene_name in hgnc_gene_name_dict: gene_name = hgnc_gene_name_dict[gene_name] print(gene_name) if gene_name not in omnigene_dict: print(gene_name + ' not in omnigene_dict') s = create_omni_gene(gene_name, curation_item, editor_ids, jax_gene_dict, PMID_extractor, PubMed_extractor, reference_dict, journals_dict, authors_dict, hgnc_gene_name_dict) print(s) send_mutation(s, server) else: omnigene_id = omnigene_dict[gene_name]['id'] if curation_item['description'] is not None: old_description_id = omnigene_dict[gene_name]['description'][ 'id'] field = omnigene_dict[gene_name]['description']['field'] gene_description = curation_item['description']['statement'] editor_id = editor_ids[curation_item['description']['editor']] edit_date = curation_item['description']['edit_date'] # def write_new_gene_description(gene_id, old_description_id:str, field:str, statement:str, editor_id,edit_date:str,pmid_extractor:callable,reference_dict:dict,journal_dict:dict,author_dict:dict )->str: s = write_new_gene_description(omnigene_id, old_description_id, field, gene_description, editor_id, edit_date, PMID_extractor, reference_dict, journals_dict, authors_dict) print(s) send_mutation(s, server) if curation_item['oncogenic_category'] is not None: old_category_id = omnigene_dict[gene_name][ 'oncogenic_category']['id'] field = omnigene_dict[gene_name]['oncogenic_category']['field'] oncogenic_category = curation_item['oncogenic_category'][ 'statement'] editor_id = editor_ids[curation_item['oncogenic_category'] ['editor']] edit_date = curation_item['oncogenic_category']['edit_date'] s = write_new_oncogenic_category(omnigene_id, old_category_id, field, oncogenic_category, editor_id, edit_date, PMID_extractor, reference_dict, journals_dict, authors_dict) print(s) send_mutation(s, server) if curation_item['synonmyms'] is not None: old_synonmyms_id = omnigene_dict[gene_name]['synonyms']['id'] field = omnigene_dict[gene_name]['synonyms']['field'] synonmyms = curation_item['synonmyms']['statement'] editor_id = editor_ids[curation_item['synonmyms']['editor']] edit_date = curation_item['synonmyms']['edit_date'] s = write_new_synonym_string(omnigene_id, old_synonmyms_id, field, synonmyms, editor_id, edit_date, PMID_extractor, reference_dict, journals_dict, authors_dict) print(s) send_mutation(s, server) # gene_id, old_description_id,field = get_id_old_id_and_field(edit['gene'], server) # if gene_name not in omnigene_dict: # gene_description:str = edit['description'] # s = create_omni_gene(edit['gene'],gene_description,editor_id,jax_gene_dict,PMID_extractor,PubMed_extractor,reference_dict,journals_dict,authors_dict,hgnc_gene_name_dict) # print(s) # send_mutation(s,server) # else: # item = omnigene_dict[gene_name] # s = write_new_gene_description(item['id'],item['statement'],item['field'],edit['description'], editor_id,PMID_extractor,reference_dict,journals_dict,authors_dict) # print(s) # send_mutation(s,server) print()