diff --git a/Load/chemical.py b/Load/chemical.py index 0c6ced1..b238ac2 100644 --- a/Load/chemical.py +++ b/Load/chemical.py @@ -48,7 +48,7 @@ def add_chemical_data(cursor, cvterm_id, organism_id, dbxref_id, pub_id, db_id, pubchem_pub_id = cursor.fetchone()[0] obsolete = False - for i in range(20): + for i in range(30): cursor.execute(dbxref_sql, (db_id['CHEBI'], f"{i+1}")) chem_dbxref_id = cursor.fetchone()[0] ################################################################################## diff --git a/Load/gene_alleles.py b/Load/gene_alleles.py index 863e231..82bd7a2 100644 --- a/Load/gene_alleles.py +++ b/Load/gene_alleles.py @@ -191,7 +191,22 @@ def feature_relationship_add(cursor, count, feat_details, tool_name, gene_name, if 'org_abbr' in feat_details: org_id = org_dict[feat_details['org_abbr']] uniquename = feat_details['uniquename'].replace('', "{:07d}".format(allele_count)) - if name not in feature_id: + uniquename = uniquename.replace('', allele_name) + print(f"NOTICE: processing {name} {uniquename}") + if name == uniquename: + cursor.execute(dbxref_sql, (db_id['FlyBase'], uniquename)) + dbxref_id = cursor.fetchone()[0] + cursor.execute(feat_sql, (dbxref_id, org_id, name, uniquename, + "", 0, cvterm_id[feat_details['type']])) + feat2_id = cursor.fetchone()[0] + + # add synonyms + cursor.execute(syn_sql, (name, cvterm_id['symbol'], name)) + symbol_id = cursor.fetchone()[0] + + # add feature_synonym + cursor.execute(fs_sql, (symbol_id, feat2_id, pub_id, True)) + elif name not in feature_id: # create dbxref, accession -> uniquename cursor.execute(dbxref_sql, (db_id['FlyBase'], uniquename)) dbxref_id = cursor.fetchone()[0] @@ -374,13 +389,15 @@ def add_relationships(rela_list, cursor, count, tool_name, gene_name, allele_nam mess = feature_relationship_add(cursor, count, item, tool_name, gene_name, allele_name, feat1_id, cvterm_id, org_id, db_id, rela_pub, feature_id, org_dict) log += " {}".format(mess) + return log def create_gene_alleles(cursor, org_dict, feature_id, cvterm_id, db_id, pub_id, num_genes=5, num_alleles=3, gene_prefix=None, allele_prefix=None, tool_prefix=None, gene_relationships=None, allele_relationships=None, pub_format=None, - gene_props=None, allele_props=None, org_abbr='Dmel', allele_org_abbr='Dmel' + gene_props=None, allele_props=None, org_abbr='Dmel', allele_org_abbr='Dmel', + add_same_name=False ): """Create the genes and alleles. @@ -411,6 +428,8 @@ def create_gene_alleles(cursor, org_dict, feature_id, cvterm_id, db_id, pub_id, alelele_props: props to be added to each allele. dict has a field: [proptype, value] format org_abbr: (default 'Dmel') abbreviation for the organism. allele_org_abbr: (default 'Dmel') abbreviation for the alleles organism. + add_same_name: Some tests require an allele relationship of the same name. + See PDEV-PDEV-251 Return List: List of genes and their alleles. [gene_id1, [allele_id1, allele_id2], gene_id2, [allele_id3, allele_id4]] @@ -430,6 +449,11 @@ def create_gene_alleles(cursor, org_dict, feature_id, cvterm_id, db_id, pub_id, 'uniquename': 'FBto', 'type': 'engineered_region', 'relationship': 'associated_with'}) + if add_same_name: + allele_relationships.append({'name': "", + 'uniquename': '', + 'type': 'point_mutation', + 'relationship': 'partof'}) gene_allele_list = [] for i in range(num_genes): if pub_format: @@ -632,7 +656,8 @@ def create_merge_allele(cursor, org_dict, feature_id, cvterm_id, db_id, pub_id): allele_prefix=None, tool_prefix='Clk', allele_relationships=allele_relationships, - pub_format="merge_title_" + pub_format="merge_title_", + add_same_name=True ) for g_a in gene_alleles: print("gene {}".format(g_a[0]))