Skip to content
Snippets Groups Projects
Commit e4709d79 authored by B13nch3n's avatar B13nch3n
Browse files

SCHWED-4896: Add IsOligosaccharide function with documentation and unit tests

parent 8a47dff6
Branches
Tags
No related merge requests found
......@@ -343,49 +343,37 @@ The Handle Classes
A chain of one or more :class:`residues <ResidueHandle>`. Chains are always
part of an entity.
.. attribute:: name
The chain name. The name uniquely identifies the chain in the entity. In
most cases, the chain name is one character. This is restriction of the PDB
file format. However, you are free to use longer names as long as you don't
want to save them as PDB files
This property is read-only. To change the name, use an :class:`XCSEditor`.
Also available as :meth:`GetName`
.. attribute:: atoms
:type: str
Get list of all atoms of this chain. To access a single atom, use
:meth:`FindAtom`.
.. attribute:: type
This property is read-only. Also available as :meth:`GetAtomList`
Describes the type of the chain.
:type: :class:`AtomHandleList` (list of :class:`AtomHandle`)
:type: :class:`ChainType`.
.. attribute:: bounds
.. attribute:: description
Axis-aligned bounding box of the chain. Read-only
Details about the chain. Not categorised, just text.
:type: :class:`ost.geom.AlignedCuboid`
.. attribute:: residues
.. attribute:: center_of_atoms
List of all residues of this chain. The residues are sorted from N- to
C-terminus. Usually the residue numbers are in ascending order
(see :attr:`in_sequence`).
Center of atoms (not mass weighted). Also available as
:meth:`GetCenterOfAtoms`.
This property is read-only.
:type: :class:`~ost.geom.Vec3`
**Example usage:**
.. attribute:: center_of_mass
.. code-block:: python
Center of mass. Also available as :meth:`GetCenterOfMass`
chain=ent.FindChain("A")
for res in chain.residues:
print(res.name, res.atom_count)
:type: :class:`~ost.geom.Vec3`
Also available as :meth:`GetResidueList`. To access a single residue, use
:meth:`FindResidue`.
.. attribute:: description
:type: :class:`ResidueHandleList` (list of :class:`ResidueHandle`)
Details about the chain. Not categorised, just text.
.. attribute:: in_sequence
......@@ -401,26 +389,40 @@ The Handle Classes
print(chain.residues) # [B.GLY1, B.GLY4, B.GLY3]
print(chain.in_sequence) # prints false
.. attribute:: residue_count
.. attribute:: is_oligosaccharide
Number of residues. Read-only. See :meth:`GetResidueCount`.
Indicates if the chain is an oligosaccharide, a branched, non-linear entity
of multiple sugars. Also available as :meth:`IsOligosaccharide`.
:type: :class:`int`
:type: :class:`bool`
.. attribute:: atoms
.. attribute:: is_polymer
Get list of all atoms of this chain. To access a single atom, use
:meth:`FindAtom`.
Indicates if a chain is a polymer. True for polypeptides, polynucleotides,
polysaccharides, oligosaccharides and branched chains. Also available as
:meth:`IsPolymer`.
This property is read-only. Also available as :meth:`GetAtomList`
:type: :class:`bool`
:type: :class:`AtomHandleList` (list of :class:`AtomHandle`)
.. attribute:: is_polynucleotide
.. attribute:: bounds
Indicates if a chain is a nucleic acid. Also available as
:meth:`IsPolynucleotide`.
Axis-aligned bounding box of the chain. Read-only
:type: :class:`bool`
:type: :class:`ost.geom.AlignedCuboid`
.. attribute:: is_polypeptide
Indicates if a chain is a protein. Also available as :meth:`IsPolypeptide`.
:type: :class:`bool`
.. attribute:: is_polysaccharide
Indicates if a chain is a polysaccharide. Also available as
:meth:`IsPolysaccharide()`.
:type: :class:`bool`
.. attribute:: mass
......@@ -428,18 +430,51 @@ The Handle Classes
:type: float
.. attribute:: center_of_mass
.. attribute:: name
Center of mass. Also available as :meth:`GetCenterOfMass`
The chain name. The name uniquely identifies the chain in the entity. In
most cases, the chain name is one character. This is restriction of the PDB
file format. However, you are free to use longer names as long as you don't
want to save them as PDB files
:type: :class:`~ost.geom.Vec3`
This property is read-only. To change the name, use an :class:`XCSEditor`.
.. attribute:: center_of_atoms
Also available as :meth:`GetName`
Center of atoms (not mass weighted). Also available as
:meth:`GetCenterOfAtoms`.
:type: str
:type: :class:`~ost.geom.Vec3`
.. attribute:: residue_count
Number of residues. Read-only. See :meth:`GetResidueCount`.
:type: :class:`int`
.. attribute:: residues
List of all residues of this chain. The residues are sorted from N- to
C-terminus. Usually the residue numbers are in ascending order
(see :attr:`in_sequence`).
This property is read-only.
**Example usage:**
.. code-block:: python
chain=ent.FindChain("A")
for res in chain.residues:
print(res.name, res.atom_count)
Also available as :meth:`GetResidueList`. To access a single residue, use
:meth:`FindResidue`.
:type: :class:`ResidueHandleList` (list of :class:`ResidueHandle`)
.. attribute:: type
Describes the type of the chain.
:type: :class:`ChainType`.
.. attribute:: valid
......@@ -491,6 +526,26 @@ The Handle Classes
See :attr:`type`
.. method:: IsOligosaccharide()
See :attr:`is_oligosaccharide`
.. method:: IsPolymer()
See :attr:`is_polymer`
.. method:: IsPolynucleotide()
See :attr:`is_polynucleotide`
.. method:: IsPolypeptide()
See :attr:`is_polypeptide`
.. method:: IsPolysaccharide()
See :attr:`is_polysaccharide`
.. method:: GetDescription()
See :attr:`description`
......
......@@ -58,10 +58,12 @@ void export_Chain()
.def("IsPolypeptide", &ChainBase::IsPolypeptide)
.def("IsPolynucleotide", &ChainBase::IsPolynucleotide)
.def("IsPolysaccharide", &ChainBase::IsPolysaccharide)
.def("IsOligosaccharide", &ChainBase::IsOligosaccharide)
.def("IsPolymer", &ChainBase::IsPolymer)
.add_property("is_polypeptide", &ChainBase::IsPolypeptide)
.add_property("is_polynucleotide", &ChainBase::IsPolynucleotide)
.add_property("is_polysaccharide", &ChainBase::IsPolysaccharide)
.add_property("is_oligosaccharide", &ChainBase::IsOligosaccharide)
.add_property("is_polymer", &ChainBase::IsPolymer)
.add_property("type", &ChainBase::GetType)
.add_property("description", &ChainBase::GetDescription)
......
......@@ -81,6 +81,13 @@ bool ChainBase::IsPolysaccharide() const
}
bool ChainBase::IsOligosaccharide() const
{
this->CheckValidity();
return impl_->IsOligosaccharide();
}
bool ChainBase::IsPolypeptide() const
{
this->CheckValidity();
......
......@@ -83,6 +83,9 @@ public:
/// \brief whether the chain is a polysaccharide
bool IsPolysaccharide() const;
/// \brief whether the chain is an oligsaccharide (branched mmCIF entity)
bool IsOligosaccharide() const;
/// \brief whether the chain is a polypeptide
bool IsPolypeptide() const;
......
......@@ -69,14 +69,20 @@ public:
{
return type_==CHAINTYPE_POLY || this->IsPolypeptide() ||
this->IsPolynucleotide() || this->IsPolysaccharide() ||
type_==CHAINTYPE_POLY_PEPTIDE_DN_RN ||
type_==CHAINTYPE_OLIGOSACCHARIDE;
this->IsOligosaccharide() ||
type_==CHAINTYPE_POLY_PEPTIDE_DN_RN || type_==CHAINTYPE_BRANCHED;
}
/// \brief whether the chain is a polysaccharide
bool IsPolysaccharide() const
{
return type_==CHAINTYPE_POLY_SAC_D || type_==CHAINTYPE_POLY_SAC_L;
}
/// \brief whether the chain is a polysaccharide
bool IsOligosaccharide() const
{
return type_==CHAINTYPE_OLIGOSACCHARIDE;
}
/// \brief whether the chain is a polypeptide
bool IsPolypeptide() const
{
......
......@@ -235,59 +235,69 @@ BOOST_AUTO_TEST_CASE(chain_type)
BOOST_CHECK(ch1.GetType() == CHAINTYPE_UNKNOWN);
BOOST_CHECK(!ch1.IsPolymer());
BOOST_CHECK(!ch1.IsPolysaccharide());
BOOST_CHECK(!ch1.IsOligosaccharide());
BOOST_CHECK(!ch1.IsPolypeptide());
BOOST_CHECK(!ch1.IsPolynucleotide());
e.SetChainType(ch1, CHAINTYPE_POLY);
BOOST_CHECK(ch1.GetType() == CHAINTYPE_POLY);
BOOST_CHECK(ch1.IsPolymer());
BOOST_CHECK(!ch1.IsPolysaccharide());
BOOST_CHECK(!ch1.IsOligosaccharide());
BOOST_CHECK(!ch1.IsPolypeptide());
BOOST_CHECK(!ch1.IsPolynucleotide());
e.SetChainType(ch1, CHAINTYPE_NON_POLY);
BOOST_CHECK(ch1.GetType() == CHAINTYPE_NON_POLY);
BOOST_CHECK(!ch1.IsPolymer());
BOOST_CHECK(!ch1.IsPolysaccharide());
BOOST_CHECK(!ch1.IsOligosaccharide());
BOOST_CHECK(!ch1.IsPolypeptide());
BOOST_CHECK(!ch1.IsPolynucleotide());
e.SetChainType(ch1, CHAINTYPE_WATER);
BOOST_CHECK(ch1.GetType() == CHAINTYPE_WATER);
BOOST_CHECK(!ch1.IsPolymer());
BOOST_CHECK(!ch1.IsPolysaccharide());
BOOST_CHECK(!ch1.IsOligosaccharide());
BOOST_CHECK(!ch1.IsPolypeptide());
BOOST_CHECK(!ch1.IsPolynucleotide());
e.SetChainType(ch1, CHAINTYPE_POLY_PEPTIDE_D);
BOOST_CHECK(ch1.IsPolymer());
BOOST_CHECK(!ch1.IsPolysaccharide());
BOOST_CHECK(!ch1.IsOligosaccharide());
BOOST_CHECK(ch1.IsPolypeptide());
BOOST_CHECK(!ch1.IsPolynucleotide());
BOOST_CHECK(ch1.GetType() == CHAINTYPE_POLY_PEPTIDE_D);
e.SetChainType(ch1, CHAINTYPE_POLY_PEPTIDE_L);
BOOST_CHECK(ch1.IsPolymer());
BOOST_CHECK(!ch1.IsPolysaccharide());
BOOST_CHECK(!ch1.IsOligosaccharide());
BOOST_CHECK(ch1.IsPolypeptide());
BOOST_CHECK(!ch1.IsPolynucleotide());
BOOST_CHECK(ch1.GetType() == CHAINTYPE_POLY_PEPTIDE_L);
e.SetChainType(ch1, CHAINTYPE_POLY_DN);
BOOST_CHECK(ch1.IsPolymer());
BOOST_CHECK(!ch1.IsPolysaccharide());
BOOST_CHECK(!ch1.IsOligosaccharide());
BOOST_CHECK(!ch1.IsPolypeptide());
BOOST_CHECK(ch1.IsPolynucleotide());
BOOST_CHECK(ch1.GetType() == CHAINTYPE_POLY_DN);
e.SetChainType(ch1, CHAINTYPE_POLY_RN);
BOOST_CHECK(ch1.IsPolymer());
BOOST_CHECK(!ch1.IsPolysaccharide());
BOOST_CHECK(!ch1.IsOligosaccharide());
BOOST_CHECK(!ch1.IsPolypeptide());
BOOST_CHECK(ch1.IsPolynucleotide());
BOOST_CHECK(ch1.GetType() == CHAINTYPE_POLY_RN);
e.SetChainType(ch1, CHAINTYPE_POLY_SAC_D);
BOOST_CHECK(ch1.IsPolymer());
BOOST_CHECK(ch1.IsPolysaccharide());
BOOST_CHECK(!ch1.IsOligosaccharide());
BOOST_CHECK(!ch1.IsPolypeptide());
BOOST_CHECK(!ch1.IsPolynucleotide());
BOOST_CHECK(ch1.GetType() == CHAINTYPE_POLY_SAC_D);
e.SetChainType(ch1, CHAINTYPE_POLY_SAC_L);
BOOST_CHECK(ch1.IsPolymer());
BOOST_CHECK(ch1.IsPolysaccharide());
BOOST_CHECK(!ch1.IsOligosaccharide());
BOOST_CHECK(!ch1.IsPolypeptide());
BOOST_CHECK(!ch1.IsPolynucleotide());
BOOST_CHECK(ch1.GetType() == CHAINTYPE_POLY_SAC_L);
......@@ -295,6 +305,7 @@ BOOST_AUTO_TEST_CASE(chain_type)
BOOST_CHECK(ch1.GetType() == CHAINTYPE_POLY_DN_RN);
BOOST_CHECK(ch1.IsPolymer());
BOOST_CHECK(!ch1.IsPolysaccharide());
BOOST_CHECK(!ch1.IsOligosaccharide());
BOOST_CHECK(!ch1.IsPolypeptide());
BOOST_CHECK(ch1.IsPolynucleotide());
e.SetChainType(ch1, CHAINTYPE_N_CHAINTYPES);
......@@ -305,30 +316,35 @@ BOOST_AUTO_TEST_CASE(chain_type)
BOOST_CHECK(ch1.GetType() == CHAINTYPE_MACROLIDE);
BOOST_CHECK(!ch1.IsPolymer());
BOOST_CHECK(!ch1.IsPolysaccharide());
BOOST_CHECK(!ch1.IsOligosaccharide());
BOOST_CHECK(!ch1.IsPolypeptide());
BOOST_CHECK(!ch1.IsPolynucleotide());
e.SetChainType(ch1, CHAINTYPE_CYCLIC_PSEUDO_PEPTIDE);
BOOST_CHECK(ch1.GetType() == CHAINTYPE_CYCLIC_PSEUDO_PEPTIDE);
BOOST_CHECK(ch1.IsPolymer());
BOOST_CHECK(!ch1.IsPolysaccharide());
BOOST_CHECK(!ch1.IsOligosaccharide());
BOOST_CHECK(ch1.IsPolypeptide());
BOOST_CHECK(!ch1.IsPolynucleotide());
e.SetChainType(ch1, CHAINTYPE_POLY_PEPTIDE_DN_RN);
BOOST_CHECK(ch1.GetType() == CHAINTYPE_POLY_PEPTIDE_DN_RN);
BOOST_CHECK(ch1.IsPolymer());
BOOST_CHECK(!ch1.IsPolysaccharide());
BOOST_CHECK(!ch1.IsOligosaccharide());
BOOST_CHECK(!ch1.IsPolypeptide());
BOOST_CHECK(!ch1.IsPolynucleotide());
e.SetChainType(ch1, CHAINTYPE_BRANCHED);
BOOST_CHECK(ch1.GetType() == CHAINTYPE_BRANCHED);
BOOST_CHECK(!ch1.IsPolymer());
BOOST_CHECK(ch1.IsPolymer());
BOOST_CHECK(!ch1.IsPolysaccharide());
BOOST_CHECK(!ch1.IsOligosaccharide());
BOOST_CHECK(!ch1.IsPolypeptide());
BOOST_CHECK(!ch1.IsPolynucleotide());
e.SetChainType(ch1, CHAINTYPE_OLIGOSACCHARIDE);
BOOST_CHECK(ch1.GetType() == CHAINTYPE_OLIGOSACCHARIDE);
BOOST_CHECK(ch1.IsPolymer());
BOOST_CHECK(!ch1.IsPolysaccharide());
BOOST_CHECK(ch1.IsOligosaccharide());
BOOST_CHECK(!ch1.IsPolypeptide());
BOOST_CHECK(!ch1.IsPolynucleotide());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment