-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
304b8df
commit 2100310
Showing
10 changed files
with
228 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
3.2.2 | ||
3.3.0.dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from cmat.clinvar_xml_io import ClinVarRecord | ||
from cmat.clinvar_xml_io.clinvar_submitted_record import ClinVarSubmittedRecord | ||
from cmat.clinvar_xml_io.xml_parsing import find_mandatory_unique_element, find_elements | ||
|
||
|
||
class ClinVarSet: | ||
""" | ||
A ClinVarSet groups together a single reference record (RCV) and one or more submitted records (SCVs). | ||
""" | ||
|
||
def __init__(self, cvs_xml, xsd_version): | ||
self.cvs_xml = cvs_xml | ||
|
||
rcv_elem = find_mandatory_unique_element(self.cvs_xml, 'ReferenceClinVarAssertion') | ||
self.rcv = ClinVarRecord(rcv_elem, xsd_version) | ||
|
||
scv_elems = find_elements(self.cvs_xml, 'ClinVarAssertion', allow_zero=False, allow_multiple=True) | ||
self.scvs = [ClinVarSubmittedRecord(elem, xsd_version, self.rcv) for elem in scv_elems] | ||
|
||
@property | ||
def id(self): | ||
return self.cvs_xml.attrib['ID'] | ||
|
||
@property | ||
def title(self): | ||
return find_mandatory_unique_element(self.cvs_xml, './Title').text | ||
|
||
@property | ||
def status(self): | ||
return find_mandatory_unique_element(self.cvs_xml, './RecordStatus').text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import os | ||
|
||
from cmat.clinvar_xml_io import ClinVarDataset | ||
|
||
resources_dir = os.path.join(os.path.dirname(__file__), 'resources') | ||
|
||
|
||
class TestClinvarRecordMeasure: | ||
@classmethod | ||
def setup_class(cls): | ||
input_file = os.path.join(resources_dir, 'clinvar_dataset_v2.xml.gz') | ||
cls.test_crm = next(iter(ClinVarDataset(input_file))).measure | ||
|
||
def test_hgvs(self): | ||
text_hgvs = [h.text for h in self.test_crm.all_hgvs] | ||
assert text_hgvs == ['NM_152443.3:c.677A>G', | ||
'NG_008321.1:g.32324A>G', | ||
'NC_000014.9:g.67729209A>G', | ||
'NC_000014.8:g.68195926A>G', | ||
'NM_152443.2:c.677A>G', | ||
'Q96NR8:p.Tyr226Cys', | ||
'NP_689656.2:p.Tyr226Cys'] | ||
|
||
def test_preferred_current_hgvs(self): | ||
assert self.test_crm.preferred_current_hgvs.text == 'NC_000014.9:g.67729209A>G' | ||
|
||
def test_rs(self): | ||
assert self.test_crm.rs_id == 'rs28940313' | ||
|
||
def test_nsv(self): | ||
assert self.test_crm.nsv_id is None | ||
|
||
def test_variant_type(self): | ||
assert self.test_crm.variant_type == 'single nucleotide variant' | ||
|
||
def test_measure_set_pubmed_refs(self): | ||
assert self.test_crm.pubmed_refs == [] | ||
|
||
def test_so_terms(self): | ||
assert self.test_crm.existing_so_terms == {'SO:0001583'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import os | ||
|
||
import pytest | ||
|
||
from cmat.clinvar_xml_io.clinvar_set import ClinVarSet | ||
from cmat.clinvar_xml_io.xml_parsing import iterate_cvs_from_xml | ||
|
||
|
||
@pytest.fixture | ||
def clinvar_set(): | ||
resources_dir = os.path.join(os.path.dirname(__file__), 'resources') | ||
input_file = os.path.join(resources_dir, 'clinvar_dataset_v2.xml.gz') | ||
return ClinVarSet(next(iterate_cvs_from_xml(input_file)), 2.0) | ||
|
||
|
||
@pytest.fixture | ||
def submitted_record(clinvar_set): | ||
return clinvar_set.scvs[0] | ||
|
||
|
||
def test_clinvar_set(clinvar_set): | ||
assert clinvar_set.rcv.accession == 'RCV000002127' | ||
assert len(clinvar_set.scvs) == 5 | ||
assert clinvar_set.id == '188870850' | ||
assert clinvar_set.title == 'NM_152443.3(RDH12):c.677A>G (p.Tyr226Cys) AND Leber congenital amaurosis 13' | ||
assert clinvar_set.status == 'current' | ||
|
||
|
||
def test_clinvar_submitted_record(submitted_record): | ||
assert submitted_record.accession == 'SCV000022285' | ||
assert submitted_record.submitter == 'OMIM' | ||
assert submitted_record.valid_allele_origins == {'germline'} | ||
assert submitted_record.evidence_support_pubmed_refs == [15258582, 15322982] | ||
|
||
assert submitted_record.created_date == '2013-04-04' # submission first publicly available | ||
assert submitted_record.submission_date == '2015-07-02' # submission last revised | ||
assert submitted_record.last_updated_date == '2015-07-05' # submission last revision publicly available | ||
|
||
with pytest.raises(NotImplementedError): | ||
assert submitted_record.valid_clinical_significances | ||
|
||
|
||
def test_clinvar_submitted_record_trait(submitted_record): | ||
assert len(submitted_record.traits_with_valid_names) == 1 | ||
scv_trait = submitted_record.traits_with_valid_names[0] | ||
|
||
assert scv_trait.preferred_or_other_valid_name == 'LEBER CONGENITAL AMAUROSIS 13' | ||
assert scv_trait.current_efo_aligned_xrefs == [] | ||
|
||
|
||
def test_clinvar_submitted_record_measure(submitted_record): | ||
assert submitted_record.measure is not None | ||
scv_measure = submitted_record.measure | ||
|
||
assert scv_measure.preferred_or_other_name == 'RDH12, TYR226CYS' | ||
assert scv_measure.preferred_current_hgvs is None | ||
assert not scv_measure.has_complete_coordinates | ||
assert scv_measure.variant_type == 'Variation' |
Oops, something went wrong.