示例#1
0
    def test_constructor(self):
        dna1 = core.DnaSpeciesType(circular=False, double_stranded=False)

        gene1 = eukaryote.GeneLocus(polymer=dna1, start=9, end=15)
        gene2 = eukaryote.GeneLocus(polymer=dna1, start=17, end=18)

        promoter1 = 'ENSR00000172399'
        promoter2 = 'ENSR00000309980'

        tf1 = eukaryote.ProteinSpeciesType(id='tf1')
        tf2 = eukaryote.ProteinSpeciesType(id='tf2')

        reg_module1 = eukaryote.RegulatoryModule(
            gene=gene1,
            promoter=promoter1,
            activity=eukaryote.ActivityLevel.active,
            type=eukaryote.RegulationType.proximal,
            transcription_factor_regulation=[
                eukaryote.TranscriptionFactorRegulation(
                    transcription_factor=tf1,
                    direction=eukaryote.RegulatoryDirection.activation),
                eukaryote.TranscriptionFactorRegulation(
                    transcription_factor=tf2,
                    direction=eukaryote.RegulatoryDirection.repression)
            ]) 

        reg_module2 = eukaryote.RegulatoryModule(
            gene=gene1,
            promoter=promoter1,
            activity=eukaryote.ActivityLevel.active,
            type=eukaryote.RegulationType.distal,
            transcription_factor_regulation=[eukaryote.TranscriptionFactorRegulation(
                transcription_factor=tf1,
                direction=eukaryote.RegulatoryDirection.repression)]) 

        reg_module3 = eukaryote.RegulatoryModule(
            id='rm3',
            name='reg_module3',
            activity=eukaryote.ActivityLevel.inactive,
            gene=gene2,
            promoter=promoter2)

        self.assertEqual(reg_module1.gene, gene1)
        self.assertEqual(reg_module1.promoter, promoter1)
        self.assertEqual(reg_module1.activity.name, 'active')
        self.assertEqual(reg_module1.type.value, 1)
        self.assertEqual(sorted([i.transcription_factor.id for i in reg_module1.transcription_factor_regulation]), 
            ['tf1', 'tf2'])
        self.assertEqual(sorted([i.direction.name for i in reg_module1.transcription_factor_regulation]), 
            ['activation', 'repression'])
        self.assertEqual(reg_module2.gene, gene1)
        self.assertEqual(reg_module2.promoter, promoter1)
        self.assertEqual(reg_module2.activity.name, 'active')
        self.assertEqual(reg_module2.type.value, 2)
        self.assertEqual(reg_module2.transcription_factor_regulation[0].transcription_factor, tf1)
        self.assertEqual(reg_module2.transcription_factor_regulation[0].direction.name, 'repression')
        self.assertEqual(reg_module3.id, 'rm3')
        self.assertEqual(reg_module3.activity.name, 'inactive')
        self.assertEqual(reg_module3.name, 'reg_module3')
        self.assertEqual(reg_module3.promoter, promoter2)
    def test_constructor(self):

        tf1 = eukaryote.ProteinSpeciesType(id='tf1')
        tf2 = eukaryote.ProteinSpeciesType(id='tf2')
        tf_reg1 = eukaryote.TranscriptionFactorRegulation(
            transcription_factor=tf1,
            direction=eukaryote.RegulatoryDirection.repression)
        tf_reg2 = eukaryote.TranscriptionFactorRegulation(
            transcription_factor=tf2,
            direction=eukaryote.RegulatoryDirection.activation)
        tf_reg3 = eukaryote.TranscriptionFactorRegulation(
            transcription_factor=tf2,
            direction=eukaryote.RegulatoryDirection.repression)

        self.assertEqual(tf_reg1.transcription_factor, tf1)
        self.assertEqual(tf_reg1.direction.name, 'repression')
        self.assertEqual(tf_reg2.direction.name, 'activation')
        self.assertEqual(tf_reg3.transcription_factor, tf2)
示例#3
0
    def test_get_charge(self):
        # Default translation table used is 1 (standard)
        self.assertEqual(self.prot1.get_charge(), 1)
        self.assertEqual(self.prot2.get_charge(), 2)

        # Test using input sequence
        test_prot = eukaryote.ProteinSpeciesType()
        self.assertEqual(test_prot.get_charge(seq_input=Bio.Seq.Seq('MKVLINKNEL')), 1)
        self.assertEqual(test_prot.get_charge(seq_input=Bio.Seq.Seq('MKKFLLTPL')), 2)
示例#4
0
    def test_get_mol_wt(self):
        # Default translation table used is 1 (standard)
        self.assertAlmostEqual(self.prot1.get_mol_wt(), 1201.49, delta=0.3)
        self.assertAlmostEqual(self.prot2.get_mol_wt(), 1090.43, delta=0.3)

        # Test using input sequence
        test_prot = eukaryote.ProteinSpeciesType()
        self.assertAlmostEqual(test_prot.get_mol_wt(seq_input=Bio.Seq.Seq('MKVLINKNEL')), 1201.49, delta=0.3)
        self.assertAlmostEqual(test_prot.get_mol_wt(seq_input=Bio.Seq.Seq('MKKFLLTPL')), 1090.43, delta=0.3)
    def test_ComplexSpeciesType(self):

        self.tmp_dirname = tempfile.mkdtemp()
        sequence_path = os.path.join(self.tmp_dirname, 'test_seq.fasta')
        with open(sequence_path, 'w') as f:
            f.write(
                '>dna1\nTTTATGAARGTNCTCATHAAYAARAAYGARCTCTAGTTTATGAARTTYAARTTYCTCCTCACNCCNCTCTAATTT\n'
            )

        dna1 = core.DnaSpeciesType(id='dna1', sequence_path=sequence_path)

        # Protein subunit 1
        gene1 = eukaryote.GeneLocus(polymer=dna1, start=1, end=36)
        exon1 = eukaryote.GenericLocus(start=4, end=36)
        transcript1 = eukaryote.TranscriptSpeciesType(gene=gene1,
                                                      exons=[exon1])
        cds1 = eukaryote.GenericLocus(start=4, end=36)
        prot1 = eukaryote.ProteinSpeciesType(transcript=transcript1,
                                             coding_regions=[cds1])

        # Protein subunit 2
        gene2 = eukaryote.GeneLocus(polymer=dna1, start=37, end=75)
        exon2 = eukaryote.GenericLocus(start=40, end=72)
        transcript2 = eukaryote.TranscriptSpeciesType(gene=gene2,
                                                      exons=[exon2])
        cds2 = eukaryote.GenericLocus(start=40, end=72)
        prot2 = eukaryote.ProteinSpeciesType(transcript=transcript2,
                                             coding_regions=[cds2])

        species_coeff1 = core.SpeciesTypeCoefficient(species_type=prot1,
                                                     coefficient=2)
        species_coeff2 = core.SpeciesTypeCoefficient(species_type=prot2,
                                                     coefficient=3)
        complex1 = core.ComplexSpeciesType(
            subunits=[species_coeff1, species_coeff2])

        self.assertEqual(complex1.get_charge(), 8)
        self.assertAlmostEqual(
            complex1.get_mol_wt(),
            (2 * prot1.get_mol_wt() + 3 * prot2.get_mol_wt()))
        self.assertEqual(complex1.get_empirical_formula(),
                         chem.EmpiricalFormula('C292H492N64O66S5'))

        shutil.rmtree(self.tmp_dirname)
    def setUp(self):
        self.tmp_dirname = tempfile.mkdtemp()
        sequence_path = os.path.join(self.tmp_dirname, 'test_seq.fasta')
        with open(sequence_path, 'w') as f:
            f.write(
                '>dna1\nTTTATGAARGTNCTCATHAAYAARAAYGARCTCTAGTTTATGAARTTYAARTTYCTCCTCACNCCNCTCTAATTT\n'
            )

        dna1 = core.DnaSpeciesType(id='dna1', sequence_path=sequence_path)

        cell1 = dna1.cell = core.Cell()

        gene1 = eukaryote.GeneLocus(polymer=dna1, start=1, end=36)
        exon1 = eukaryote.GenericLocus(start=4, end=36)
        transcript1 = eukaryote.TranscriptSpeciesType(gene=gene1,
                                                      exons=[exon1])
        cds1 = eukaryote.GenericLocus(start=4, end=36)
        self.prot1 = eukaryote.ProteinSpeciesType(id='prot1',
                                                  name='protein1',
                                                  uniprot='Q12X34',
                                                  transcript=transcript1,
                                                  coding_regions=[cds1])

        gene2 = eukaryote.GeneLocus(polymer=dna1,
                                    start=30,
                                    end=75,
                                    strand=core.PolymerStrand.positive)
        exon2_1 = eukaryote.GenericLocus(start=32, end=35)
        exon2_2 = eukaryote.GenericLocus(start=38, end=45)
        exon2_3 = eukaryote.GenericLocus(start=49, end=54)
        exon2_4 = eukaryote.GenericLocus(start=55, end=72)
        exon2_5 = eukaryote.GenericLocus(start=73, end=74)
        transcript2 = eukaryote.TranscriptSpeciesType(
            gene=gene2, exons=[exon2_1, exon2_2, exon2_3, exon2_4, exon2_5])
        cds2_2 = eukaryote.GenericLocus(start=40, end=45)
        cds2_3 = eukaryote.GenericLocus(start=49, end=54)
        cds2_4 = eukaryote.GenericLocus(start=55, end=72)
        self.prot2 = eukaryote.ProteinSpeciesType(
            id='prot2',
            name='protein2',
            uniprot='P12345',
            cell=cell1,
            transcript=transcript2,
            coding_regions=[cds2_4, cds2_2, cds2_3])
    def test_serialize(self):

        tf1 = eukaryote.ProteinSpeciesType(id='tf1')
        tf_reg1 = eukaryote.TranscriptionFactorRegulation(
            transcription_factor=tf1,
            direction=eukaryote.RegulatoryDirection.repression)
        tf_reg2 = eukaryote.TranscriptionFactorRegulation(
            transcription_factor=tf1,
            direction=eukaryote.RegulatoryDirection.activation)

        self.assertEqual(tf_reg1.serialize(), 'tf1:repression')
        self.assertEqual(tf_reg2.serialize(), 'tf1:activation')
示例#8
0
    def test_get_empirical_formula(self):
        # Default translation table used is 1 (standard)
        self.assertEqual(self.prot1.get_empirical_formula(),
                         chem.EmpiricalFormula('C53H96N14O15S1'))
        self.assertEqual(self.prot2.get_empirical_formula(),
                         chem.EmpiricalFormula('C53H91N11O11S1'))

        # Test using input sequence
        test_prot = eukaryote.ProteinSpeciesType()
        self.assertEqual(test_prot.get_empirical_formula(seq_input=Bio.Seq.Seq('MKVLINKNEL')),
                         chem.EmpiricalFormula('C53H96N14O15S1'))
        self.assertEqual(test_prot.get_empirical_formula(seq_input=Bio.Seq.Seq('MKKFLLTPL')),
                         chem.EmpiricalFormula('C53H91N11O11S1'))
    def test_deserialize(self):

        tf1 = eukaryote.ProteinSpeciesType(id='tf1')

        objects = {
            eukaryote.ProteinSpeciesType: {
                'tf1': tf1,
            },
        }

        result = eukaryote.TranscriptionFactorRegulation.deserialize(
            'tf1:activation', objects)
        self.assertEqual(result[0].transcription_factor, tf1)
        self.assertEqual(result[0].direction,
                         eukaryote.RegulatoryDirection.activation)
        self.assertEqual(result[1], None)

        result = eukaryote.TranscriptionFactorRegulation.deserialize(
            'tf1:repression', objects)
        self.assertEqual(result[0].transcription_factor, tf1)
        self.assertEqual(result[0].direction,
                         eukaryote.RegulatoryDirection.repression)
        self.assertEqual(result[1], None)

        result = eukaryote.TranscriptionFactorRegulation.deserialize(
            'tf1:unknown', objects)
        self.assertEqual(result[0].transcription_factor, tf1)
        self.assertEqual(result[0].direction,
                         eukaryote.RegulatoryDirection.unknown)
        self.assertEqual(result[1], None)

        result = eukaryote.TranscriptionFactorRegulation.deserialize(
            'tf:activation', objects)
        self.assertEqual(result[0], None)

        result = eukaryote.TranscriptionFactorRegulation.deserialize(
            'tf1:1', objects)
        self.assertEqual(result[0], None)

        result = eukaryote.TranscriptionFactorRegulation.deserialize(
            'tf1:error', objects)
        self.assertEqual(result[0], None)

        result = eukaryote.TranscriptionFactorRegulation.deserialize(
            'tf1:3.6', objects)
        self.assertEqual(result[0], None)
示例#10
0
    def test_constructor(self):
        # defining modified protein name
        mp = eukaryote.ProteinSpeciesType(id='mp')

        # testing example of modification: one protein one modified site
        ptm1 = eukaryote.PtmSite(id='protptm1', name='ptm1', modified_protein=mp,
             type='phosphorylation', modified_residue='s145', fractional_abundance='0.5', comments='oneprot_onesite')

        self.assertEqual(ptm1.id, 'protptm1')
        self.assertEqual(ptm1.name, 'ptm1')
        self.assertEqual(ptm1.modified_protein, mp)
        self.assertEqual(ptm1.type, 'phosphorylation')
        self.assertEqual(ptm1.modified_residue, 's145')
        self.assertEqual(ptm1.fractional_abundance, '0.5')
        self.assertEqual(ptm1.comments, 'oneprot_onesite')
        self.assertEqual(ptm1.references, [])
        self.assertEqual(ptm1.identifiers, [])