def test_multiple_variants(self): node_data = Gene('HGNC', 'AKT1', variants=[Hgvs('p.Phe508del'), Hgvs('p.Phe509del')]) node_parent_data = node_data.get_parent() node_parent_tuple = node_parent_data self.graph.add_node_from_data(node_data) self.assertIn(node_data, self.graph) self.assertIn(node_parent_tuple, self.graph) self.assertEqual(2, self.graph.number_of_nodes()) self.assertEqual(1, self.graph.number_of_edges())
def test_trunc_2(self): """Test a truncation in which the amino acid is specified.""" statement = 'trunc(Gly40)' result = self.parser.parseString(statement) expected = Hgvs('p.Gly40*') self.assertEqual(expected, result.asDict())
def test_single_variant(self): node_data = Gene('HGNC', 'AKT1', variants=Hgvs('p.Phe508del')) node_parent_data = node_data.get_parent() self.graph.add_node_from_data(node_data) self.assertIn(node_data, self.graph) self.assertIn(node_parent_data, self.graph) self.assertEqual(2, self.graph.number_of_nodes()) self.assertEqual(1, self.graph.number_of_edges())
def test_canonicalize_variant_dsl(self): """Use the __str__ functions in the DSL to create BEL instead of external pybel.canonicalize.""" self.assertEqual('var("p.Val600Glu")', str(Hgvs('p.Val600Glu'))) self.assertEqual('var("p.Val600Glu")', str(ProteinSubstitution('Val', 600, 'Glu'))) self.assertEqual('pmod(go:0006468 ! "protein phosphorylation")', str(ProteinModification('Ph'))) self.assertEqual('pmod(TEST:Ph)', str(ProteinModification('Ph', namespace='TEST'))) self.assertEqual( 'pmod(TEST:Ph, Ser)', str(ProteinModification('Ph', namespace='TEST', code='Ser'))) self.assertEqual( 'pmod(TEST:Ph, Ser, 5)', str( ProteinModification('Ph', namespace='TEST', code='Ser', position=5))) self.assertEqual( 'pmod(GO:"protein phosphorylation", Thr, 308)', str( ProteinModification(name='protein phosphorylation', namespace='GO', code='Thr', position=308))) self.assertEqual('frag("?")', str(Fragment())) self.assertEqual('frag("672_713")', str(Fragment(start=672, stop=713))) self.assertEqual('frag("?", "descr")', str(Fragment(description='descr'))) self.assertEqual( 'frag("672_713", "descr")', str(Fragment(start=672, stop=713, description='descr'))) self.assertEqual('gmod(go:0006306 ! "DNA methylation")', str(GeneModification('Me'))) self.assertEqual('gmod(TEST:Me)', str(GeneModification('Me', namespace='TEST'))) self.assertEqual( 'gmod(GO:"DNA Methylation")', str(GeneModification('DNA Methylation', namespace='GO')))
def test_trunc_1(self): statement = 'trunc(40)' result = self.parser.parseString(statement) expected = Hgvs('p.40*') self.assertEqual(expected, result.asDict())
def test_chromosome_1(self): statement = 'variant(g.117199646_117199648delCTT)' expected = Hgvs('g.117199646_117199648delCTT') result = self.parser.parseString(statement) self.assertEqual(expected, result.asDict())
def test_chromosome_2(self): statement = 'var(c.1521_1523delCTT)' expected = Hgvs('c.1521_1523delCTT') result = self.parser.parseString(statement) self.assertEqual(expected, result.asDict())
def test_unspecified(self): statement = 'var(=)' expected = Hgvs('=') result = self.parser.parseString(statement) self.assertEqual(expected, result.asDict())
def test_frameshift(self): statement = 'variant(p.Thr1220Lysfs)' expected = Hgvs('p.Thr1220Lysfs') result = self.parser.parseString(statement) self.assertEqual(expected, result.asDict())
def test_protein_del_quoted(self): statement = 'variant("p.Phe508del")' expected = Hgvs('p.Phe508del') result = self.parser.parseString(statement) self.assertEqual(expected, result.asDict())
def test_protein_mut(self): statement = 'var(p.Gly576Ala)' expected = Hgvs('p.Gly576Ala') result = self.parser.parseString(statement) self.assertEqual(expected, result.asDict())
def test_multiple_variants(self, mock): node_data = Gene(namespace='HGNC', name='AKT1', variants=[Hgvs('p.Phe508del'), Hgvs('p.Phe509del')]) self._help_reconstitute(node_data, 2, 1)
def test_Hgvs(self, mock): node_data = Gene(namespace='HGNC', name='AKT1', variants=Hgvs('p.Phe508del')) self._help_reconstitute(node_data, 2, 1)
def test_gsub(self): statement = 'sub(G,308,A)' result = self.parser.parseString(statement) expected_dict = Hgvs('c.308G>A') self.assertEqual(expected_dict, result.asDict())
def test_psub_2(self): statement = 'sub(Ala, 127, Tyr)' result = self.parser.parseString(statement) expected_list = Hgvs('p.Ala127Tyr') self.assertEqual(expected_list, result.asDict())
def test_protein_trunc_legacy(self): statement = 'var(p.65*)' result = self.parser.parseString(statement) expected = Hgvs('p.65*') self.assertEqual(expected, result.asDict())
def test_rna_del(self): statement = 'var(r.1653_1655delcuu)' expected = Hgvs('r.1653_1655delcuu') result = self.parser.parseString(statement) self.assertEqual(expected, result.asDict())
egfr = hgnc(name='EGFR') fadd = hgnc(name='FADD') casp8 = hgnc(name='CASP8') mia = hgnc(name='MIA') il6 = Protein('HGNC', 'IL6') adgrb1 = Protein(namespace='HGNC', name='ADGRB1') adgrb2 = Protein(namespace='HGNC', name='ADGRB2') adgrb_complex = ComplexAbundance([adgrb1, adgrb2]) achlorhydria = Pathology(namespace='MESHD', name='Achlorhydria') akt1_rna = akt1.get_rna() akt1_gene = akt1_rna.get_gene() akt_methylated = akt1_gene.with_variants(GeneModification('Me')) akt1_phe_508_del = akt1_gene.with_variants(Hgvs('p.Phe508del')) cftr = hgnc('CFTR') cftr_protein_unspecified_variant = cftr.with_variants(HgvsUnspecified()) cftr_protein_phe_508_del = cftr.with_variants(Hgvs('p.Phe508del')) adenocarcinoma = Pathology('MESHD', 'Adenocarcinoma') interleukin_23_complex = NamedComplexAbundance('GO', 'interleukin-23 complex') oxygen_atom = Abundance(namespace='CHEBI', name='oxygen atom') hydrogen_peroxide = Abundance('CHEBI', 'hydrogen peroxide') tmprss2_gene = Gene('HGNC', 'TMPRSS2') tmprss2_erg_gene_fusion = GeneFusion( partner_5p=tmprss2_gene,