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

Add additional evidence/assertion fields to the CIViC consequence annotation #92

Merged
merged 6 commits into from
Jun 19, 2020
44 changes: 44 additions & 0 deletions civicpy/civic.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,19 @@ def csq(self, include_status=None):
"{} ({})".format(evidence.source.citation_id, evidence.source.source_type),
str(evidence.variant_origin),
evidence.status,
str(evidence.clinical_significance or ''),
str(evidence.evidence_direction or ''),
str(evidence.disease),
'&'.join([str(drug) for drug in evidence.drugs]),
str(evidence.drug_interaction_type or ""),
'&'.join(["{} (HPO ID {})".format(phenotype.hpo_class, phenotype.hpo_id) for phenotype in evidence.phenotypes]),
susannasiebert marked this conversation as resolved.
Show resolved Hide resolved
evidence.evidence_level,
str(evidence.rating),
"",
"",
"",
"",
"",
]))
for assertion in self.assertions:
if include_status is not None and assertion.status not in include_status:
Expand All @@ -664,6 +677,19 @@ def csq(self, include_status=None):
"",
str(assertion.variant_origin),
assertion.status,
assertion.clinical_significance,
assertion.evidence_direction,
str(assertion.disease),
'&'.join([str(drug) for drug in assertion.drugs]),
str(assertion.drug_interaction_type or ''),
"",
"",
"",
"&".join([acmg_code.code for acmg_code in assertion.acmg_codes]),
str(assertion.amp_level or ''),
assertion.format_nccn_guideline(),
str(assertion.fda_regulatory_approval or ''),
str(assertion.fda_companion_test or ''),
]))
return csq

Expand Down Expand Up @@ -798,6 +824,12 @@ def evidence(self):
def hpo_ids(self):
return [x.hpo_id for x in self.phenotypes if x.hpo_id]

def format_nccn_guideline(self):
if self.nccn_guideline is None:
return ""
else:
return "{} (v{})".format(self.nccn_guideline, self.nccn_guideline_version)


class User(CivicRecord):

Expand Down Expand Up @@ -896,10 +928,22 @@ def update(self):
class Drug(CivicAttribute):
_SIMPLE_FIELDS = CivicRecord._SIMPLE_FIELDS.union({'ncit_id'})

def __str__(self):
if self.ncit_id is None:
return self.name
else:
return "{} (NCIt ID {})".format(self.name, self.ncit_id)


class Disease(CivicAttribute):
_SIMPLE_FIELDS = CivicRecord._SIMPLE_FIELDS.union({'display_name', 'doid', 'url'})

def __str__(self):
if self.doid is None:
return self.name
else:
return "{} (DOID {})".format(self.name, self.doid)


class Country(CivicAttribute):
_SIMPLE_FIELDS = CivicRecord._SIMPLE_FIELDS.union({'iso', 'name'})
Expand Down
13 changes: 13 additions & 0 deletions civicpy/exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,19 @@ class VCFWriter(DictWriter):
'CIViC Entity Source',
'CIViC Entity Variant Origin',
'CIViC Entity Status',
'CIViC Entity Clinical Signifiance',
'CIViC Entity Direction',
'CIViC Entity Disease',
'CIViC Entity Drugs',
'CIViC Entity Drug Interaction Type',
'CIViC Evidence Phenotypes',
'CIViC Evidence Level',
'CIViC Evidence Rating',
'CIViC Assertion ACMG Codes',
'CIViC Assertion AMP Category',
'CIViC Assertion NCCN Guideline',
'CIVIC Assertion Regulatory Approval',
'CIVIC Assertion FDA Companion Test ',
]))


Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@
],
extras_require={
'test': [
'pytest',
'pytest-cov',
'pytest==4.1.0',
'pytest-cov==2.9.0',
'attrs==18.2.0',
'python-coveralls',
'coverage<5.0',
],
Expand Down