Skip to content
Snippets Groups Projects
Commit 4514c413 authored by marco's avatar marco
Browse files

add JOIN_SPREAD_ATOM_RECORDS flag to PDBReader

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@1916 5a81b35b-ba03-0410-adc8-b2c5c5119f08
parent 422e7cb2
Branches
Tags
No related merge requests found
......@@ -20,7 +20,8 @@ from _io import *
from ost import mol,conop
def LoadPDB(filename, restrict_chains="", no_hetatms=False,
fault_tolerant=False, load_multi=False):
fault_tolerant=False, load_multi=False,
join_spread_atom_records=False):
"""
Load PDB file from disk.
......@@ -35,6 +36,10 @@ def LoadPDB(filename, restrict_chains="", no_hetatms=False,
If load_multi is set to true, a list of entities will be returned instead
of only the first.
If join_spread_atom_records is set to true, atom records belonging to the
same residue are joined, even if they do not appear sequentially in the PDB
file.
"""
conop_inst=conop.Conopology.Instance()
builder=conop_inst.GetBuilder("DEFAULT")
......@@ -45,6 +50,8 @@ def LoadPDB(filename, restrict_chains="", no_hetatms=False,
flags=PDB.SKIP_FAULTY_RECORDS
if no_hetatms:
flags|=PDB.NO_HETATMS
if join_spread_atom_records:
flags|=PDB.JOIN_SPREAD_ATOM_RECORDS
reader.SetFlags(flags)
if load_multi:
ent_list=[]
......
......@@ -37,6 +37,7 @@ void export_pdb_io()
.value("NO_HETATMS", PDB::NO_HETATMS)
.value("SKIP_FAULTY_RECORDS", PDB::SKIP_FAULTY_RECORDS)
.value("WRITE_MULTIPLE_MODELS", PDB::WRITE_MULTIPLE_MODELS)
.value("JOIN_SPREAD_ATOM_RECORDS", PDB::JOIN_SPREAD_ATOM_RECORDS)
;
class_<PDBReader, boost::noncopyable>("PDBReader", init<String>())
.def("HasNext", &PDBReader::HasNext)
......
......@@ -35,6 +35,29 @@ struct PDB {
WRITE_MULTIPLE_MODELS=4,
/// \brief enable for PQR
PQR_FORMAT=8,
/// \brief Join atom records into one residue, even if the atom records
/// are not sequential.
///
/// This is useful in the following case:
///
/// \verbatim
/// ATOM 43 N AALA P 4
/// ATOM 45 CA AALA P 4
/// ATOM 47 C AALA P 4
/// ATOM 48 O AALA P 4
/// ATOM 49 N APRO P 5
/// ATOM 50 CD APRO P 5
/// ATOM 53 CA APRO P 5
/// ATOM 55 CB APRO P 5
/// ATOM 58 CG APRO P 5
/// ATOM 61 C APRO P 5
/// ATOM 62 O APRO P 5
/// ATOM 550 CB AALA P 4
/// \endverbatim
///
/// By default, the atom 550 will start a new residue instead of being
/// joined with atoms 43-48 into one residue.
JOIN_SPREAD_ATOM_RECORDS=16
} Type;
};
......
......@@ -446,14 +446,21 @@ void PDBReader::ParseAndAddAtom(const String& line, int line_num,
++chain_count_;
}
}
if(update_residue) {
LOGN_DUMP("new residue " << rkey << " " << rnum);
curr_residue_=editor.AppendResidue(curr_chain_, rkey, rnum);
if (flags_ & PDB::JOIN_SPREAD_ATOM_RECORDS) {
curr_residue_=curr_chain_.FindResidue(rnum);
if (!curr_residue_.IsValid()) {
LOGN_DUMP("new residue " << rkey << " " << rnum);
curr_residue_=editor.AppendResidue(curr_chain_, rkey, rnum);
++residue_count_;
}
} else {
LOGN_DUMP("new residue " << rkey << " " << rnum);
curr_residue_=editor.AppendResidue(curr_chain_, rkey, rnum);
++residue_count_;
}
assert(curr_residue_.IsValid());
++residue_count_;
}
// finally add atom
LOGN_DUMP("adding atom " << aname << " (" << s_ele << ") @" << apos);
mol::AtomProp aprop;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment