Ejemplo n.º 1
0
def make_polyglycine( chain_lengths, no_reserve=True):
    from pyxmolpp2.polymer import Frame
    from pyxmolpp2.polymer import ChainName
    from pyxmolpp2.polymer import AtomName
    from pyxmolpp2.polymer import ResidueName, ResidueId
    from pyxmolpp2.geometry import XYZ

    aid=1
    rid=1
    frame = Frame(0)
    for chainId, N in chain_lengths:
        if no_reserve:
            c = frame.emplace(ChainName(chainId))
        else:
            c = frame.emplace(ChainName(chainId),N)
        for i in range(N):
            if no_reserve:
                r = c.emplace(ResidueName("GLY"),ResidueId(rid))
            else:
                r = c.emplace(ResidueName("GLY"),ResidueId(rid),7)

            rid+=1
            for aname in ["N","H","CA","HA2","HA3","C","O"]:
                r.emplace(AtomName(aname),aid,XYZ(1,2,3))
                aid+=1

    return frame
Ejemplo n.º 2
0
def test_Residue_setters():
    from pyxmolpp2.polymer import ResidueName, ResidueId
    frame = make_polyglycine([("A", 1)])
    r = frame.asResidues[0]

    r.name = ResidueName("X")
    assert r.name == ResidueName("X")

    r.rName = ResidueName("Y")
    assert r.rName == ResidueName("Y")

    r.id = ResidueId(5)
    assert r.id == ResidueId(5)

    r.rId = ResidueId(7)
    assert r.rId == ResidueId(7)
Ejemplo n.º 3
0
def test_lookup_by_name():
    from pyxmolpp2.polymer import ChainName, ResidueId, AtomName, \
        OutOfRangeResidue, OutOfRangeFrame, OutOfRangeChain
    frame = make_polyglycine([("A",2)])

    frame[ChainName("A")]  # does not throw
    frame[ChainName("A")][ResidueId(2)] # does not throw
    frame[ChainName("A")][ResidueId(2)][AtomName("CA")] # does not throw
    frame[ChainName("A")][ResidueId(2)][AtomName("N")] # does not throw

    with pytest.raises(OutOfRangeFrame):
        frame[ChainName("B")] # does throw

    with pytest.raises(OutOfRangeChain):
        frame[ChainName("A")][ResidueId(3)] # does throw

    with pytest.raises(OutOfRangeResidue):
        frame[ChainName("A")][ResidueId(2)][AtomName("CX")] # does not throw
Ejemplo n.º 4
0
def test_residue_id():
    from pyxmolpp2.polymer import rId, ResidueId, ResidueInsertionCode
    frame = make_polyglycine([("A", 10)])

    assert frame.asAtoms.filter(rId == 5).size == 1 * 7
    assert frame.asAtoms.filter(rId.is_in({1, 2, 3})).size == 3 * 7
    assert frame.asAtoms.filter(~rId.is_in({1, 2, 3})).size == 7 * 7
    assert frame.asAtoms.filter((rId == 2) | (rId == 3)).size == 2 * 7

    assert frame.asResidues.filter(rId == 5).size == 1
    assert frame.asResidues.filter(rId.is_in({1, 2, 3})).size == 3
    assert frame.asResidues.filter(~rId.is_in({1, 2, 3})).size == 7
    assert frame.asResidues.filter((rId == 2) | (rId == 3)).size == 2

    assert frame.asResidues.filter(
        rId == ResidueId(5, ResidueInsertionCode("A"))).size == 0
Ejemplo n.º 5
0
def test_lookup_after_rename():
    from pyxmolpp2.polymer import ChainName, ResidueId, AtomName, \
        OutOfRangeResidue, OutOfRangeFrame, OutOfRangeChain
    frame = make_polyglycine([("A",2)])

    frame[ChainName("A")]  # does not throw
    frame[ChainName("A")][ResidueId(2)] # does not throw
    frame[ChainName("A")][ResidueId(2)][AtomName("CA")] # does not throw

    frame[ChainName("A")][ResidueId(2)][AtomName("CA")].name = AtomName("CX")
    frame[ChainName("A")][ResidueId(2)].id = ResidueId(99)
    frame[ChainName("A")].name = ChainName("X")

    frame[ChainName("X")]  # does not throw
    frame[ChainName("X")][ResidueId(99)] # does not throw
    frame[ChainName("X")][ResidueId(99)][AtomName("CX")] # does not throw
Ejemplo n.º 6
0
def test_Frame():
    from pyxmolpp2.polymer import Frame
    from pyxmolpp2.polymer import ChainName
    from pyxmolpp2.polymer import AtomName
    from pyxmolpp2.polymer import ResidueName, ResidueId
    from pyxmolpp2.geometry import XYZ

    f = Frame(5)
    c = f.emplace(ChainName("A"), 1)
    r = c.emplace(ResidueName("LYS"), ResidueId(1))
    a = r.emplace(AtomName("CA"), 1, XYZ(1,2,3))

    assert a.residue == r
    assert a.chain == c
    assert a.frame == f

    assert r.asAtoms[0] == a
    assert c.asAtoms[0] == a
    assert f.asAtoms[0] == a

    assert r.asAtoms.asResidues[0] == r
    assert c.asAtoms.asResidues[0] == r
    assert f.asAtoms.asResidues[0] == r

    assert r.asAtoms.asResidues.asChains[0] == c
    assert c.asAtoms.asResidues.asChains[0] == c
    assert f.asAtoms.asResidues.asChains[0] == c


    assert r.chain == c
    assert r.frame == f

    assert c.frame == f

    assert c.asResidues[0] == r
    assert f.asResidues[0] == r

    assert f.asChains[0] == c