Example #1
0
 def test_assembly(self):
     """Test Assembly class"""
     e1 = ihm.Entity('AHCD')
     e2 = ihm.Entity('AHC')
     a = ihm.Assembly([e1, e2], name='foo', description='bar')
     self.assertEqual(a.name, 'foo')
     self.assertEqual(a.description, 'bar')
Example #2
0
    def test_all_entity_ranges(self):
        """Test _all_entity_ranges() method"""
        class MockObject(object):
            pass

        s = ihm.System()
        e1 = ihm.Entity('AHCD', description='foo')
        a1 = ihm.AsymUnit(e1)
        s.entities.append(e1)
        s.asym_units.append(a1)
        e1rng = e1(1, 3)
        a1rng = a1(1, 2)

        sm1 = MockObject()
        sm1.asym_unit = e1rng
        s.orphan_starting_models.append(sm1)

        rep = ihm.representation.Representation()
        seg1 = ihm.representation.Segment()
        seg1.starting_model = None
        seg1.asym_unit = a1
        rep.append(seg1)
        s.orphan_representations.append(rep)

        asmb1 = ihm.Assembly([e1, a1])
        s.orphan_assemblies.append(asmb1)

        ensemble = MockObject()
        density = MockObject()
        density.asym_unit = a1rng
        ensemble.densities = [density]
        s.ensembles.append(ensemble)

        # duplicates should not be filtered
        self.assertEqual(list(s._all_entity_ranges()),
                         [e1rng, a1, e1, a1, a1rng])
Example #3
0
system.entities.extend((entityA, entityB))

# Next, we define asymmetric units for everything we modeled.
# These roughly correspond to chains in a traditional PDB file. Multiple
# asymmetric units may map to the same entity (for example if there are
# several copies of a given protein). Parts of the system that were seen in
# an experiment but were not modeled are represented as entities to which no
# asymmetric units map.
asymA = ihm.AsymUnit(entityA, details='Subunit A')
asymB = ihm.AsymUnit(entityB, details='Subunit B')
system.asym_units.extend((asymA, asymB))

# Next, we group asymmetric units (and/or entities) into assemblies.
# Here, we'll define an assembly of everything that we modeled, plus
# two subassemblies (of the subunits) that the SAXS data applies to:
modeled_assembly = ihm.Assembly((asymA, asymB), name='Modeled assembly')
assemblyA = ihm.Assembly((asymA, ), name='Subunit A')
assemblyB = ihm.Assembly((asymB, ), name='Subunit B')

# Define how the system was represented. Multiple representations of the
# system are possible, and can overlap. Here we'll say we represent A
# atomically as a rigid body and B as 3 flexible coarse-grained spheres:
rep = ihm.representation.Representation([
    ihm.representation.AtomicSegment(asymA, rigid=True),
    ihm.representation.FeatureSegment(asymB,
                                      rigid=False,
                                      primitive='sphere',
                                      count=3)
])

# Set up restraints on the system. First, two on the subunits that use
Example #4
0
# 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')
asym_h2o = ihm.AsymUnit(entity_h2o, details='Crystal waters')
system.asym_units.extend((asym_protein, asym_rna, asym_dna, asym_heme1,
                          asym_heme2, asym_h2o))

# todo: show handling of multiple waters

# Just as in the simple-docking.py example, we can add models with coordinates.
# Here we define an atomic model containing just the two hemes and the water.
assembly = ihm.Assembly((asym_heme1, asym_heme2, asym_h2o),
                        name="Modeled assembly")
rep = ihm.representation.Representation(
    [ihm.representation.AtomicSegment(asym_heme1, rigid=False),
     ihm.representation.AtomicSegment(asym_heme2, rigid=False),
     ihm.representation.AtomicSegment(asym_h2o, rigid=False)])
protocol = ihm.protocol.Protocol(name='Modeling')


class MyModel(ihm.model.Model):
    def get_atoms(self):
        # seq_id only makes sense for polymers; for ligands it should be None
        yield ihm.model.Atom(asym_unit=asym_heme1, type_symbol='FE', het=True,
                             seq_id=None, atom_id='FE', x=0., y=0., z=0.)
        yield ihm.model.Atom(asym_unit=asym_heme2, type_symbol='FE', het=True,
                             seq_id=None, atom_id='FE', x=10., y=10., z=10.)
        yield ihm.model.Atom(asym_unit=asym_h2o, type_symbol='O', het=True,