Skip to content

Commit

Permalink
push to keep safe before going back later
Browse files Browse the repository at this point in the history
  • Loading branch information
ianlongden committed Oct 2, 2024
1 parent f496e26 commit 0c00313
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
12 changes: 8 additions & 4 deletions Load/drivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ def add_driver_data(cursor, org_dict, feature_id, cvterm_id, dbxref_id, pub_id,
cursor.execute(feat_sql, (al_dbxref_id, org_id, al_name, unique_name, None, 0, cvterm_id['allele']))
feature_id[al_name] = cursor.fetchone()[0]
# add synonyms
cursor.execute(syn_sql, (feature_id[al_name], cvterm_id['symbol'], al_sym_name))
cursor.execute(syn_sql, (al_name, cvterm_id['symbol'], al_sym_name))
syn_id = cursor.fetchone()[0]
cursor.execute(fs_sql, (syn_id, feature_id[al_name], pub_id))

cursor.execute(syn_sql, (feature_id[al_name], cvterm_id['symbol'], al_sym_name[5:])) # skip sp name
cursor.execute(syn_sql, (al_name, cvterm_id['symbol'], al_sym_name[5:])) # skip sp name
syn_id = cursor.fetchone()[0]
cursor.execute(fs_sql, (syn_id, feature_id[al_name], pub_id))
# Scer\GAL4 | gene | FBgn0014445 | Scer | alleleof
Expand Down Expand Up @@ -108,7 +108,7 @@ def add_driver_data(cursor, org_dict, feature_id, cvterm_id, dbxref_id, pub_id,
ec_sql = """INSERT INTO expression_cvterm (expression_id, cvterm_id, cvterm_type_id) VALUES (%s, %s, %s)"""
fr_sql = """INSERT INTO feature_relationship (subject_id, object_id, type_id) VALUES (%s, %s, %s) RETURNING feature_relationship_id"""
frp_sql = """INSERT INTO feature_relationship_pub (feature_relationship_id, pub_id) VALUES (%s, %s)"""

fp_sql = """INSERT INTO feature_pub (feature_id, pub_id) VALUES (%s, %s)"""
for i in range(4, 9):
# Scer\\GAL4[DBD.hb1]INTERSECTIONHsap\\RELA[AD.pxn1]
# Scer\GAL4<up>DBD.hb1</up>∩Hsap\RELA<up>AD.pxn1</up>
Expand All @@ -122,7 +122,8 @@ def add_driver_data(cursor, org_dict, feature_id, cvterm_id, dbxref_id, pub_id,
cursor.execute(feat_sql, (co_dbxref_id, org_dict['Ssss'], co_name, unique_name,
None, 0, cvterm_id['split system combination']))
feature_id[co_name] = cursor.fetchone()[0]

# add feature pub
cursor.execute(fp_sql, (feature_id[co_name], feature_id[f'CO_paper_{i}']))
# add synonym
cursor.execute(syn_sql, (feature_id[co_name], cvterm_id['symbol'], co_syn))
syn_id = cursor.fetchone()[0]
Expand Down Expand Up @@ -159,8 +160,11 @@ def add_driver_data(cursor, org_dict, feature_id, cvterm_id, dbxref_id, pub_id,

cursor.execute(fr_sql, (feature_id[co_name], feature_id[f'Scer\\GAL4[DBD.hb{i}]'], cvterm_id['partially_produced_by']))
fr_id = cursor.fetchone()[0]
cursor.execute(fp_sql, (feature_id[f'Scer\\GAL4[DBD.hb{i}]'], feature_id[f'CO_paper_{i}']))

cursor.execute(frp_sql, (fr_id, feature_id[f'CO_paper_{i}']))
cursor.execute(fr_sql, (feature_id[co_name], feature_id[f'Hsap\RELA[AD.pxn{i}]'], cvterm_id['partially_produced_by']))
fr_id = cursor.fetchone()[0]
cursor.execute(fp_sql, (feature_id[f'Hsap\RELA[AD.pxn{i}]'], feature_id[f'CO_paper_{i}']))
cursor.execute(frp_sql, (fr_id, feature_id[f'CO_paper_{i}']))

12 changes: 8 additions & 4 deletions add-test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def load_cv_cvterm(parsed_yaml):
START = 0
NEW_DB = 1
FORMAT = 2
print_debug = {"FlyBase anatomy CV": 1}
specific_dbs = {'SO': (0, 'SO', '{:07d}'),
'molecular_function': (1000, 'GO', '{:07d}'),
'cellular_component': (2000, 'GO', '{:07d}'),
Expand All @@ -141,9 +142,10 @@ def load_cv_cvterm(parsed_yaml):

cursor.execute(cv_sql, (cv_name,))
cv_id[cv_name] = cursor.fetchone()[0]

print("adding cv {} [{}] and db [{}]".format(cv_name, cv_id[cv_name], db_id[cv_name]))
if cv_name in print_debug:
print("adding cv {} [{}] and db [{}]".format(cv_name, cv_id[cv_name], db_id[cv_name]))
# for specific cvterm we want to unique numbers as dbxrefs.
count = 0
if cv_name in specific_dbs:
count = specific_dbs[cv_name][START]
for cvterm_name in cv_cvterm[cv_name]:
Expand All @@ -167,7 +169,9 @@ def load_cv_cvterm(parsed_yaml):
cursor.execute(cvterm_sql, (dbxref_id[cvterm_name], cv_id[cv_name], cvterm_name))
cvterm_id[cvterm_name] = cursor.fetchone()[0]
cv_cvterm_id[cv_name][cvterm_name] = cvterm_id[cvterm_name]
print("\t{} cvterm [{}] and dbxref [{}]".format(cvterm_name, cvterm_id[cvterm_name], dbxref_id[cvterm_name]))
if cv_name in print_debug:
print(f"\t{cvterm_name} cvterm [{cvterm_id[cvterm_name]}], {cv_name} cv [{cv_id[cv_name]}] and dbxref [{dbxref_id[cvterm_name]}]")
# exit(-1)
add_cvterm_namespace(cv_cvterm_id)


Expand Down Expand Up @@ -301,7 +305,7 @@ def load_pub_author_pubprop(parsed_yaml):
cvprop_sql = """ INSERT INTO cvtermprop (cvterm_id, type_id, value) VALUES (%s, %s, %s) """

conn.commit()
count = cursor.rowcount
# count = cursor.rowcount

###################
# create chromosome
Expand Down
9 changes: 6 additions & 3 deletions data/cv_cvterm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ FlyBase anatomy CV: ['embryo','dopaminergic PAM neuron 1', 'dopaminergic PAM neu
'increased number']
####### End of order matters cv/cvterms

anonymous: ['affectedby']

cell_line_cvtermprop type: ['basis']
cell_lineprop type: ['internalnotes', 'lab_of_origin', 'comment', 'source_genotype',
'source_strain', 'source_cross', 'karyotype']
Expand All @@ -40,7 +42,8 @@ feature_cvtermprop type: [
feature_expression property type: ['curated_as', 'comment']
feature_pubprop type: ['abstract_languages']
feature_relationshipprop type: ['fly_disease-implication_change', 'comment', 'relative_position', 'score',
'start_location', 'end_location', 'is_subset_expression', 'is_relative_wildtype']
'start_location', 'end_location', 'is_subset_expression', 'is_relative_wildtype',
'control_comment']

FlyBase: ['FlyBase analysis']
FlyBase_internal: ['pubprop type:curated_by']
Expand Down Expand Up @@ -114,7 +117,7 @@ property type: [
'propagate_transgenic_uses', 'protein_coding_gene', 'protocol', 'reported_antibod_gen',
'significant_subject_in_review', 'source_prep', 'stage', 'strain', 'strain_type', 'sub_datatype', 'taxgroup', 'wild_type_role',
'curated_chromosomal_location', 'curated_cytological_location', 'flanking_type', 'first_base_of_target',
'problem', 'first_base_of_unique_in_natTE']
'problem', 'first_base_of_unique_in_natTE', 'is_multiple_insertion_line', 'chromosomal_orientation']

pub type: [
'computer file', 'unattributed', 'unspecified', 'personal communication to FlyBase',
Expand Down Expand Up @@ -143,7 +146,7 @@ relationship type: [
'overlap_inferred', 'partially_produced_by', 'parent_grp', 'part_deletes', 'part_duplicates', 'partof',
'primer_progenitor_of', 'producedby', 'progenitor', 'replacement_descendant_of', 'representative_isoform',
'recom_right_end', 'recom_left_end', 'related_tool', 'segregant_of', 'tagged_with', 'undefined_grp',
'transposed_descendant_of', 'recombinant_descendant_of', 'modified_descendant_of']
'transposed_descendant_of', 'recombinant_descendant_of', 'modified_descendant_of', 'affectedby']

selected_anatomy: [
'unassigned_class', 'selected_anatomy', 'unassigned_anatomy', 'selected_class',
Expand Down

0 comments on commit 0c00313

Please sign in to comment.