more tests work and cmakelists is fixed

This commit is contained in:
Daniel Russel 2009-04-07 13:56:30 +00:00
parent 217bee88fe
commit 34a474f1a9
6 changed files with 52 additions and 40 deletions

View File

@ -129,14 +129,21 @@ inline bool Atom::operator!=(const Atom &o) const {
/*!
This returns the next unused index.
*/
template <class It>
inline int index_atoms(It b, It e, int start=0) {
for (; b != e; ++b) {
b->atom().set_index(Atom::Index(start++));
template <class Range>
inline int index_atoms(Range &r, int start=0) {
for (typename Range::iterator c=r.begin(); c!= r.end(); ++c) {
c->atom().set_index(Atom::Index(start++));
}
return start;
}
template <class Range>
inline int index_atoms(Range r, int start=0) {
for (typename Range::iterator c=r.begin(); c!= r.end(); ++c) {
c->atom().set_index(Atom::Index(start++));
}
return start;
}
//! Take an Atom and return the a K::Weighted_point

View File

@ -85,7 +85,7 @@ struct Get_point {
template <class A>
struct Get_index {
typedef unsigned int result_type;
typedef Atom::Index result_type;
result_type operator()(A a) const {
return a.index();
}

View File

@ -22,12 +22,14 @@ include(CGAL_CreateSingleSourceCGALProgram)
link_libraries(${CGAL_PDB_LIBRARY})
create_single_source_cgal_program( check_heatom.cpp )
create_single_source_cgal_program( check_pdb.cpp )
create_single_source_cgal_program( check_protein.cpp )
create_single_source_cgal_program( check_transform.cpp )
create_single_source_cgal_program( check_bonds.cpp )
create_single_source_cgal_program( check_refine_alignment.cpp )
create_single_source_cgal_program(check_atom_hetatom.cpp)
create_single_source_cgal_program(check_bonds.cpp)
create_single_source_cgal_program(check_hetatom.cpp)
create_single_source_cgal_program(check_iterators.cpp)
create_single_source_cgal_program(check_pdb.cpp)
create_single_source_cgal_program(check_refine_alignment.cpp)
create_single_source_cgal_program(check_small_map.cpp)
create_single_source_cgal_program(check_transform.cpp)

View File

@ -34,18 +34,17 @@ int main(int , char *[]){
//p.write(std::cout);
std::ostringstream of;
std::cout << "There are " << p.number_of_models() << " models." << std::endl;
std::cout << "There are " << p.models().size() << " models." << std::endl;
for (CGAL::PDB::PDB::Model_iterator it= p.models_begin();
it != p.models_end(); ++it){
const CGAL::PDB::Model &m= it->model();
std::cout << "Model " << it->key() << " has " << m.number_of_chains()
<< " chains" << " and " << m.number_of_heterogens()
CGAL_PDB_FOREACH(const CGAL::PDB::PDB::Model_pair& m,
p.models()) {
std::cout << "Model " << m.key() << " has " << m.model().chains().size()
<< " chains" << " and " << m.model().heterogens().size()
<< " heterogens" << std::endl;
for (CGAL::PDB::Model::Chain_const_iterator it = m.chains_begin();
it != m.chains_end(); ++it) {
std::cout << "Chain " << it->key() << " has "
<< it->chain().number_of_monomers() << " residues" << std::endl;
CGAL_PDB_FOREACH(const CGAL::PDB::Model::Chain_pair &c,
m.model().chains()) {
std::cout << "Chain " << c.key() << " has "
<< c.chain().monomers().size() << " residues" << std::endl;
}
}
p.write(of);

View File

@ -33,14 +33,14 @@ int main(int , char *[]){
//p.write(std::cout);
std::ostringstream of;
std::cout << "There are " << p.number_of_models() << " models." << std::endl;
std::cout << "There are " << p.models().size() << " models." << std::endl;
CGAL_PDB_FOREACH(const CGAL::PDB::PDB::Model_pair &m,
p.models()) {
std::cout << "Model " << m.key() << " has " << m.model().chains().size()
<< " chains" << " and " << m.model().heterogens().size()
<< " HETATMS" << std::endl;
CGAL_PDB_FOREACH(const CGAL::PDB::Model::Chain_pair &c,
m.chains()) {
m.model().chains()) {
std::cout << "Chain " << c.key() << " has "
<< c.chain().monomers().size() << " residues" << std::endl;
}

View File

@ -20,10 +20,15 @@ MA 02110-1301, USA. */
#include <CGAL/PDB/Chain.h>
#include <CGAL/PDB/PDB.h>
#include <CGAL/PDB/iterator.h>
#include <CGAL/PDB/range.h>
#include <fstream>
#include <cassert>
template <class Vector, class Range>
void fill(Vector &v, const Range &r) {
v.insert(v.end(), r.begin(), r.end());
}
int main() {
//dsr::Residue res= dsr::Residue(dsr::Residue::VAL);
@ -34,29 +39,28 @@ int main() {
{
std::ifstream in("data/check_pdb.pdb");
PDB pdb(in);
assert(pdb.number_of_models() != 0);
Model &model= pdb.models_begin()->model();
assert(model.number_of_chains() != 0);
const Chain &p= model.chains_begin()->chain();
unsigned int na= p.number_of_atoms();
assert(pdb.models().size() != 0);
Model &model= pdb.models().begin()->model();
assert(model.chains().size() != 0);
Chain &p= model.chains().begin()->chain();
unsigned int na= p.atoms().size();
//p.write(std::cout);
std::cout << "There are " << p.number_of_monomers() << " residues."
std::cout << "There are " << p.monomers().size() << " residues."
<< std::endl;
std::vector<Atom> atoms (make_atom_iterator(p.atoms_begin()),
make_atom_iterator(p.atoms_end()));
std::vector<Atom> atoms;
fill(atoms, make_atom_range(p.atoms()));
assert(na==atoms.size());
std::vector<Point> points (make_point_iterator(make_atom_iterator(p.atoms_begin())),
make_point_iterator(make_atom_iterator(p.atoms_end())));
std::vector<Point> points;
fill(points,make_point_range(make_atom_range(p.atoms())));
index_atoms(make_backbone_iterator(p.atoms_begin(), p.atoms_end()),
make_backbone_iterator(p.atoms_end(), p.atoms_end()));
std::vector<Index> bbi (make_index_iterator(make_atom_iterator(make_backbone_iterator(p.atoms_begin(), p.atoms_end()))),
make_index_iterator(make_atom_iterator(make_backbone_iterator(p.atoms_end(), p.atoms_end()))));
index_atoms(make_backbone_range(p.atoms()));
std::vector<Index> bbi;
fill(bbi, make_index_range(make_atom_range(make_backbone_range(p.atoms()))));
assert(bbi.size() < atoms.size());
std::cout << bbi.size() << std::endl;
std::vector<Bond> bbs (make_bond_indices_iterator(make_ok_bond_iterator(Is_backbone(), p.bonds_begin(), p.bonds_end())),
make_bond_indices_iterator(make_ok_bond_iterator(Is_backbone(), p.bonds_end(), p.bonds_end())));
std::vector<Bond> bbs;
fill(bbs, make_bond_indices_range(make_ok_bond_range(Is_backbone(), p.bonds())));
std::cout << bbs.size() << std::endl;
for (unsigned int i=0; i< bbs.size(); ++i) {
assert(bbs[i].first < Index(bbi.size()));