Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#141. Fix orthologs parser #144

Open
wants to merge 2 commits into
base: release/2023-05
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions api/db/dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,89 @@ def calorie_experiment_search(self, input):

return self.read_query(query, params, tables)

def add_experiment(self, experiment: entities.CalorieRestrictionExperiment):
experiment_dict = experiment.dict(exclude_none=True)

query = f"INSERT INTO calorie_restriction_experiment ({', '.join(experiment_dict.keys())}) "
subs = ', '.join([f'%({k})s' for k in experiment_dict.keys()])
query += f"VALUES ({subs});"

cur = self.cnx.cursor(dictionary=True)
cur.execute(query, experiment_dict)
self.cnx.commit()

cur.execute(
"SELECT * FROM calorie_restriction_experiment WHERE ID=%(id)s;",
{'id': cur.lastrowid},
)
result = cur.fetchone()

return result

def get_measurement_method(self, name):
cur = self.cnx.cursor(dictionary=True)
cur.execute(
"SELECT id FROM measurement_method WHERE name_en='{}';".format(name)
)
return cur.fetchone()

def get_measurement_type(self, name):
cur = self.cnx.cursor(dictionary=True)
cur.execute(
"SELECT id FROM measurement_type WHERE name_en='{}';".format(name)
)
return cur.fetchone()

def get_model_organism(self, name):
cur = self.cnx.cursor(dictionary=True)
cur.execute(
"SELECT id FROM model_organism WHERE name_en='{}';".format(name)
)
return cur.fetchone()

def get_organism_sex(self, name):
cur = self.cnx.cursor(dictionary=True)
cur.execute(
"SELECT id FROM organism_sex WHERE name_en='{}';".format(name)
)
return cur.fetchone()

def get_organism_line(self, name):
cur = self.cnx.cursor(dictionary=True)
cur.execute(
"SELECT id FROM organism_line WHERE name_en='{}';".format(name)
)
return cur.fetchone()

def get_sample(self, name):
cur = self.cnx.cursor(dictionary=True)
cur.execute(
"SELECT id FROM sample WHERE name_en='{}';".format(name)
)
return cur.fetchone()

def get_isoform(self, name):
cur = self.cnx.cursor(dictionary=True)
cur.execute(
"SELECT id FROM isoform WHERE name_en='{}';".format(name)
)
return cur.fetchone()

def get_treatment_time(self, name):
cur = self.cnx.cursor(dictionary=True)
cur.execute(
"SELECT id FROM treatment_time_unit WHERE name_en='{}';".format(name)
)
return cur.fetchone()

def add_treatment_time(self, name):
cur = self.cnx.cursor(dictionary=True)
cur.execute(
"INSERT INTO treatment_time_unit(name_en) VALUES ('{}');".format(name)
)
self.cnx.commit()
return cur.fetchone()


class WorkerStateDAO(BaseDAO):
"""Worker state Table fetcher."""
Expand Down
13 changes: 8 additions & 5 deletions scripts/human_orthologs/dataset_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ def parser():
source = Source(name='calorie_restriction')
result = dao.SourceDAO().get_source(source=source)
calorie_dao = dao.CalorieExperimentDAO()
correspond_measurement_method = {
'RNAseq': 'RNA-Seq',
'Microarray and qRT-PCR': 'microarray, qPCR',
}
if result:
source_id = result['id']
else:
Expand Down Expand Up @@ -77,13 +81,12 @@ def parser():
source_id=source_id,
)
dao.SourceDAO().add_relation(gene_to_source=gene_to_source)
if (
row['measurementMethod'] == "chromatography, mass_spectrometry"
or row['measurementMethod'] == "mass_spectrometry"
):
if row['measurementMethod'] in ("chromatography, mass_spectrometry", "mass_spectrometry",):
measurement_method_str = row['measurementMethod']
else:
measurement_method_str = row['measurementMethod'].lower().replace('_', ' ')
measurement_method_str = correspond_measurement_method[
row['measurementMethod']
]
measurement_method_id = calorie_dao.get_measurement_method(name=measurement_method_str)[
'id'
]
Expand Down