コード例 #1
0
 def test_non_polymer_chem_comp(self):
     """Test NonPolymerChemComp class"""
     cc1 = ihm.NonPolymerChemComp('HEM')
     self.assertEqual(cc1.type, 'non-polymer')
     self.assertEqual(cc1.code_canonical, 'X')
     cc2 = ihm.NonPolymerChemComp('HEM', code_canonical='G')
     self.assertEqual(cc2.code_canonical, 'G')
コード例 #2
0
 def test_entity_weight(self):
     """Test Entity.formula_weight"""
     e1 = ihm.Entity('AHCD')
     self.assertAlmostEqual(e1.formula_weight, 499.516, places=1)
     # Entity containing a component with unknown weight
     heme = ihm.Entity([ihm.NonPolymerChemComp('HEM')])
     self.assertIsNone(heme.formula_weight)
コード例 #3
0
    def test_entity_type(self):
        """Test Entity.type"""
        protein = ihm.Entity('AHCD')
        heme = ihm.Entity([ihm.NonPolymerChemComp('HEM')])
        water = ihm.Entity([ihm.WaterChemComp()])
        self.assertEqual(protein.type, 'polymer')
        self.assertTrue(protein.is_polymeric())
        self.assertEqual(heme.type, 'non-polymer')
        self.assertFalse(heme.is_polymeric())
        self.assertEqual(water.type, 'water')
        self.assertFalse(water.is_polymeric())

        # A single amino acid should be classified non-polymer
        single_aa = ihm.Entity('A')
        self.assertEqual(single_aa.type, 'non-polymer')
        self.assertFalse(single_aa.is_polymeric())

        # ... unless forced polymer
        single_aa._force_polymer = True
        self.assertEqual(single_aa.type, 'polymer')
        self.assertTrue(single_aa.is_polymeric())

        # An entity with no sequence is a polymer
        empty = ihm.Entity([])
        self.assertEqual(empty.type, 'polymer')
        self.assertTrue(empty.is_polymeric())
コード例 #4
0
 def test_entity_type(self):
     """Test Entity.type"""
     protein = ihm.Entity('AHCD')
     heme = ihm.Entity([ihm.NonPolymerChemComp('HEM')])
     water = ihm.Entity([ihm.WaterChemComp()])
     self.assertEqual(protein.type, 'polymer')
     self.assertTrue(protein.is_polymeric())
     self.assertEqual(heme.type, 'non-polymer')
     self.assertFalse(heme.is_polymeric())
     self.assertEqual(water.type, 'water')
     self.assertFalse(water.is_polymeric())
コード例 #5
0
 def test_entity(self):
     """Test Entity class"""
     e1 = ihm.Entity('AHCD', description='foo')
     # Should compare identical if sequences are the same
     e2 = ihm.Entity('AHCD', description='bar')
     e3 = ihm.Entity('AHCDE', description='foo')
     heme = ihm.Entity([ihm.NonPolymerChemComp('HEM')])
     self.assertEqual(e1, e2)
     self.assertNotEqual(e1, e3)
     self.assertEqual(e1.seq_id_range, (1, 4))
     self.assertEqual(e3.seq_id_range, (1, 5))
     # seq_id does not exist for nonpolymers
     self.assertEqual(heme.seq_id_range, (None, None))
コード例 #6
0
 def test_entity_range(self):
     """Test EntityRange class"""
     e = ihm.Entity('AHCDAH')
     heme = ihm.Entity([ihm.NonPolymerChemComp('HEM')])
     e._id = 42
     self.assertEqual(e.seq_id_range, (1, 6))
     r = e(3, 4)
     self.assertEqual(r.seq_id_range, (3, 4))
     self.assertEqual(r._id, 42)
     # Cannot create ranges for nonpolymeric entities
     self.assertRaises(TypeError, heme.__call__, 1, 1)
     samer = e(3, 4)
     otherr = e(2, 4)
     self.assertEqual(r, samer)
     self.assertEqual(hash(r), hash(samer))
     self.assertNotEqual(r, otherr)
     self.assertNotEqual(r, e)  # entity_range != entity
コード例 #7
0
 def test_asym_range(self):
     """Test AsymUnitRange class"""
     e = ihm.Entity('AHCDAH')
     heme = ihm.Entity([ihm.NonPolymerChemComp('HEM')])
     a = ihm.AsymUnit(e)
     aheme = ihm.AsymUnit(heme)
     a._id = 42
     self.assertEqual(a.seq_id_range, (1, 6))
     # seq_id is not defined for nonpolymers
     self.assertEqual(aheme.seq_id_range, (None, None))
     r = a(3, 4)
     self.assertEqual(r.seq_id_range, (3, 4))
     self.assertEqual(r._id, 42)
     self.assertEqual(r.entity, e)
     # Cannot create ranges for nonpolymeric entities
     self.assertRaises(TypeError, aheme.__call__, 1, 1)
     samer = a(3, 4)
     otherr = a(2, 4)
     self.assertEqual(r, samer)
     self.assertEqual(hash(r), hash(samer))
     self.assertNotEqual(r, otherr)
     self.assertNotEqual(r, a)  # asym_range != asym
     self.assertNotEqual(r, e(3, 4))  # asym_range != entity_range
     self.assertNotEqual(r, e)  # asym_range != entity
コード例 #8
0
 def test_non_polymer_chem_comp(self):
     """Test NonPolymerChemComp class"""
     cc1 = ihm.NonPolymerChemComp('HEM')
     self.assertEqual(cc1.type, 'non-polymer')
コード例 #9
0
ファイル: ligands_water.py プロジェクト: CAHanke/python-ihm
# An entity corresponding to an RNA sequence
entity_rna = ihm.Entity('ACG',
                        alphabet=ihm.RNAAlphabet,
                        description='RNA chain')

# An entity corresponding to a DNA sequence
entity_dna = ihm.Entity(['DA', 'DC', 'DG'],
                        alphabet=ihm.DNAAlphabet,
                        description='DNA chain')

# Non-polymers such as ligands or water should each live in their own Entity:

# A ligand entity (in this case, heme)
heme = ihm.NonPolymerChemComp("HEM",
                              name='PROTOPORPHYRIN IX CONTAINING FE',
                              formula='C34 H32 Fe N4 O4')
entity_heme = ihm.Entity([heme], description='Heme')

# Water
entity_h2o = ihm.Entity([ihm.WaterChemComp()], description='Water')

system.entities.extend(
    (entity_protein, entity_rna, entity_dna, entity_heme, entity_h2o))

# Next, we define asymmetric units for everything we modeled.
# Here, we have a single instance of each protein, RNA and DNA, two hemes,
# plus crystal waters
asym_protein = ihm.AsymUnit(entity_protein, details='Subunit A')
asym_rna = ihm.AsymUnit(entity_rna, details='RNA chain')
asym_dna = ihm.AsymUnit(entity_dna, details='DNA chain')
コード例 #10
0
system = ihm.System()

# An entity corresponding to an amino acid (polyalanine) sequence
entity_protein = ihm.Entity('AAA', description='Subunit A')

# An entity corresponding to an RNA sequence
entity_rna = ihm.Entity('ACG', alphabet=ihm.RNAAlphabet,
                        description='RNA chain')

# An entity corresponding to a DNA sequence
entity_dna = ihm.Entity(['DA', 'DC', 'DG'], alphabet=ihm.DNAAlphabet,
                        description='DNA chain')

# A ligand entity (in this case, heme)
entity_heme = ihm.Entity([ihm.NonPolymerChemComp("HEM")], description='Heme')

# Water
entity_h2o = ihm.Entity([ihm.WaterChemComp()], description='Water')

system.entities.extend((entity_protein, entity_rna, entity_dna, entity_heme,
                        entity_h2o))

# Next, we define asymmetric units for everything we modeled.
# Here, we have a single instance of each protein, RNA and DNA, two hemes,
# plus crystal waters
asym_protein = ihm.AsymUnit(entity_protein, details='Subunit A')
asym_rna = ihm.AsymUnit(entity_rna, details='RNA chain')
asym_dna = ihm.AsymUnit(entity_dna, details='DNA chain')
asym_heme1 = ihm.AsymUnit(entity_heme, details='First heme')
asym_heme2 = ihm.AsymUnit(entity_heme, details='Second heme')