Beispiel #1
0
    def test_incomplete_termini(self):
        monomer1 = protein.ProteinForm().from_str('{AA0062}')
        monomer2 = protein.ProteinForm().from_str('{AA0318}')

        dimer = protein.ProteinForm().from_str('{AA0062}{AA0318}')
        self.assertEqual(dimer.validate(), [])
        self.assertEqual(dimer.get_formula(),
                         monomer1.get_formula() + monomer2.get_formula() - EmpiricalFormula('OH3'))
        self.assertEqual(dimer.get_charge(),
                         monomer1.get_charge() + monomer2.get_charge() - 1)

        dimer = protein.ProteinForm().from_str('{AA0318}{AA0062}')
        self.assertNotEqual(dimer.validate(), [])
Beispiel #2
0
    def test_c_terminus_only(self):
        # AA0062
        form = protein.ProteinForm().from_str('{AA0062}')
        self.assertEqual(form.validate(), [])
        self.assertEqual(form.export('smiles'), form.seq[0].export('smiles'))
        self.assertEqual(form.get_formula(), form.seq[0].get_formula())
        self.assertEqual(form.get_charge(), form.seq[0].get_charge())

        form = protein.ProteinForm().from_str('A{AA0062}')
        self.assertNotEqual(form.validate(), [])

        form = protein.ProteinForm().from_str('{AA0062}A')
        self.assertEqual(form.validate(), [])
Beispiel #3
0
    def test_no_termini(self):
        # AA0344
        monomer = Monomer(structure='OC[C@H](N1SC[C@@H](C1=O)[NH3+])C=O')
        form = protein.ProteinForm()
        form.seq.append(monomer)
        self.assertEqual(form.validate(), [])
        self.assertEqual(form.export('smiles'), form.seq[0].export('smiles'))
        self.assertEqual(form.get_formula(), form.seq[0].get_formula())
        self.assertEqual(form.get_charge(), form.seq[0].get_charge())

        form = protein.ProteinForm()
        form.seq.append(monomer)
        form.seq.append(protein.protein_alphabet.monomers.A)
        self.assertNotEqual(form.validate(), [])

        form = protein.ProteinForm()
        form.seq.append(protein.protein_alphabet.monomers.A)
        form.seq.append(monomer)
        self.assertNotEqual(form.validate(), [])
Beispiel #4
0
    def test_ProteinForm_properties(self):
        monomers = protein.canonical_protein_alphabet.monomers

        form = protein.CanonicalProteinForm().from_str('A')
        self.assertEqual(form.get_formula(), EmpiricalFormula('C3H7NO2') + EmpiricalFormula('H'))
        self.assertEqual(form.get_charge(), 1)
        self.assertEqual(form.export('smiles'), ALA_smiles)

        form = protein.CanonicalProteinForm().from_str('AA')
        self.assertEqual(form.get_formula(), EmpiricalFormula('C6H12N2O3') + EmpiricalFormula('H'))
        self.assertEqual(form.get_charge(), 1)
        self.assertEqual(form.export('smiles'), di_ALA_smiles)

        form = protein.CanonicalProteinForm().from_str('AAA')
        self.assertEqual(form.get_formula(), EmpiricalFormula('C9H17N3O4') + EmpiricalFormula('H'))
        self.assertEqual(form.get_charge(), 1)
        self.assertEqual(form.export('smiles'), tri_ALA_smiles)

        form = protein.ProteinForm().from_str('AAA')
        self.assertEqual(form.get_formula(), EmpiricalFormula('C9H17N3O4') + EmpiricalFormula('H'))
        self.assertEqual(form.get_charge(), 1)
        self.assertEqual(form.export('smiles'), tri_ALA_smiles)
Beispiel #5
0
    def test_gen_genomic_viz(self):
        form = protein.ProteinForm().from_str(('ACR:GCRGAARGCH:ILCA{SEL}RC' *
                                               30) +
                                              (' | x-link: ['
                                               '   l-bond-atom: 2S11'
                                               ' | r-bond-atom: 5S11'
                                               ' | l-displaced-atom: 2H11'
                                               ' | r-displaced-atom: 5H11'
                                               ']'
                                               ' | x-link: ['
                                               '   l-bond-atom: 40S11'
                                               ' | r-bond-atom: 80S11'
                                               ' | l-displaced-atom: 40H11'
                                               ' | r-displaced-atom: 80H11'
                                               ']'
                                               ' | x-link: ['
                                               '   l-bond-atom: 60S11'
                                               ' | r-bond-atom: 100S11'
                                               ' | l-displaced-atom: 60H11'
                                               ' | r-displaced-atom: 100H11'
                                               ']'
                                               ' | x-link: ['
                                               '   l-bond-atom: 20S11'
                                               ' | r-bond-atom: 160S11'
                                               ' | l-displaced-atom: 20H11'
                                               ' | r-displaced-atom: 160H11'
                                               ']'
                                               ' | x-link: ['
                                               '   l-bond-atom: 140S11'
                                               ' | r-bond-atom: 220S11'
                                               ' | l-displaced-atom: 140H11'
                                               ' | r-displaced-atom: 220H11'
                                               ']'))
        seq_features = [{
            'label': 'Processed',
            'color': '#cccccc',
            'positions': {
                0: [[1, 30], [50, 85]]
            },
        }]

        svg = util.gen_genomic_viz(
            [form, form, form, form],
            inter_crosslinks=[
                mock.Mock(
                    get_l_bond_atoms=lambda:
                    [mock.Mock(subunit='0', monomer=100)],
                    get_r_bond_atoms=lambda:
                    [mock.Mock(subunit='3', monomer=150)],
                ),
                mock.Mock(
                    get_l_bond_atoms=lambda:
                    [mock.Mock(subunit='2', monomer=150)],
                    get_r_bond_atoms=lambda:
                    [mock.Mock(subunit='1', monomer=50)],
                    comments='Disulfide',
                ),
            ],
            polymer_labels={
                0: 'Title 1',
                1: 'Title 2',
                2: 'Title 3',
                3: 'Title 4',
            },
            seq_features=seq_features,
            width=1200,
            nt_per_track=80,
            cols=2)
        self.assertIsInstance(svg, str)
Beispiel #6
0
 def test_ProteinForm_init(self):
     protein.ProteinForm()
     protein.CanonicalProteinForm()
Beispiel #7
0
 def test_validate_form(self):
     form = protein.ProteinForm()
     form.from_str('ARG')
     self.assertEqual(form.validate(), [])
Beispiel #8
0
    def test_validate_bonds(self):
        validate_bpform_bonds(protein.CanonicalProteinForm)
        validate_bpform_bonds(protein.ProteinForm)

        self.validate_alphabet(protein.CanonicalProteinForm().alphabet)
        self.validate_alphabet(protein.ProteinForm().alphabet)
Beispiel #9
0
 def test_get_structure(self):
     form = protein.ProteinForm().from_str('ARCGY' * 100)
     structure, _ = form.get_structure()
     self.assertIsInstance(structure, openbabel.OBMol)
     cml = OpenBabelUtils.export(structure, 'cml')
     self.assertTrue(cml.startswith('<molecule'))