예제 #1
0
  def test_0(self):

    m = topology.Molecule()
    self.assertEqual( m.size(), 0 )
    self.assertEqual( m.atoms, [] )
    self.assertEqual( m.atom_for, {} )
    self.assertEqual( m.descriptor_for, {} )
    self.assertEqual( list( m.graph.vertices() ), [] )
    self.assertEqual( list( m.graph.edges() ), [] )
예제 #2
0
  def test_asn_leu(self):

    l_ca = topology.Atom( label = "CA" )
    l_cb = topology.Atom( label = "C" )
    l_cg = topology.Atom( label = "C" )
    l_cd1 = topology.Atom( label = "C" )
    l_cd2 = topology.Atom( label = "C" )
    leu = topology.Molecule()
    leu.add( atom = l_ca, xyz = ( -1.0085, -0.590773,  0.814318 ) )
    leu.add( atom = l_cb, xyz = (  0.0275, -0.557773, -0.314682 ) )
    leu.add( atom = l_cg, xyz = (  1.2335,  0.374227, -0.138682 ) )
    leu.add( atom = l_cd1, xyz = (  2.3065,  0.046227, -1.16768  ) )
    leu.add( atom = l_cd2, xyz = (  0.8395,  1.84323,  -0.230682 ) )

    a_ca = topology.Atom( label = "CA" )
    a_cb = topology.Atom( label = "C" )
    a_cg = topology.Atom( label = "C" )
    a_od1 = topology.Atom( label = "C" )
    a_nd2 = topology.Atom( label = "C" )
    asn = topology.Molecule()
    asn.add( atom = a_ca, xyz = ( -1.03327, -0.544348,  0.860946 ) )
    asn.add( atom = a_cb,  xyz = (  0.10486, -0.548357, -0.164901 ) )
    asn.add( atom = a_cg,  xyz = (  0.990984, 0.682823, -0.070521 ) )
    asn.add( atom = a_od1, xyz = (  1.39496,  1.24684,  -1.08724  ) )
    asn.add( atom = a_nd2, xyz = (  1.29745,  1.10599,   1.15228  ) )

    m = topology.GreedyMatch(
      molecule1 = leu,
      molecule2 = asn,
      vertex_equality = lambda l, r: l.label == r.label,
      edge_equality = lambda l, r: abs( l - r ) <= 0.1,
      )
    self.assertEqual( m.count(), 1 )
    self.assertEqual( m.length(), 3 )
    mapping = m.remapped()[0]
    self.assertEqual( len( mapping ), 3 )
    self.assertTrue( ( l_ca, a_ca ) in mapping )
    self.assertTrue( ( l_cb, a_cb ) in mapping )
    self.assertTrue( ( l_cg, a_cg ) in mapping )
    self.assertTrue( ( l_cd1, a_od1 ) not in mapping )
예제 #3
0
  def test_1(self):

    m = topology.Molecule()
    a = topology.Atom()
    m.add( atom = a,  xyz = ( 0, 0, 0 ) )
    self.assertEqual( m.size(), 1 )
    self.assertEqual( m.atoms, [ a ] )
    self.assertEqual( len( m.atom_for ), 1 )
    self.assertTrue( a in m.atom_for.values() )
    self.assertEqual( len( m.descriptor_for ), 1 )
    self.assertTrue( a in m.descriptor_for )
    self.assertEqual( len( list( m.graph.vertices() ) ), 1 )
    self.assertEqual( list( m.graph.edges() ), [] )
예제 #4
0
  def test_2(self):

    m = topology.Molecule()
    a1 = topology.Atom()
    a2 = topology.Atom()
    m.add( atom = a1, xyz = ( 0, 0, 0 ) )
    m.add( atom = a2, xyz = ( 1, 1, 1 ) )
    self.assertEqual( m.size(), 2 )
    self.assertEqual( set( m.atoms ), set( [ a1, a2 ] ) )
    self.assertEqual( len( m.atom_for ), 2 )
    self.assertTrue( a1 in m.atom_for.values() )
    self.assertTrue( a2 in m.atom_for.values() )
    self.assertEqual( len( m.descriptor_for ), 2 )
    self.assertTrue( a1 in m.descriptor_for )
    self.assertTrue( a2 in m.descriptor_for )
    self.assertEqual( len( list( m.graph.vertices() ) ), 2 )
    self.assertEqual( len( list( m.graph.edges() ) ), 1 )
    edge = m.graph.edges().next()
    self.assertAlmostEqual( m.graph.edge_weight( edge = edge ), 1.73205, 5 )