00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "dsrpdb/Protein.h"
00022 #include "dsrpdb/geometry.h"
00023 #include "dsrpdb/iterator.h"
00024 #include <fstream>
00025 #include <cassert>
00026 #include <iterator>
00027
00028 int main(int argc, char *argv[]){
00029
00030
00031 assert(argc==3);
00032 std::ifstream in(argv[1]);
00033 dsrpdb::Protein p(in);
00034
00035 std::ofstream of(argv[2]);
00036
00037 std::cout << "There are " << p.number_of_residues() << " residues." << std::endl;
00038
00039 p.write_pdb(of);
00040
00041
00042
00043 std::vector<dsrpdb::Point> atms;
00044 dsrpdb::coordinates(p.atoms_begin(), p.atoms_end(), std::back_inserter(atms));
00045 std::cout << "There are " << atms.size() << " atoms." << std::endl;
00046 assert(std::distance(p.atoms_begin(), p.atoms_end()) == atms.size());
00047
00048 std::vector<dsrpdb::Protein::Bond> bds(p.bonds_begin(), p.bonds_end());
00049 std::cout << "There are " << bds.size() << " bonds." << std::endl;
00050
00051
00052 std::vector<dsrpdb::Point> bb;
00053 dsrpdb::backbone_coordinates(p.atoms_begin(), p.atoms_end(), std::back_inserter(bb));
00054 assert(bb.size() < atms.size());
00055 {
00056 std::vector<std::pair<int,int> > bonds;
00057 std::vector<dsrpdb::Point> points;
00058 dsrpdb::coordinates_and_bonds(p, std::back_inserter(points), std::back_inserter(bonds));
00059 assert(bonds.size() == bds.size());
00060 assert(points.size() == atms.size());
00061 }
00062 {
00063 std::vector<dsrpdb::Point> points;
00064 dsrpdb::coordinates(p.atoms_begin(), p.atoms_end(), std::back_inserter(points));
00065 assert(points.size() == atms.size());
00066 }
00067 {
00068 std::vector<dsrpdb::Point> points;
00069 std::copy(backbone_coordinates_begin(p),
00070 backbone_coordinates_end(p),
00071 std::back_inserter(points));
00072 assert(points.size() == bb.size());
00073 }
00074 {
00075 std::vector<std::pair<int,int> > bonds;
00076 std::vector<dsrpdb::Point> points;
00077 dsrpdb::simplified_coordinates_and_bonds(p,
00078 std::back_inserter(points),
00079 std::back_inserter(bonds));
00080
00081 assert(bonds.size() == points.size()-1);
00082 assert(points.size() == 4*p.number_of_residues());
00083 }
00084
00085 {
00086 for (dsrpdb::Protein::Atoms_iterator it= p.atoms_begin(); it != p.atoms_end(); ++it){
00087 dsrpdb::Atom::Index ind= it->second.index();
00088 dsrpdb::Residue::Atom_label al= it->first;
00089 dsrpdb::Residue& res= p.residue_containing_atom(ind);
00090 assert(&res >= &*p.residues_begin()
00091 && &res < &*p.residues_begin() + p.number_of_residues());
00092 assert(res.atom_label(ind) != dsrpdb::Residue::AL_INVALID);
00093 assert(res.atom_label(ind) == al);
00094 }
00095 }
00096
00097 {
00098 for (dsrpdb::Protein::Bonds_iterator it= p.bonds_begin(); it != p.bonds_end(); ++it){
00099 dsrpdb::Atom::Index ind0= it->first;
00100 dsrpdb::Atom::Index ind1= it->second;
00101 assert(p.atom(ind0) != p.atom(dsrpdb::Atom::Index()));
00102 assert(p.atom(ind1) != p.atom(dsrpdb::Atom::Index()));
00103 int ir0= p.residue_containing_atom(ind0).index();
00104 int ir1= p.residue_containing_atom(ind1).index();
00105 int diff = ir1 - ir0;
00106 assert(diff==0 || diff ==1);
00107 }
00108 }
00109
00110 return EXIT_SUCCESS;
00111 }