mirror of https://github.com/CGAL/cgal
not sure why this existed anyway. Probably due to issues with SVN move or
something.
This commit is contained in:
parent
1784196317
commit
b21841b7d6
|
|
@ -2526,102 +2526,6 @@ Optimisation_doc/doc_tex/Inscribed_areas/largestEmptyRect.pdf -text svneol=unset
|
|||
Optimisation_doc/doc_tex/Inscribed_areas/max_triangle.eps -text svneol=unset#application/postscript
|
||||
Optimisation_doc/doc_tex/Inscribed_areas/max_triangle.gif -text svneol=unset#image/gif
|
||||
Optimisation_doc/doc_tex/Inscribed_areas/max_triangle.pdf -text svneol=unset#application/pdf
|
||||
PDB.tmpout/demo/PDB/makefile -text
|
||||
PDB.tmpout/demo/PDB/pdb_align.cpp -text
|
||||
PDB.tmpout/demo/PDB/pdb_align_points.cpp -text
|
||||
PDB.tmpout/demo/PDB/pdb_cat.cpp -text
|
||||
PDB.tmpout/demo/PDB/pdb_distance.cpp -text
|
||||
PDB.tmpout/demo/PDB/pdb_distance_matrix.cpp -text
|
||||
PDB.tmpout/demo/PDB/pdb_distances.cpp -text
|
||||
PDB.tmpout/demo/PDB/pdb_filter.cpp -text
|
||||
PDB.tmpout/demo/PDB/pdb_split.cpp -text
|
||||
PDB.tmpout/demo/PDB/pdb_stats.cpp -text
|
||||
PDB.tmpout/demo/PDB/pdb_strip_sidechains.cpp -text
|
||||
PDB.tmpout/demo/PDB/pdb_to_spheres.cpp -text
|
||||
PDB.tmpout/demo/PDB/pdb_transform.cpp -text
|
||||
PDB.tmpout/dont_submit -text
|
||||
PDB.tmpout/include/CGAL/PDB/Atom.h -text
|
||||
PDB.tmpout/include/CGAL/PDB/Matrix.h -text
|
||||
PDB.tmpout/include/CGAL/PDB/Model.h -text
|
||||
PDB.tmpout/include/CGAL/PDB/PDB.h -text
|
||||
PDB.tmpout/include/CGAL/PDB/Point.h -text
|
||||
PDB.tmpout/include/CGAL/PDB/Protein.h -text
|
||||
PDB.tmpout/include/CGAL/PDB/Quaternion.h -text
|
||||
PDB.tmpout/include/CGAL/PDB/Residue.h -text
|
||||
PDB.tmpout/include/CGAL/PDB/Transform.h -text
|
||||
PDB.tmpout/include/CGAL/PDB/align.h -text
|
||||
PDB.tmpout/include/CGAL/PDB/align_generic.h -text
|
||||
PDB.tmpout/include/CGAL/PDB/basic.h -text
|
||||
PDB.tmpout/include/CGAL/PDB/cgal.h -text
|
||||
PDB.tmpout/include/CGAL/PDB/distance.h -text
|
||||
PDB.tmpout/include/CGAL/PDB/geometry.h -text
|
||||
PDB.tmpout/include/CGAL/PDB/geometry_internal.h -text
|
||||
PDB.tmpout/include/CGAL/PDB/internal/Error_logger.h -text
|
||||
PDB.tmpout/include/CGAL/PDB/internal/Residue_data.h -text
|
||||
PDB.tmpout/include/CGAL/PDB/internal/align_points.out.h -text
|
||||
PDB.tmpout/include/CGAL/PDB/internal/pdb_utils.h -text
|
||||
PDB.tmpout/include/CGAL/PDB/internal/tnt/jama_cholesky.h -text
|
||||
PDB.tmpout/include/CGAL/PDB/internal/tnt/jama_eig.h -text
|
||||
PDB.tmpout/include/CGAL/PDB/internal/tnt/jama_lu.h -text
|
||||
PDB.tmpout/include/CGAL/PDB/internal/tnt/jama_qr.h -text
|
||||
PDB.tmpout/include/CGAL/PDB/internal/tnt/jama_svd.h -text
|
||||
PDB.tmpout/include/CGAL/PDB/internal/tnt/tnt_array1d.h -text
|
||||
PDB.tmpout/include/CGAL/PDB/internal/tnt/tnt_array1d_utils.h -text
|
||||
PDB.tmpout/include/CGAL/PDB/internal/tnt/tnt_array2d.h -text
|
||||
PDB.tmpout/include/CGAL/PDB/internal/tnt/tnt_array2d_utils.h -text
|
||||
PDB.tmpout/include/CGAL/PDB/internal/tnt/tnt_cmat.h -text
|
||||
PDB.tmpout/include/CGAL/PDB/internal/tnt/tnt_i_refvec.h -text
|
||||
PDB.tmpout/include/CGAL/PDB/internal/tnt/tnt_math_utils.h -text
|
||||
PDB.tmpout/include/CGAL/PDB/internal/tnt/tnt_subscript.h -text
|
||||
PDB.tmpout/include/CGAL/PDB/internal/tnt/tnt_vec.h -text
|
||||
PDB.tmpout/include/CGAL/PDB/iterator.h -text
|
||||
PDB.tmpout/include/CGAL/PDB/small_map.h -text
|
||||
PDB.tmpout/include/CGAL/PDB/transforms.h -text
|
||||
PDB.tmpout/maintainer -text
|
||||
PDB.tmpout/src/CGALPDB/PDB_Atom.cpp -text
|
||||
PDB.tmpout/src/CGALPDB/PDB_Error_logger.cpp -text
|
||||
PDB.tmpout/src/CGALPDB/PDB_Model.cpp -text
|
||||
PDB.tmpout/src/CGALPDB/PDB_PDB.cpp -text
|
||||
PDB.tmpout/src/CGALPDB/PDB_Protein.cpp -text
|
||||
PDB.tmpout/src/CGALPDB/PDB_Protein_pdb.cpp -text
|
||||
PDB.tmpout/src/CGALPDB/PDB_Quaternion.cpp -text
|
||||
PDB.tmpout/src/CGALPDB/PDB_Residue.cpp -text
|
||||
PDB.tmpout/src/CGALPDB/PDB_Residue_data.cpp -text
|
||||
PDB.tmpout/src/CGALPDB/PDB_Transform.cpp -text
|
||||
PDB.tmpout/src/CGALPDB/PDB_align.cpp -text
|
||||
PDB.tmpout/src/CGALPDB/PDB_distance.cpp -text
|
||||
PDB.tmpout/src/CGALPDB/PDB_pdb_utils.cpp -text
|
||||
PDB.tmpout/src/CGALPDB/PDB_transforms.cpp -text
|
||||
PDB.tmpout/src/CGALPDB/all_files.cpp -text
|
||||
PDB.tmpout/src/CGALPDB/makefile -text
|
||||
PDB.tmpout/test/PDB/check_bonds.cpp -text
|
||||
PDB.tmpout/test/PDB/check_hetatom.cpp -text
|
||||
PDB.tmpout/test/PDB/check_pdb.cpp -text
|
||||
PDB.tmpout/test/PDB/check_protein.cpp -text
|
||||
PDB.tmpout/test/PDB/check_refine_alignment.cpp -text
|
||||
PDB.tmpout/test/PDB/check_transform.cpp -text
|
||||
PDB.tmpout/test/PDB/check_transforms.cpp -text
|
||||
PDB.tmpout/test/PDB/data/check_bonds.pdb -text
|
||||
PDB.tmpout/test/PDB/data/check_hetatom.check_out.pdb -text
|
||||
PDB.tmpout/test/PDB/data/check_hetatom.pdb -text
|
||||
PDB.tmpout/test/PDB/data/check_pdb.check_out.pdb -text
|
||||
PDB.tmpout/test/PDB/data/check_pdb.pdb -text
|
||||
PDB.tmpout/test/PDB/data/check_pdb_align_0.pdb -text
|
||||
PDB.tmpout/test/PDB/data/check_pdb_align_1.pdb -text
|
||||
PDB.tmpout/test/PDB/data/check_pdb_align_2.pdb -text
|
||||
PDB.tmpout/test/PDB/data/check_pdb_align_aligned.check_out.pdb -text
|
||||
PDB.tmpout/test/PDB/data/check_pdb_align_aligned.pdb -text
|
||||
PDB.tmpout/test/PDB/data/check_pdb_cat.check_out.pdb -text
|
||||
PDB.tmpout/test/PDB/data/check_pdb_cat.pdb -text
|
||||
PDB.tmpout/test/PDB/data/check_pdb_split.0.pdb -text
|
||||
PDB.tmpout/test/PDB/data/check_pdb_split.1.pdb -text
|
||||
PDB.tmpout/test/PDB/data/check_protein.check_out.pdb -text
|
||||
PDB.tmpout/test/PDB/data/check_protein.pdb -text
|
||||
PDB.tmpout/test/PDB/data/check_refine_alignment_0.pdb -text
|
||||
PDB.tmpout/test/PDB/data/check_refine_alignment_1.pdb -text
|
||||
PDB.tmpout/test/PDB/data/check_refine_alignment_2.pdb -text
|
||||
PDB.tmpout/test/PDB/include/check_equal.h -text
|
||||
PDB.tmpout/todo -text
|
||||
PDB/demo/PDB/makefile -text
|
||||
PDB/demo/PDB/pdb_split.cpp -text
|
||||
PDB/demo/PDB/pdb_tree.cpp -text
|
||||
|
|
|
|||
|
|
@ -1,110 +0,0 @@
|
|||
# Created by the script cgal_create_makefile
|
||||
# This is the makefile for compiling a CGAL application.
|
||||
|
||||
#---------------------------------------------------------------------#
|
||||
# include platform specific settings
|
||||
#---------------------------------------------------------------------#
|
||||
# Choose the right include file from the <cgalroot>/make directory.
|
||||
|
||||
# CGAL_MAKEFILE = ENTER_YOUR_INCLUDE_MAKEFILE_HERE
|
||||
include $(CGAL_MAKEFILE)
|
||||
|
||||
#---------------------------------------------------------------------#
|
||||
# compiler flags
|
||||
#---------------------------------------------------------------------#
|
||||
|
||||
CXXFLAGS = \
|
||||
-I../../include \
|
||||
$(CGAL_CXXFLAGS) \
|
||||
$(LONG_NAME_PROBLEM_CXXFLAGS)
|
||||
|
||||
#---------------------------------------------------------------------#
|
||||
# linker flags
|
||||
#---------------------------------------------------------------------#
|
||||
|
||||
LIBPATH = \
|
||||
$(CGAL_LIBPATH)
|
||||
|
||||
LDFLAGS = \
|
||||
$(LONG_NAME_PROBLEM_LDFLAGS) \
|
||||
$(CGAL_LDFLAGS)
|
||||
|
||||
#---------------------------------------------------------------------#
|
||||
# target entries
|
||||
#---------------------------------------------------------------------#
|
||||
|
||||
all: \
|
||||
pdb_align$(EXE_EXT) \
|
||||
pdb_align_points$(EXE_EXT) \
|
||||
pdb_cat$(EXE_EXT) \
|
||||
pdb_distance$(EXE_EXT) \
|
||||
pdb_distance_matrix$(EXE_EXT) \
|
||||
pdb_distances$(EXE_EXT) \
|
||||
pdb_filter$(EXE_EXT) \
|
||||
pdb_split$(EXE_EXT) \
|
||||
pdb_stats$(EXE_EXT) \
|
||||
pdb_strip_sidechains$(EXE_EXT) \
|
||||
pdb_to_spheres$(EXE_EXT) \
|
||||
pdb_transform$(EXE_EXT)
|
||||
|
||||
pdb_align$(EXE_EXT): pdb_align$(OBJ_EXT)
|
||||
$(CGAL_CXX) $(LIBPATH) $(EXE_OPT)pdb_align pdb_align$(OBJ_EXT) $(LDFLAGS)
|
||||
|
||||
pdb_align_points$(EXE_EXT): pdb_align_points$(OBJ_EXT)
|
||||
$(CGAL_CXX) $(LIBPATH) $(EXE_OPT)pdb_align_points pdb_align_points$(OBJ_EXT) $(LDFLAGS)
|
||||
|
||||
pdb_cat$(EXE_EXT): pdb_cat$(OBJ_EXT)
|
||||
$(CGAL_CXX) $(LIBPATH) $(EXE_OPT)pdb_cat pdb_cat$(OBJ_EXT) $(LDFLAGS)
|
||||
|
||||
pdb_distance$(EXE_EXT): pdb_distance$(OBJ_EXT)
|
||||
$(CGAL_CXX) $(LIBPATH) $(EXE_OPT)pdb_distance pdb_distance$(OBJ_EXT) $(LDFLAGS)
|
||||
|
||||
pdb_distance_matrix$(EXE_EXT): pdb_distance_matrix$(OBJ_EXT)
|
||||
$(CGAL_CXX) $(LIBPATH) $(EXE_OPT)pdb_distance_matrix pdb_distance_matrix$(OBJ_EXT) $(LDFLAGS)
|
||||
|
||||
pdb_distances$(EXE_EXT): pdb_distances$(OBJ_EXT)
|
||||
$(CGAL_CXX) $(LIBPATH) $(EXE_OPT)pdb_distances pdb_distances$(OBJ_EXT) $(LDFLAGS)
|
||||
|
||||
pdb_filter$(EXE_EXT): pdb_filter$(OBJ_EXT)
|
||||
$(CGAL_CXX) $(LIBPATH) $(EXE_OPT)pdb_filter pdb_filter$(OBJ_EXT) $(LDFLAGS)
|
||||
|
||||
pdb_split$(EXE_EXT): pdb_split$(OBJ_EXT)
|
||||
$(CGAL_CXX) $(LIBPATH) $(EXE_OPT)pdb_split pdb_split$(OBJ_EXT) $(LDFLAGS)
|
||||
|
||||
pdb_stats$(EXE_EXT): pdb_stats$(OBJ_EXT)
|
||||
$(CGAL_CXX) $(LIBPATH) $(EXE_OPT)pdb_stats pdb_stats$(OBJ_EXT) $(LDFLAGS)
|
||||
|
||||
pdb_strip_sidechains$(EXE_EXT): pdb_strip_sidechains$(OBJ_EXT)
|
||||
$(CGAL_CXX) $(LIBPATH) $(EXE_OPT)pdb_strip_sidechains pdb_strip_sidechains$(OBJ_EXT) $(LDFLAGS)
|
||||
|
||||
pdb_to_spheres$(EXE_EXT): pdb_to_spheres$(OBJ_EXT)
|
||||
$(CGAL_CXX) $(LIBPATH) $(EXE_OPT)pdb_to_spheres pdb_to_spheres$(OBJ_EXT) $(LDFLAGS)
|
||||
|
||||
pdb_transform$(EXE_EXT): pdb_transform$(OBJ_EXT)
|
||||
$(CGAL_CXX) $(LIBPATH) $(EXE_OPT)pdb_transform pdb_transform$(OBJ_EXT) $(LDFLAGS)
|
||||
|
||||
clean: \
|
||||
pdb_align.clean \
|
||||
pdb_align_points.clean \
|
||||
pdb_cat.clean \
|
||||
pdb_distance.clean \
|
||||
pdb_distance_matrix.clean \
|
||||
pdb_distances.clean \
|
||||
pdb_filter.clean \
|
||||
pdb_split.clean \
|
||||
pdb_stats.clean \
|
||||
pdb_strip_sidechains.clean \
|
||||
pdb_to_spheres.clean \
|
||||
pdb_transform.clean
|
||||
|
||||
#---------------------------------------------------------------------#
|
||||
# suffix rules
|
||||
#---------------------------------------------------------------------#
|
||||
|
||||
.C$(OBJ_EXT):
|
||||
$(CGAL_CXX) $(CXXFLAGS) $(OBJ_OPT) $<
|
||||
|
||||
|
||||
.cpp$(OBJ_EXT):
|
||||
$(CGAL_CXX) $(CXXFLAGS) $(OBJ_OPT) $<
|
||||
|
||||
|
|
@ -1,139 +0,0 @@
|
|||
/* Copyright 2004
|
||||
Stanford University
|
||||
|
||||
This file is part of the DSR PDB Library.
|
||||
|
||||
The DSR PDB Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The DSR PDB Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the DSR PDB Library; see the file LICENSE.LGPL. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include <CGAL/PDB/PDB.h>
|
||||
|
||||
#include <vector>
|
||||
#include <iterator>
|
||||
#include <fstream>
|
||||
#include <CGAL/PDB/align.h>
|
||||
#include <CGAL/PDB/distance.h>
|
||||
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
std::string base_file, input_file, output_file;
|
||||
bool print_help=false;
|
||||
bool crms=false, drms=false;
|
||||
int base_model=0;
|
||||
bool warn=false;
|
||||
{
|
||||
boost::program_options::options_description o("Allowed options"), po, ao;
|
||||
o.add_options()
|
||||
("aligned-pdb,a", boost::program_options::value< std::string>(&output_file), "Where to write the result of aligning input-pdb to base-pdb.")
|
||||
|
||||
("crms,c", boost::program_options::bool_switch(&crms), "Output the cRMS between the two pdbs (after alignment).")
|
||||
("drms,d", boost::program_options::bool_switch(&drms), "Output the dRMS between the two pdbs.")
|
||||
("verbose,v", boost::program_options::bool_switch(&warn), "Warn about errors parsing pdb file.")
|
||||
("help", boost::program_options::bool_switch(&print_help), "Produce help message");
|
||||
po.add_options()("base-pdb", boost::program_options::value< std::string>(&base_file), "Base file")
|
||||
("input-pdb", boost::program_options::value< std::string>(&input_file), "input file");
|
||||
ao.add(o).add(po);
|
||||
|
||||
boost::program_options::positional_options_description p;
|
||||
p.add("base-pdb", 1);
|
||||
p.add("input-pdb", 1);
|
||||
|
||||
boost::program_options::variables_map vm;
|
||||
boost::program_options::store(boost::program_options::command_line_parser(argc, argv).
|
||||
options(ao).positional(p).run(), vm);
|
||||
boost::program_options::notify(vm);
|
||||
|
||||
|
||||
if (base_file.empty() || input_file.empty() || print_help) {
|
||||
std::cout << "This program aligns two proteins and can compute distances between them.\n";
|
||||
std::cout << "usage: " << argv[0] << " base-pdb input-pdb\n\n";
|
||||
std::cout << o << "\n";
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::ifstream in(input_file.c_str());
|
||||
|
||||
if (!in){
|
||||
std::cerr<< "Error opening input file: " << input_file << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
std::ifstream bin(base_file.c_str());
|
||||
|
||||
if (!bin){
|
||||
std::cerr<< "Error opening input file: " << base_file << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
CGAL_PDB_NS::PDB input(in, warn);
|
||||
CGAL_PDB_NS::PDB base(bin, warn);
|
||||
CGAL_PDB_NS::Protein base_protein;
|
||||
for (unsigned int i=0; i< base.number_of_models(); ++i){
|
||||
const CGAL_PDB_NS::Model &m= base.model(i);
|
||||
if (base_model ==0 || m.index()==base_model) {
|
||||
for (unsigned int j=0; j< m.number_of_chains(); ++j){
|
||||
base_protein= m.chain(j);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( !output_file.empty() || crms) {
|
||||
for (unsigned int i=0; i< input.number_of_models(); ++i){
|
||||
CGAL_PDB_NS::Model &m= input.model(i);
|
||||
CGAL_PDB_NS::Protein &p= m.chain(0);
|
||||
CGAL_PDB_NS::align_second_protein_to_first(base_protein, p);
|
||||
}
|
||||
}
|
||||
|
||||
if (!output_file.empty()) {
|
||||
std::ofstream out(output_file.c_str());
|
||||
if (!out){
|
||||
std::cerr << "Error opening output file "
|
||||
<< output_file << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
input.write(out);
|
||||
}
|
||||
|
||||
if (crms) {
|
||||
std::cout << "cRMS:\n";
|
||||
for (unsigned int i=0; i< input.number_of_models(); ++i){
|
||||
CGAL_PDB_NS::Model &m= input.model(i);
|
||||
CGAL_PDB_NS::Protein &p= m.chain(0);
|
||||
double d=CGAL_PDB_NS::no_align_cRMS(base_protein, p);
|
||||
if (d < .00001) d=0;
|
||||
std::cout << "Model " << i << " is " << d << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (drms) {
|
||||
std::cout << "dRMS:\n";
|
||||
for (unsigned int i=0; i< input.number_of_models(); ++i){
|
||||
CGAL_PDB_NS::Model &m= input.model(i);
|
||||
CGAL_PDB_NS::Protein &p= m.chain(0);
|
||||
double d=CGAL_PDB_NS::dRMS(base_protein, p);
|
||||
if (d < .00001) d=0;
|
||||
std::cout << "Model " << i << " is " << d << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
}
|
||||
|
|
@ -1,207 +0,0 @@
|
|||
/* Copyright 2004
|
||||
Stanford University
|
||||
|
||||
This file is part of the DSR PDB Library.
|
||||
|
||||
The DSR PDB Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The DSR PDB Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the DSR PDB Library; see the file LICENSE.LGPL. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include <CGAL/PDB/PDB.h>
|
||||
|
||||
#include <vector>
|
||||
#include <iterator>
|
||||
#include <fstream>
|
||||
#include <CGAL/PDB/align.h>
|
||||
#include <CGAL/PDB/distance.h>
|
||||
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
|
||||
// return the cRMS
|
||||
double align_to_points(const std::vector<CGAL_PDB_NS::Point> &points,
|
||||
char mode, CGAL_PDB_NS::Protein &p){
|
||||
std::vector<CGAL_PDB_NS::Point> ppoints;
|
||||
switch (mode) {
|
||||
case 'b':
|
||||
CGAL_PDB_NS::backbone_coordinates(p.atoms_begin(), p.atoms_end(),
|
||||
std::back_inserter(ppoints));
|
||||
break;
|
||||
case 'c':
|
||||
CGAL_PDB_NS::ca_coordinates(p.atoms_begin(), p.atoms_end(),
|
||||
std::back_inserter(ppoints));
|
||||
break;
|
||||
case 'a':
|
||||
CGAL_PDB_NS::coordinates(p.atoms_begin(), p.atoms_end(),
|
||||
std::back_inserter(ppoints));
|
||||
break;
|
||||
};
|
||||
|
||||
assert(points.size() == ppoints.size());
|
||||
|
||||
CGAL_PDB_NS::Transform tr= CGAL_PDB_NS::transform_taking_first_to_second(ppoints, points);
|
||||
//std::cout << tr << std::endl;
|
||||
|
||||
for (CGAL_PDB_NS::Protein::Atoms_iterator it= p.atoms_begin(); it != p.atoms_end(); ++it){
|
||||
CGAL_PDB_NS::Point np= tr(it->second.cartesian_coords());
|
||||
it->second.set_cartesian_coords(np);
|
||||
}
|
||||
|
||||
/*
|
||||
{
|
||||
|
||||
CGAL_PDB_NS::Transform tr2= CGAL_PDB_NS::compute_transform_taking_first_to_second(points,
|
||||
ppoints);
|
||||
std::cout << tr2 << std::endl;
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
std::vector<CGAL_PDB_NS::Point> npoints(ppoints.size());
|
||||
for (unsigned int i=0; i< points.size(); ++i){
|
||||
CGAL_PDB_NS::Point tp = tr(ppoints[i]);
|
||||
npoints[i]=tp;
|
||||
}
|
||||
CGAL_PDB_NS::Transform tr2= CGAL_PDB_NS::compute_transform_taking_first_to_second(npoints,
|
||||
points);
|
||||
std::cout << tr2 << std::endl;
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
std::vector<CGAL_PDB_NS::Point> npoints(ppoints.size());
|
||||
for (unsigned int i=0; i< points.size(); ++i){
|
||||
CGAL_PDB_NS::Point tp = tr(points[i]);
|
||||
npoints[i]=tp;
|
||||
}
|
||||
CGAL_PDB_NS::Transform tr2= CGAL_PDB_NS::compute_transform_taking_first_to_second(npoints,
|
||||
ppoints);
|
||||
std::cout << tr2 << std::endl;
|
||||
|
||||
}*/
|
||||
|
||||
double dist=0;
|
||||
|
||||
CGAL_PDB_NS::Squared_distance sd;
|
||||
|
||||
for (unsigned int i=0; i< points.size(); ++i){
|
||||
CGAL_PDB_NS::Point tp = tr(ppoints[i]);
|
||||
dist += std::sqrt(sd(tp, points[i]));
|
||||
}
|
||||
return dist/ points.size();
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
std::string base_file, input_file, output_file;
|
||||
bool print_help=false;
|
||||
bool crms=false;
|
||||
char mode='b';
|
||||
bool warn=false;
|
||||
{
|
||||
boost::program_options::options_description o("Allowed options"), po, ao;
|
||||
o.add_options()
|
||||
("aligned-pdb,o", boost::program_options::value< std::string>(&output_file),
|
||||
"Where to write the result of aligning input-pdb to base-points.")
|
||||
("atoms,a", boost::program_options::value< char>(&mode),
|
||||
"Which atoms to use from the protein. Values are b (backbone), c (c-alpha), a (all).")
|
||||
("crms,c", boost::program_options::bool_switch(&crms),
|
||||
"Output the cRMS between the two pdbs (after alignment).")
|
||||
("verbose,v", boost::program_options::bool_switch(&warn),
|
||||
"Warn about errors parsing pdb file.")
|
||||
("help", boost::program_options::bool_switch(&print_help),
|
||||
"Produce help message");
|
||||
po.add_options()("base-points", boost::program_options::value< std::string>(&base_file),
|
||||
"Base points")
|
||||
("input-pdb", boost::program_options::value< std::string>(&input_file),
|
||||
"input file");
|
||||
ao.add(o).add(po);
|
||||
|
||||
boost::program_options::positional_options_description p;
|
||||
p.add("base-points", 1);
|
||||
p.add("input-pdb", 1);
|
||||
|
||||
boost::program_options::variables_map vm;
|
||||
boost::program_options::store(boost::program_options::command_line_parser(argc, argv).
|
||||
options(ao).positional(p).run(), vm);
|
||||
boost::program_options::notify(vm);
|
||||
|
||||
|
||||
if (base_file.empty() || input_file.empty() || print_help
|
||||
|| (mode != 'b' && mode != 'c' && mode != 'a')) {
|
||||
std::cout << "This program aligns aligns a protein with a set of points and"
|
||||
" can compute distances between them.\n";
|
||||
std::cout << "usage: " << argv[0] << " base-points input-pdb\n\n";
|
||||
std::cout << o << "\n";
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::ifstream in(input_file.c_str());
|
||||
|
||||
if (!in){
|
||||
std::cerr<< "Error opening input file: " << input_file << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
std::ifstream bin(base_file.c_str());
|
||||
|
||||
if (!bin){
|
||||
std::cerr<< "Error opening input file: " << base_file << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
CGAL_PDB_NS::PDB input(in, warn);
|
||||
|
||||
std::vector<CGAL_PDB_NS::Point> points;
|
||||
while (bin) {
|
||||
char buf[10000];
|
||||
bin.getline(buf, 10000);
|
||||
if (!bin) break;
|
||||
if (buf[0]=='#') continue;
|
||||
std::istringstream iss(buf);
|
||||
CGAL_PDB_NS::Point pt;
|
||||
iss >> pt;
|
||||
points.push_back(pt);
|
||||
}
|
||||
|
||||
std::cout << "Read " << points.size() << " points.\n";
|
||||
|
||||
if ( !output_file.empty() || crms) {
|
||||
for (unsigned int i=0; i< input.number_of_models(); ++i){
|
||||
CGAL_PDB_NS::Model &m= input.model(i);
|
||||
CGAL_PDB_NS::Protein &p= m.chain(0);
|
||||
double cRMS= align_to_points(points, mode, p);
|
||||
if (crms) {
|
||||
std::cout << cRMS << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!output_file.empty()) {
|
||||
std::ofstream out(output_file.c_str());
|
||||
if (!out){
|
||||
std::cerr << "Error opening output file "
|
||||
<< output_file << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
input.write(out);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
}
|
||||
|
|
@ -1,105 +0,0 @@
|
|||
/* Copyright 2004
|
||||
Stanford University
|
||||
|
||||
This file is part of the DSR PDB Library.
|
||||
|
||||
The DSR PDB Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The DSR PDB Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the DSR PDB Library; see the file LICENSE.LGPL. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include <CGAL/PDB/PDB.h>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <CGAL/PDB/align.h>
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
std::vector<std::string> input_files;
|
||||
std::string output_file;
|
||||
bool print_help=false;
|
||||
bool verbose=false;
|
||||
bool align=false;
|
||||
|
||||
{
|
||||
boost::program_options::options_description o("Allowed options"), po, ao;
|
||||
o.add_options()
|
||||
("help", boost::program_options::bool_switch(&print_help), "produce help message")
|
||||
("verbose,v", boost::program_options::bool_switch(&verbose),
|
||||
"Print error messages from reading the pdb files.")
|
||||
("align,a", boost::program_options::bool_switch(&align),
|
||||
"Align each protein to the previous.");
|
||||
po.add_options()
|
||||
("input-pdbs", boost::program_options::value< std::vector<std::string> >(&input_files),
|
||||
"The input and output files.");
|
||||
|
||||
ao.add(o).add(po);
|
||||
|
||||
boost::program_options::positional_options_description p;
|
||||
p.add("input-pdbs", -1);
|
||||
|
||||
boost::program_options::variables_map vm;
|
||||
boost::program_options::store(boost::program_options::command_line_parser(argc, argv).
|
||||
options(ao).positional(p).run(), vm);
|
||||
boost::program_options::notify(vm);
|
||||
|
||||
|
||||
if (input_files.size() <2 || print_help) {
|
||||
std::cout << "Concatenate a bunch of pdb files into one pdb file with many models.\n";
|
||||
std::cout << "usage: " << argv[0] << " input-pdb-0 input-pdb-1 ... output-pdb\n";
|
||||
std::cout << o << "\n";
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
output_file=input_files.back();
|
||||
input_files.pop_back();
|
||||
}
|
||||
|
||||
|
||||
CGAL_PDB_NS::PDB outpdb;
|
||||
CGAL_PDB_NS::Model last;
|
||||
for (unsigned int i=0; i < input_files.size(); ++i){
|
||||
std::ifstream in(input_files[i].c_str());
|
||||
if (!in){
|
||||
std::cerr << "Error opening input file " << input_files[i] << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
CGAL_PDB_NS::PDB inpdb(in, verbose);
|
||||
|
||||
for (CGAL_PDB_NS::PDB::Models_iterator mit= inpdb.models_begin(); mit != inpdb.models_end(); ++mit){
|
||||
CGAL_PDB_NS::Model m= *mit;
|
||||
m.set_index(outpdb.number_of_models());
|
||||
if (align && i != 0) {
|
||||
for (unsigned int j= 0; j< m.number_of_chains(); ++j) {
|
||||
CGAL_PDB_NS::Protein &p= m.chain(j);
|
||||
const CGAL_PDB_NS::Protein &bp= last.chain(j);
|
||||
CGAL_PDB_NS::align_second_protein_to_first(bp, p);
|
||||
}
|
||||
}
|
||||
outpdb.new_model(m);
|
||||
last= m;
|
||||
}
|
||||
}
|
||||
|
||||
if (output_file.empty()){
|
||||
outpdb.write(std::cout);
|
||||
} else {
|
||||
std::ofstream out(output_file.c_str());
|
||||
outpdb.write(out);
|
||||
}
|
||||
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -1,230 +0,0 @@
|
|||
/* Copyright 2004
|
||||
Stanford University
|
||||
|
||||
This file is part of the DSR PDB Library.
|
||||
|
||||
The DSR PDB Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The DSR PDB Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the DSR PDB Library; see the file LICENSE.LGPL. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include <CGAL/PDB/PDB.h>
|
||||
|
||||
#include <vector>
|
||||
#include <iterator>
|
||||
#include <fstream>
|
||||
#include <CGAL/PDB/align.h>
|
||||
#include <CGAL/PDB/distance.h>
|
||||
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
|
||||
/*!
|
||||
\example pdb_distance.cc
|
||||
|
||||
This example shows how to compute various types of distance measures
|
||||
between proteins. For cRMS computations, the proteins are first
|
||||
aligned and then the cRMS is computed (this could instead be done
|
||||
with one function call).
|
||||
*/
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
std::string base_file, input_file, output_file;
|
||||
bool print_help=false;
|
||||
bool crms=false, drms=false;
|
||||
int base_model=0;
|
||||
bool warn=false;
|
||||
bool all_atoms=false;
|
||||
bool no_align=false;
|
||||
bool max_cdist=false;
|
||||
bool max_ddist=false;
|
||||
{
|
||||
boost::program_options::options_description o("Allowed options"), po, ao;
|
||||
o.add_options()
|
||||
("crms,c", boost::program_options::bool_switch(&crms),
|
||||
"Output the cRMS between the two pdbs (after alignment).")
|
||||
("drms,d", boost::program_options::bool_switch(&drms),
|
||||
"Output the dRMS between the two pdbs.")
|
||||
("all-atoms,a", boost::program_options::bool_switch(&all_atoms),
|
||||
"Output the distances between all atoms, not just the C_alphas.")
|
||||
("no-align,n", boost::program_options::bool_switch(&no_align),
|
||||
"Do not rigidly align the proteins before computing cRMS.")
|
||||
("verbose,v", boost::program_options::bool_switch(&warn),
|
||||
"Warn about errors parsing pdb file.")
|
||||
("max-c-dist,C", boost::program_options::bool_switch(&max_cdist),
|
||||
"Output the max distance between any two corresponding atoms.")
|
||||
("max-d-dist,D", boost::program_options::bool_switch(&max_ddist),
|
||||
"Output the max distance difference between pairwise distances.")
|
||||
("help", boost::program_options::bool_switch(&print_help), "Produce help message");
|
||||
|
||||
po.add_options()("input-pdb-0",
|
||||
boost::program_options::value< std::string>(&base_file),
|
||||
"First input file.")
|
||||
("input-pdb-1", boost::program_options::value< std::string>(&input_file),
|
||||
"Second input file");
|
||||
ao.add(o).add(po);
|
||||
|
||||
boost::program_options::positional_options_description p;
|
||||
p.add("input-pdb-0", 1);
|
||||
p.add("input-pdb-1", 1);
|
||||
|
||||
boost::program_options::variables_map vm;
|
||||
boost::program_options::store(boost::program_options::command_line_parser(argc, argv).
|
||||
options(ao).positional(p).run(), vm);
|
||||
boost::program_options::notify(vm);
|
||||
|
||||
|
||||
if (base_file.empty() || input_file.empty() || print_help) {
|
||||
std::cout << "This program computes the distance between two pdb files..\n";
|
||||
std::cout << "usage: " << argv[0] << " input-pdb-0 input-pdb-1\n\n";
|
||||
std::cout << o << "\n";
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::ifstream in(input_file.c_str());
|
||||
|
||||
if (!in){
|
||||
std::cerr<< "Error opening input file: " << input_file << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
std::ifstream bin(base_file.c_str());
|
||||
|
||||
if (!bin){
|
||||
std::cerr<< "Error opening input file: " << base_file << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
CGAL_PDB_NS::PDB input(in, warn);
|
||||
CGAL_PDB_NS::PDB base(bin, warn);
|
||||
CGAL_PDB_NS::Protein base_protein;
|
||||
for (unsigned int i=0; i< base.number_of_models(); ++i){
|
||||
const CGAL_PDB_NS::Model &m= base.model(i);
|
||||
if (base_model ==0 || m.index()==base_model) {
|
||||
for (unsigned int j=0; j< m.number_of_chains(); ++j){
|
||||
base_protein= m.chain(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( crms && !no_align) {
|
||||
for (unsigned int i=0; i< input.number_of_models(); ++i){
|
||||
CGAL_PDB_NS::Model &m= input.model(i);
|
||||
CGAL_PDB_NS::Protein &p= m.chain(0);
|
||||
CGAL_PDB_NS::align_second_protein_to_first(base_protein, p);
|
||||
}
|
||||
}
|
||||
|
||||
if (crms) {
|
||||
std::cout << "cRMS:\n";
|
||||
for (unsigned int i=0; i< input.number_of_models(); ++i){
|
||||
CGAL_PDB_NS::Model &m= input.model(i);
|
||||
CGAL_PDB_NS::Protein &p= m.chain(0);
|
||||
double d;
|
||||
if (all_atoms) {
|
||||
d =CGAL_PDB_NS::no_align_cRMS(base_protein, p);
|
||||
} else {
|
||||
d =CGAL_PDB_NS::no_align_ca_cRMS(base_protein, p);
|
||||
}
|
||||
if (d < .00001) d=0;
|
||||
std::cout << "Model " << i << " is " << d << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (max_cdist) {
|
||||
std::vector<CGAL_PDB_NS::Point> base_coords;
|
||||
if (all_atoms) {
|
||||
CGAL_PDB_NS::coordinates(base_protein.atoms_begin(), base_protein.atoms_end(), std::back_inserter(base_coords));
|
||||
} else {
|
||||
CGAL_PDB_NS::ca_coordinates(base_protein.atoms_begin(), base_protein.atoms_end(), std::back_inserter(base_coords));
|
||||
}
|
||||
std::cout << "Max dist:\n";
|
||||
for (unsigned int i=0; i< input.number_of_models(); ++i){
|
||||
CGAL_PDB_NS::Model &m= input.model(i);
|
||||
CGAL_PDB_NS::Protein &p= m.chain(0);
|
||||
std::vector<CGAL_PDB_NS::Point> coords;
|
||||
if (all_atoms) {
|
||||
CGAL_PDB_NS::coordinates(p.atoms_begin(), p.atoms_end(), std::back_inserter(coords));
|
||||
} else {
|
||||
CGAL_PDB_NS::ca_coordinates(p.atoms_begin(), p.atoms_end(), std::back_inserter(coords));
|
||||
}
|
||||
if (coords.size() != base_coords.size()){
|
||||
std::cerr<< "Proteins being compared must have the same number of atoms.\n";
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
double mmax= 0;
|
||||
CGAL_PDB_NS::Squared_distance sd;
|
||||
for (unsigned int j=0; j< coords.size(); ++j){
|
||||
mmax=std::max BOOST_PREVENT_MACRO_SUBSTITUTION(std::sqrt(sd(coords[j], base_coords[j])), mmax);
|
||||
}
|
||||
std::cout << "Model " << i << " is " << mmax << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (drms) {
|
||||
std::cout << "\ndRMS:\n";
|
||||
for (unsigned int i=0; i< input.number_of_models(); ++i){
|
||||
CGAL_PDB_NS::Model &m= input.model(i);
|
||||
CGAL_PDB_NS::Protein &p= m.chain(0);
|
||||
double d;
|
||||
if (all_atoms) {
|
||||
d=CGAL_PDB_NS::dRMS(base_protein, p);
|
||||
} else {
|
||||
d=CGAL_PDB_NS::ca_dRMS(base_protein, p);
|
||||
}
|
||||
if (d < .00001) d=0;
|
||||
std::cout << "Model " << i << " is " << d << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (max_ddist) {
|
||||
CGAL_PDB_NS::Matrix base_matrix;
|
||||
if (all_atoms) {
|
||||
base_matrix=CGAL_PDB_NS::distance_matrix(base_protein);
|
||||
} else {
|
||||
base_matrix=CGAL_PDB_NS::ca_distance_matrix(base_protein);
|
||||
}
|
||||
std::cout << "Max dist:\n";
|
||||
for (unsigned int i=0; i< input.number_of_models(); ++i){
|
||||
CGAL_PDB_NS::Model &m= input.model(i);
|
||||
CGAL_PDB_NS::Protein &p= m.chain(0);
|
||||
CGAL_PDB_NS::Matrix input_matrix;
|
||||
if (all_atoms) {
|
||||
input_matrix= CGAL_PDB_NS::distance_matrix(p);
|
||||
} else {
|
||||
input_matrix = CGAL_PDB_NS::ca_distance_matrix(p);
|
||||
}
|
||||
if (base_matrix.dim1() != input_matrix.dim1()){
|
||||
std::cerr << "Proteins being compared must have the same number of atoms.\n";
|
||||
std::cerr << "Base protein had " << base_matrix.dim1()
|
||||
<< " atoms and second protein had " << input_matrix.dim1()
|
||||
<< " atoms." << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
double mmax= 0;
|
||||
double maxr=0;
|
||||
for (int j=0; j< base_matrix.dim1(); ++j){
|
||||
for (int k=0; k< j; ++k){
|
||||
mmax=std::max BOOST_PREVENT_MACRO_SUBSTITUTION(std::abs(base_matrix[j][k]-input_matrix[j][k]), mmax);
|
||||
maxr=std::max BOOST_PREVENT_MACRO_SUBSTITUTION(std::abs(base_matrix[j][k]-input_matrix[j][k])
|
||||
/std::max BOOST_PREVENT_MACRO_SUBSTITUTION(base_matrix[j][k],input_matrix[j][k]), maxr);
|
||||
}
|
||||
}
|
||||
std::cout << "Model " << i << " is " << mmax << " with ratio " << maxr << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
}
|
||||
|
|
@ -1,212 +0,0 @@
|
|||
/* Copyright 2004
|
||||
Stanford University
|
||||
|
||||
This file is part of the DSR PDB Library.
|
||||
|
||||
The DSR PDB Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The DSR PDB Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the DSR PDB Library; see the file LICENSE.LGPL. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include <CGAL/PDB/PDB.h>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <CGAL/PDB/distance.h>
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
|
||||
#ifdef PDB_USE_MAGICK
|
||||
#include <Magick++.h>
|
||||
|
||||
|
||||
/*!
|
||||
\example pdb_write_distmat.cc
|
||||
|
||||
This example shows how to write a distance matrix to a file.
|
||||
*/
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
std::string input_file, output_file;
|
||||
bool print_help=false;
|
||||
bool verbose=false;
|
||||
bool interactive=false;
|
||||
bool backbone=false;
|
||||
bool all_atoms=false;
|
||||
double contact_map_threshold=std::numeric_limits<double>::infinity();
|
||||
|
||||
{
|
||||
boost::program_options::options_description o("Allowed options"), po, ao;
|
||||
o.add_options()
|
||||
("help", boost::program_options::bool_switch(&print_help), "produce help message")
|
||||
("verbose,v", boost::program_options::bool_switch(&verbose), "print verbose error messages")
|
||||
("all-atoms,a", boost::program_options::bool_switch(&all_atoms),
|
||||
"Output the distances between all atoms, not just the C_alphas.")
|
||||
("backbone-atoms,b", boost::program_options::bool_switch(&backbone),
|
||||
"Output the distances between all backbone atoms, not just the C_alphas.")
|
||||
("image,i",boost::program_options::value<std::string>(&output_file), "Output image file.")
|
||||
("contact-threshold,c",boost::program_options::value<double>(&contact_map_threshold), "Output a contact map with the given threshold. (assuming the image argument is passed).")
|
||||
("query,q", boost::program_options::bool_switch(&interactive), "Enter a mode to do interactive queries about edge lengths.");
|
||||
po.add_options()
|
||||
("input-pdb", boost::program_options::value< std::string>(&input_file), "input file");
|
||||
|
||||
ao.add(o).add(po);
|
||||
|
||||
boost::program_options::positional_options_description p;
|
||||
p.add("input-pdb", 1);
|
||||
p.add("output-image", 1);
|
||||
|
||||
boost::program_options::variables_map vm;
|
||||
boost::program_options::store(boost::program_options::command_line_parser(argc, argv).
|
||||
options(ao).positional(p).run(), vm);
|
||||
boost::program_options::notify(vm);
|
||||
|
||||
|
||||
|
||||
//boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm);
|
||||
//boost::program_options::notify(vm);
|
||||
|
||||
if (input_file.empty() || print_help || (all_atoms && backbone)) {
|
||||
std::cout << "This program writes the distance matrix to an image file.\n";
|
||||
std::cout << "Only one of -b or -a may be used.\n";
|
||||
std::cout << "usage: " << argv[0] << " input-pdb\n\n";
|
||||
std::cout << o << "\n";
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
std::ifstream in(input_file.c_str());
|
||||
if (!in) {
|
||||
std::cerr << "Error opening input file " << input_file << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
CGAL_PDB_NS::PDB pdb(in, verbose);
|
||||
|
||||
if (verbose) std::cout << "Input PDB has " << pdb.number_of_models() << " models." << std::endl;
|
||||
if (pdb.number_of_models() != 1){
|
||||
std::cout << "Attempting to write multiple image files: assuming the output argument has a %d in it.\n";
|
||||
}
|
||||
|
||||
for (unsigned int i=0;i< pdb.number_of_models(); ++i){
|
||||
CGAL_PDB_NS::Model &m= pdb.model(i);
|
||||
CGAL_PDB_NS::Matrix arr;
|
||||
if (all_atoms) {
|
||||
arr= distance_matrix(m);
|
||||
} else if (backbone) {
|
||||
arr= backbone_distance_matrix(m);
|
||||
} else {
|
||||
arr= ca_distance_matrix(m);
|
||||
}
|
||||
|
||||
//std::cout << arr.dim1() << " " << arr.dim2() << std::endl;
|
||||
|
||||
if (interactive) {
|
||||
std::cout << "Entering interactive mode for model " << i << std::endl;
|
||||
std::cout << "There are " << arr.dim1() << " atoms." << std::endl;
|
||||
while (true) {
|
||||
std::cout << "> " << std::flush;
|
||||
char buf[100];
|
||||
std::cin.getline(buf, 100);
|
||||
if (strcmp(buf, "quit") ==0 || strcmp(buf,"exit") ==0){
|
||||
break;
|
||||
} else {
|
||||
int a,b;
|
||||
if (sscanf(buf, "%d %d", &a, &b)==2){
|
||||
if (a > arr.dim1() || b > arr.dim1() || a<0 || b <0){
|
||||
std::cerr << "Index " << a << " or " << b << " out of range." << std::endl;
|
||||
} else {
|
||||
std::cout << arr[a][b] << std::endl;
|
||||
}
|
||||
} else if (sscanf(buf, "r %d %d", &a, &b) ==2) {
|
||||
if (a > 0 && b > 0) {
|
||||
CGAL_PDB_NS::Residue::Index ia(a), ib(b);
|
||||
if (m.chain(0).has_residue(ia) && m.chain(0).has_residue(ib)) {
|
||||
CGAL_PDB_NS::Point pa= m.chain(0).residue(ia).atom(CGAL_PDB_NS::Residue::AL_CA).cartesian_coords();
|
||||
CGAL_PDB_NS::Point pb= m.chain(0).residue(ib).atom(CGAL_PDB_NS::Residue::AL_CA).cartesian_coords();
|
||||
CGAL_PDB_NS::Squared_distance sd;
|
||||
double d= std::sqrt(sd(pa,pb));
|
||||
std::cout << "The Ca distance is " << d << std::endl;
|
||||
} else {
|
||||
std::cerr << "Invalid residues picked.\n";
|
||||
}
|
||||
} else {
|
||||
std::cerr << "Invalid residues indices picked (must be greater than 0).\n";
|
||||
}
|
||||
} else {
|
||||
std::cerr << "Error parsing input. Please enter a pair of indices or 'exit'." << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!output_file.empty()) {
|
||||
|
||||
char buf[100000];
|
||||
if (pdb.number_of_models() != 1){
|
||||
sprintf(buf, output_file.c_str(), i);
|
||||
} else {
|
||||
sprintf(buf, output_file.c_str());
|
||||
}
|
||||
Magick::Geometry geom(arr.dim1(),arr.dim2());
|
||||
|
||||
|
||||
Magick::Image im(geom, "red");
|
||||
|
||||
if (contact_map_threshold != std::numeric_limits<double>::infinity()){
|
||||
for (int j=0; j< arr.dim1(); ++j){
|
||||
for (int k=0; k< arr.dim2(); ++k){
|
||||
if (arr[j][k] < contact_map_threshold){
|
||||
im.pixelColor(j, k, Magick::ColorGray(1));
|
||||
} else {
|
||||
im.pixelColor(j,k, Magick::ColorGray(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
double lmax=0;
|
||||
for (int i=0; i< arr.dim1(); ++i){
|
||||
for (int j=0; j< arr.dim2(); ++j){
|
||||
lmax=std::max BOOST_PREVENT_MACRO_SUBSTITUTION(max, arr[i][j]);
|
||||
//min=std::min(min, arr[i][j]);
|
||||
}
|
||||
}
|
||||
//std::cout << "Maximum distance is " << max << std::endl;
|
||||
for (int i=0; i< arr.dim1(); ++i){
|
||||
for (int j=0; j< arr.dim2(); ++j){
|
||||
im.pixelColor(i,j, Magick::ColorGray(arr[i][j]/lmax));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
im.write(buf);
|
||||
}
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main(int, char*[]){
|
||||
//bool this_program_requires_image_magick;
|
||||
std::cerr << "This program requires Image Magick++\n";
|
||||
// so that the test suite is not red
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,131 +0,0 @@
|
|||
#include <CGAL/PDB/PDB.h>
|
||||
#include <vector>
|
||||
#include <iterator>
|
||||
#include <fstream>
|
||||
#include <CGAL/PDB/distance.h>
|
||||
|
||||
#ifdef PDB_USE_MAGICK
|
||||
#include <Magick++.h>
|
||||
#endif
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
std::vector<std::string> inputs;
|
||||
bool print_help=false;
|
||||
bool crms=false, drms=false;
|
||||
bool warn=false;
|
||||
bool all_atoms=false;
|
||||
std::string image_name;
|
||||
{
|
||||
boost::program_options::options_description o("Allowed options"), po, ao;
|
||||
o.add_options()
|
||||
("crms,c", boost::program_options::bool_switch(&crms),
|
||||
"Output the cRMS between the two pdbs (after alignment).")
|
||||
("drms,d", boost::program_options::bool_switch(&drms),
|
||||
"Output the dRMS between the two pdbs.")
|
||||
("all-atoms,a", boost::program_options::bool_switch(&all_atoms),
|
||||
"Output the distances between all atoms, not just the C_alphas.")
|
||||
("verbose,v", boost::program_options::bool_switch(&warn),
|
||||
"Warn about errors parsing pdb file.")
|
||||
("image-file,i", boost::program_options::value<std::string>(&image_name),
|
||||
"Output the max distance difference between pairwise distances.")
|
||||
("help", boost::program_options::bool_switch(&print_help), "Produce help message");
|
||||
|
||||
po.add_options()("input-pdbs",
|
||||
boost::program_options::value< std::vector<std::string> >(&inputs)->composing(),
|
||||
"The input files. Names with a % in their name are assumed to have printf style converters for ints and will be expanded to the first n integers that correspond to names of actual files.");
|
||||
ao.add(o).add(po);
|
||||
|
||||
boost::program_options::positional_options_description p;
|
||||
p.add("input-pdbs", -1);
|
||||
|
||||
boost::program_options::variables_map vm;
|
||||
boost::program_options::store(boost::program_options::command_line_parser(argc, argv).
|
||||
options(ao).positional(p).run(), vm);
|
||||
boost::program_options::notify(vm);
|
||||
|
||||
|
||||
if (inputs.empty() || print_help) {
|
||||
std::cout << "This program computes the distances between a collection of pdb files.\n";
|
||||
std::cout << "usage: " << argv[0] << " file1.pdb file%03d.pdb ...\n\n";
|
||||
std::cout << o << "\n";
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::string> names;
|
||||
std::vector<CGAL_PDB_NS::Protein> pdbs;
|
||||
for (unsigned int i=0; i < inputs.size(); ++i){
|
||||
if (inputs[i].find('%') == std::string::npos){
|
||||
std::ifstream in(inputs[i].c_str());
|
||||
if (!in) {
|
||||
std::cerr << "Error opening file " << inputs[i] << std::endl;
|
||||
} else {
|
||||
pdbs.push_back(CGAL_PDB_NS::Protein(in));
|
||||
names.push_back(inputs[i]);
|
||||
}
|
||||
} else {
|
||||
for (unsigned int j=0; ; ++j){
|
||||
char buf[5000];
|
||||
sprintf(buf, inputs[i].c_str(), j);
|
||||
std::ifstream in(buf);
|
||||
if (!in) {
|
||||
break;
|
||||
} else {
|
||||
pdbs.push_back(CGAL_PDB_NS::Protein(in));
|
||||
names.push_back(buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CGAL_TNT_NS::Array2D<double> dists(pdbs.size(), pdbs.size(), 0.0);
|
||||
|
||||
double max=0;
|
||||
for (unsigned int i=0; i< pdbs.size(); ++i){
|
||||
for (unsigned int j=0; j<i; ++j){
|
||||
double d;
|
||||
if (drms) {
|
||||
if (all_atoms) {
|
||||
d= CGAL_PDB_NS::dRMS(pdbs[i], pdbs[j]);
|
||||
} else {
|
||||
d= CGAL_PDB_NS::ca_dRMS(pdbs[i], pdbs[j]);
|
||||
}
|
||||
} else {
|
||||
if (all_atoms) {
|
||||
d= CGAL_PDB_NS::cRMS(pdbs[i], pdbs[j]);
|
||||
} else {
|
||||
d= CGAL_PDB_NS::ca_cRMS(pdbs[i], pdbs[j]);
|
||||
}
|
||||
}
|
||||
dists[i][j]=dists[j][i]=d;
|
||||
max= (std::max)(d, max);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::cout << "The maximum error is " << max << std::endl;
|
||||
|
||||
#ifdef PDB_USE_MAGICK
|
||||
if (!image_name.empty()){
|
||||
Magick::Geometry geom(dists.dim1(),dists.dim2());
|
||||
|
||||
Magick::Image im(geom, "red");
|
||||
for (int j=0; j< dists.dim1(); ++j){
|
||||
for (int k=0; k< dists.dim2(); ++k){
|
||||
double v= (std::min) (1.0, dists[j][k]/6.0);
|
||||
im.pixelColor(j, k, Magick::ColorGray(1-v));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
im.write(image_name.c_str());
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -1,152 +0,0 @@
|
|||
/* Copyright 2004
|
||||
Stanford University
|
||||
|
||||
This file is part of the DSR PDB Library.
|
||||
|
||||
The DSR PDB Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The DSR PDB Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the DSR PDB Library; see the file LICENSE.LGPL. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include <CGAL/PDB/PDB.h>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
|
||||
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
std::string input_file, output_file, nearby_file;
|
||||
|
||||
bool print_help=false;
|
||||
bool verbose=false;
|
||||
double dist_threshold=3;
|
||||
|
||||
boost::program_options::options_description o("Allowed options"), po, ao;
|
||||
o.add_options()
|
||||
("help", boost::program_options::bool_switch(&print_help),
|
||||
"produce help message")
|
||||
("verbose,v", boost::program_options::bool_switch(&verbose),
|
||||
"print out verbose messages about reading and writing pdb files")
|
||||
("distance,d", boost::program_options::value<double>(&dist_threshold),
|
||||
"The maximum distance to find neighbors when looking for nearby atoms.")
|
||||
("nearby-file,n", boost::program_options::value<std::string>(&nearby_file),
|
||||
"Only output atoms which are near atoms of a similar type in this file.");
|
||||
po.add_options()
|
||||
("input-pdb", boost::program_options::value< std::string>(&input_file),
|
||||
"input file")
|
||||
("output-pdb", boost::program_options::value< std::string>(&output_file),
|
||||
"Output file.");
|
||||
|
||||
ao.add(o).add(po);
|
||||
|
||||
boost::program_options::positional_options_description p;
|
||||
p.add("input-pdb", 1);
|
||||
p.add("output-pdb", 2);
|
||||
|
||||
boost::program_options::variables_map vm;
|
||||
boost::program_options::store(boost::program_options::command_line_parser(argc, argv).
|
||||
options(ao).positional(p).run(), vm);
|
||||
boost::program_options::notify(vm);
|
||||
|
||||
|
||||
|
||||
//boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm);
|
||||
//boost::program_options::notify(vm);
|
||||
|
||||
if (input_file.empty()
|
||||
|| output_file.empty()
|
||||
|| print_help) {
|
||||
std::cout << "This program filters a pdb file, removing some of the atoms and residues.\n";
|
||||
std::cout << "useage: " << argv[0]
|
||||
<< " [-c] input-pdb output.pdb\n" << std::endl;
|
||||
std::cout << o << "\n";
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
// std::cout << input_file << " " << output_template << " " << split_domain << " " << split_chains << std::endl;
|
||||
|
||||
std::ifstream in(input_file.c_str());
|
||||
if (!in) {
|
||||
std::cerr << "Error opening input file " << input_file << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
//= new char[strlen(argv[2]+1000)];
|
||||
CGAL_PDB_NS::PDB pdb(in, verbose);
|
||||
|
||||
std::cout << "Input PDB has " << pdb.number_of_models() << " models." << std::endl;
|
||||
|
||||
|
||||
|
||||
if (!nearby_file.empty()){
|
||||
std::ifstream ns(input_file.c_str());
|
||||
if (!ns) {
|
||||
std::cerr << "Error opening input file " << nearby_file << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
CGAL_PDB_NS::PDB fpdb(ns, verbose);
|
||||
|
||||
CGAL_PDB_NS::Squared_distance sd;
|
||||
|
||||
for (unsigned int i=0; i< pdb.number_of_models(); ++i){
|
||||
CGAL_PDB_NS::Model &m= pdb.model(i);
|
||||
CGAL_PDB_NS::Model &fm= fpdb.number_of_models()==1?fpdb.model(0):fpdb.model(i);
|
||||
|
||||
for (unsigned int j=0; j< m.number_of_chains(); ++j){
|
||||
CGAL_PDB_NS::Protein &c= m.chain(j);
|
||||
std::vector<CGAL_PDB_NS::Atom::Index> to_erase;
|
||||
|
||||
|
||||
for (CGAL_PDB_NS::Protein::Const_atoms_iterator it= c.atoms_begin(); it != c.atoms_end(); ++it){
|
||||
bool found=false;
|
||||
for (unsigned int j=0; j< fm.number_of_chains(); ++j){
|
||||
const CGAL_PDB_NS::Protein &fc= fm.chain(j);
|
||||
for (CGAL_PDB_NS::Protein::Const_atoms_iterator fit= fc.atoms_begin(); fit != fc.atoms_end(); ++fit){
|
||||
if (fit->second.type()== it->second.type()) {
|
||||
double dd= sd(fit->second.cartesian_coords(), it->second.cartesian_coords());
|
||||
if (dd < dist_threshold*dist_threshold){
|
||||
found=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (found==true) break;
|
||||
}
|
||||
if (!found) {
|
||||
to_erase.push_back(it->second.index());
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned int i=0; i< to_erase.size(); ++i){
|
||||
c.erase_atom(to_erase[i]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
std::ofstream out(output_file.c_str());
|
||||
if (!out) {
|
||||
std::cerr << "Error opening output file " << output_file << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
pdb.write(out);
|
||||
//delete[] buf;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -1,205 +0,0 @@
|
|||
/* Copyright 2004
|
||||
Stanford University
|
||||
|
||||
This file is part of the DSR PDB Library.
|
||||
|
||||
The DSR PDB Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The DSR PDB Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the DSR PDB Library; see the file LICENSE.LGPL. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include <CGAL/PDB/PDB.h>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <cctype>
|
||||
#include <boost/program_options.hpp>
|
||||
|
||||
/*!
|
||||
\example pdb_split.cc
|
||||
|
||||
This example shows how to split a pdb file various ways. A pdb can
|
||||
be split into different models, chains or event cut a particular
|
||||
chain.
|
||||
*/
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
bool split_chains=false;
|
||||
std::string input_file, output_template;
|
||||
int split_domain=-1;
|
||||
bool print_help=false;
|
||||
bool verbose=false;
|
||||
char split_chain='\0';
|
||||
|
||||
boost::program_options::options_description o("Allowed options"), po, ao;
|
||||
o.add_options()
|
||||
("help", boost::program_options::bool_switch(&print_help),
|
||||
"produce help message")
|
||||
("verbose,v", boost::program_options::bool_switch(&verbose),
|
||||
"print out verbose messages about reading and writing pdb files")
|
||||
("split-chains,c", boost::program_options::bool_switch(&split_chains),
|
||||
"Split all chains into separate files.")
|
||||
("select-chain,C", boost::program_options::value<char>(&split_chain),
|
||||
"Select this chain only.")
|
||||
("domain-split,s", boost::program_options::value<int>(&split_domain),
|
||||
"Split a chain into domains at this residue.");
|
||||
po.add_options()
|
||||
("input-pdb", boost::program_options::value< std::string>(&input_file),
|
||||
"input file")
|
||||
("output-pdb-template", boost::program_options::value< std::string>(&output_template),
|
||||
"A sprintf style string that will be used to generate the names for the output files.");
|
||||
|
||||
ao.add(o).add(po);
|
||||
|
||||
boost::program_options::positional_options_description p;
|
||||
p.add("input-pdb", 1);
|
||||
p.add("output-pdb-template", 2);
|
||||
|
||||
boost::program_options::variables_map vm;
|
||||
boost::program_options::store(boost::program_options::command_line_parser(argc, argv).
|
||||
options(ao).positional(p).run(), vm);
|
||||
boost::program_options::notify(vm);
|
||||
|
||||
|
||||
|
||||
//boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm);
|
||||
//boost::program_options::notify(vm);
|
||||
|
||||
if (input_file.empty()
|
||||
|| output_template.empty()
|
||||
|| (split_chains && split_chain != '\0')
|
||||
|| (split_chains && split_domain != -1)
|
||||
|| (split_chain != '\0' && split_domain != -1)
|
||||
|| print_help) {
|
||||
std::cout << "This program splits a pdb file with multiple models or multiple domains into multiple files each with one model .\n";
|
||||
std::cout << "useage: " << argv[0]
|
||||
<< " [-c] input-pdb template%d[%c].pdb\n" << std::endl;
|
||||
std::cout << "The second argument is an sprintf style string that will be used to generate the names for the output files.\n\n";
|
||||
std::cout << o << "\n";
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (split_chain != '\0'){
|
||||
std::cout << "Splitting on chain " << split_chain << std::endl;
|
||||
} else if (split_domain != -1) {
|
||||
std::cout << "Splitting on residue " << split_domain << std::endl;
|
||||
} else {
|
||||
std::cout << "Splitting into chains " << std::endl;
|
||||
}
|
||||
|
||||
|
||||
// std::cout << input_file << " " << output_template << " " << split_domain << " " << split_chains << std::endl;
|
||||
|
||||
std::ifstream in(input_file.c_str());
|
||||
if (!in) {
|
||||
std::cerr << "Error opening input file " << input_file << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
//= new char[strlen(argv[2]+1000)];
|
||||
CGAL_PDB_NS::PDB pdb(in, verbose);
|
||||
|
||||
std::cout << "Input PDB has " << pdb.number_of_models() << " models." << std::endl;
|
||||
|
||||
if (split_domain != -1 && pdb.number_of_models()!= 1){
|
||||
std::cerr << "Splitting a domain can only work if there is only one model and chain.\n";
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
for (unsigned int i=0; i< pdb.number_of_models(); ++i){
|
||||
const CGAL_PDB_NS::Model &m= pdb.model(i);
|
||||
if (split_chain != '\0' || split_chains || split_domain!= -1) {
|
||||
std::cout << "Model " << i << " has " << m.number_of_chains() << " chains."<< std::endl;
|
||||
if (split_domain != -1 && m.number_of_chains()!= 1){
|
||||
std::cerr << "Splitting a domain can only work if there is only one model and chain.\n";
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
for (unsigned int j=0; j< m.number_of_chains(); ++j){
|
||||
const CGAL_PDB_NS::Protein &p= m.chain(j);
|
||||
|
||||
if (split_chain != '\0') {
|
||||
if (p.chain() == split_chain || p.chain() == std::toupper(split_chain) ) {
|
||||
std::cout << "Writing chain " << p.chain() << std::endl;
|
||||
assert(split_domain ==-1);
|
||||
|
||||
std::ofstream out(output_template.c_str());
|
||||
CGAL_PDB_NS::PDB npdb;
|
||||
CGAL_PDB_NS::Model nm;
|
||||
nm.new_chain(p);
|
||||
npdb.new_model(nm);
|
||||
npdb.set_header(pdb.header_begin(), pdb.header_end());
|
||||
npdb.write(out);
|
||||
} else {
|
||||
std::cout << "Skipping chain " << p.chain() << std::endl;
|
||||
}
|
||||
} else if (split_chains) {
|
||||
std::cout << "Writing chain " << p.chain() << std::endl;
|
||||
assert(split_domain ==-1);
|
||||
char buf[100000];
|
||||
if (pdb.number_of_models()==1) {
|
||||
sprintf(buf, output_template.c_str(),p.chain());
|
||||
} else {
|
||||
sprintf(buf, output_template.c_str(), m.index(), p.chain());
|
||||
}
|
||||
std::ofstream out(buf);
|
||||
CGAL_PDB_NS::PDB npdb;
|
||||
CGAL_PDB_NS::Model nm;
|
||||
nm.new_chain(p);
|
||||
npdb.new_model(nm);
|
||||
npdb.set_header(pdb.header_begin(), pdb.header_end());
|
||||
npdb.write(out);
|
||||
} else {
|
||||
CGAL_PDB_NS::Protein ps[2]={CGAL_PDB_NS::Protein(), CGAL_PDB_NS::Protein()};
|
||||
for (CGAL_PDB_NS::Protein::Const_residues_iterator rit = p.residues_begin();
|
||||
rit != p.residues_end(); ++rit){
|
||||
//rit->write('c', std::cout);
|
||||
if (rit->index().to_index()
|
||||
< static_cast<unsigned int>(split_domain)){
|
||||
ps[0].new_residue(*rit);
|
||||
} else {
|
||||
ps[1].new_residue(*rit);
|
||||
}
|
||||
}
|
||||
|
||||
assert(ps[0].number_of_residues() + ps[1].number_of_residues()
|
||||
== p.number_of_residues());
|
||||
|
||||
for (unsigned int j=0; j< 2; ++j){
|
||||
std::cout << "Writing pdb with " << ps[j].number_of_residues() << " residues.\n";
|
||||
char buf[100000];
|
||||
sprintf(buf, output_template.c_str(), j);
|
||||
std::ofstream out(buf);
|
||||
CGAL_PDB_NS::PDB npdb;
|
||||
CGAL_PDB_NS::Model nm(0);
|
||||
nm.new_chain(ps[j]);
|
||||
npdb.new_model(nm);
|
||||
npdb.set_header(pdb.header_begin(), pdb.header_end());
|
||||
npdb.write(out);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
char buf[100000];
|
||||
sprintf(buf, argv[2], m.index());
|
||||
std::ofstream out(buf);
|
||||
CGAL_PDB_NS::PDB npdb;
|
||||
npdb.new_model(m);
|
||||
npdb.set_header(pdb.header_begin(), pdb.header_end());
|
||||
npdb.write(out);
|
||||
}
|
||||
}
|
||||
//delete[] buf;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
/* Copyright 2004
|
||||
Stanford University
|
||||
|
||||
This file is part of the DSR PDB Library.
|
||||
|
||||
The DSR PDB Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The DSR PDB Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the DSR PDB Library; see the file LICENSE.LGPL. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include <CGAL/PDB/PDB.h>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
std::string input_file;
|
||||
std::string output_file;
|
||||
bool print_help=false;
|
||||
bool verbose=false;
|
||||
|
||||
{
|
||||
boost::program_options::options_description o("Allowed options"), po, ao;
|
||||
o.add_options()
|
||||
("help", boost::program_options::bool_switch(&print_help), "produce help message")
|
||||
("verbose,v", boost::program_options::bool_switch(&verbose),
|
||||
"Print error messages from reading the pdb files.");
|
||||
po.add_options()
|
||||
("input-pdb", boost::program_options::value< std::string >(&input_file),
|
||||
"The input and output files.");
|
||||
|
||||
ao.add(o).add(po);
|
||||
|
||||
boost::program_options::positional_options_description p;
|
||||
p.add("input-pdb", -1);
|
||||
|
||||
boost::program_options::variables_map vm;
|
||||
boost::program_options::store(boost::program_options::command_line_parser(argc, argv).
|
||||
options(ao).positional(p).run(), vm);
|
||||
boost::program_options::notify(vm);
|
||||
|
||||
|
||||
if (print_help || input_file.empty()) {
|
||||
std::cout << "Print some statistics of a pdb file.\n";
|
||||
std::cout << "usage: " << argv[0] << " pdb_file.pdb\n";
|
||||
std::cout << o << "\n";
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
std::ifstream in(input_file.c_str());
|
||||
if (!in){
|
||||
std::cerr << "Error opening input file " << input_file << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
CGAL_PDB_NS::PDB inpdb(in, verbose);
|
||||
|
||||
std::cout << "PDB has " << inpdb.number_of_models() << " models." << std::endl;
|
||||
|
||||
for (CGAL_PDB_NS::PDB::Models_iterator mit= inpdb.models_begin(); mit != inpdb.models_end(); ++mit){
|
||||
CGAL_PDB_NS::Model m= *mit;
|
||||
std::cout << "Model has " << m.number_of_chains() << " chains." << std::endl;
|
||||
for (unsigned int i=0; i< m.number_of_chains(); ++i){
|
||||
std::cout << m.chain(i).chain() << " ";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -1,127 +0,0 @@
|
|||
/* Copyright 2004
|
||||
Stanford University
|
||||
|
||||
This file is part of the DSR PDB Library.
|
||||
|
||||
The DSR PDB Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The DSR PDB Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the DSR PDB Library; see the file LICENSE.LGPL. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include <CGAL/PDB/PDB.h>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include <CGAL/PDB/Transform.h>
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
std::string input_file, output_file;
|
||||
bool print_help=false;
|
||||
bool verbose=false;
|
||||
bool dali=false;
|
||||
bool matrix=false;
|
||||
|
||||
boost::program_options::options_description o("Allowed options"), po, ao;
|
||||
o.add_options()
|
||||
("help", boost::program_options::bool_switch(&print_help),
|
||||
"produce help message")
|
||||
("verbose,v", boost::program_options::bool_switch(&verbose),
|
||||
"print out any errors that occur during reading of the pdb file.");
|
||||
|
||||
po.add_options()
|
||||
("input-pdb", boost::program_options::value< std::string>(&input_file),
|
||||
"input file")
|
||||
("output-pdb", boost::program_options::value< std::string>(&output_file),
|
||||
"output file");
|
||||
ao.add(o).add(po);
|
||||
|
||||
boost::program_options::positional_options_description p;
|
||||
p.add("input-pdb", 1);
|
||||
p.add("output-pdb", 1);
|
||||
|
||||
boost::program_options::variables_map vm;
|
||||
boost::program_options::store(boost::program_options::command_line_parser(argc, argv).
|
||||
options(ao).positional(p).run(), vm);
|
||||
boost::program_options::notify(vm);
|
||||
|
||||
if (input_file.empty() || output_file.empty() || print_help || (dali && matrix)) {
|
||||
std::cout << "This program produces a pdb identical to the input but with no sidechains.\n";
|
||||
std::cout << "usage: " << argv[0] << " input-pdb output-pdb\n\n";
|
||||
std::cout << o << "\n";
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// std::cout << input_file << " " << output_template << " " << split_domain << " " << split_chains << std::endl;
|
||||
|
||||
|
||||
|
||||
//= new char[strlen(argv[2]+1000)];
|
||||
|
||||
|
||||
std::ifstream in(input_file.c_str());
|
||||
if (!in) {
|
||||
std::cerr << "Error opening output file " << input_file << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
CGAL_PDB_NS::PDB pdb(in, verbose);
|
||||
|
||||
if (verbose) std::cout << "Input PDB has " << pdb.number_of_models() << " models." << std::endl;
|
||||
|
||||
CGAL_PDB_NS::PDB outpdb;
|
||||
|
||||
for (unsigned int i=0;i< pdb.number_of_models(); ++i){
|
||||
CGAL_PDB_NS::Model &m= pdb.model(i);
|
||||
CGAL_PDB_NS::Model om;
|
||||
|
||||
std::cout << "Model " << i << " has " << m.number_of_chains() << " chains."<< std::endl;
|
||||
for (unsigned int j=0; j< m.number_of_chains(); ++j){
|
||||
CGAL_PDB_NS::Protein &p= m.chain(j);
|
||||
CGAL_PDB_NS::Protein op;
|
||||
for (CGAL_PDB_NS::Protein::Residues_iterator rit= p.residues_begin(); rit != p.residues_end(); ++rit){
|
||||
CGAL_PDB_NS::Residue nr(rit->type());
|
||||
nr.set_index(rit->index());
|
||||
if (rit->has_atom(CGAL_PDB_NS::Residue::AL_N)) {
|
||||
nr.set_atom(CGAL_PDB_NS::Residue::AL_N, rit->atom(CGAL_PDB_NS::Residue::AL_N));
|
||||
}
|
||||
if (rit->has_atom(CGAL_PDB_NS::Residue::AL_CA)) {
|
||||
nr.set_atom(CGAL_PDB_NS::Residue::AL_CA, rit->atom(CGAL_PDB_NS::Residue::AL_CA));
|
||||
}
|
||||
if (rit->has_atom(CGAL_PDB_NS::Residue::AL_C)) {
|
||||
nr.set_atom(CGAL_PDB_NS::Residue::AL_C, rit->atom(CGAL_PDB_NS::Residue::AL_C));
|
||||
}
|
||||
op.new_residue(nr);
|
||||
}
|
||||
om.new_chain(op);
|
||||
}
|
||||
outpdb.new_model(om);
|
||||
}
|
||||
|
||||
std::ofstream out(output_file.c_str());
|
||||
if (!out) {
|
||||
std::cerr << "Error opening output file " << output_file << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
outpdb.write(out);
|
||||
|
||||
//delete[] buf;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
/* Copyright 2004
|
||||
Stanford University
|
||||
|
||||
This file is part of the DSR PDB Library.
|
||||
|
||||
The DSR PDB Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The DSR PDB Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the DSR PDB Library; see the file LICENSE.LGPL. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include <CGAL/PDB/PDB.h>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <CGAL/PDB/cgal.h>
|
||||
#include <iterator>
|
||||
#include <CGAL/Simple_cartesian.h>
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
std::string input_file;
|
||||
std::string output_file;
|
||||
bool print_help=false;
|
||||
bool verbose=false;
|
||||
|
||||
{
|
||||
boost::program_options::options_description o("Allowed options"), po, ao;
|
||||
o.add_options()
|
||||
("help", boost::program_options::bool_switch(&print_help), "produce help message")
|
||||
("verbose,v", boost::program_options::bool_switch(&verbose),
|
||||
"Print error messages from reading the pdb files.");
|
||||
po.add_options()
|
||||
("input-pdb", boost::program_options::value< std::string >(&input_file),
|
||||
"The input file.")
|
||||
("output-spheres", boost::program_options::value< std::string >(&output_file),
|
||||
"The output file.");
|
||||
|
||||
ao.add(o).add(po);
|
||||
|
||||
boost::program_options::positional_options_description p;
|
||||
p.add("input-pdb", 1);
|
||||
p.add("output-spheres", 1);
|
||||
|
||||
boost::program_options::variables_map vm;
|
||||
boost::program_options::store(boost::program_options::command_line_parser(argc, argv).
|
||||
options(ao).positional(p).run(), vm);
|
||||
boost::program_options::notify(vm);
|
||||
|
||||
|
||||
if (input_file.empty() || output_file.empty() || print_help) {
|
||||
std::cout << "Read a PDB file and write spheres:\n# num_spheres \nx y z r\n...\nto the output file.\n";
|
||||
std::cout << "usage: " << argv[0] << " input.pdb output.spheres\n";
|
||||
std::cout << o << "\n";
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
std::ifstream in(input_file.c_str());
|
||||
if (!in){
|
||||
std::cerr << "Error opening input file " << input_file << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
CGAL_PDB_NS::PDB inpdb(in, verbose);
|
||||
|
||||
std::ofstream out(output_file.c_str());
|
||||
if (!out) {
|
||||
std::cerr<< "Error opening output file: " << output_file << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
typedef CGAL::Simple_cartesian<double> K;
|
||||
|
||||
CGAL_PDB_NS::all_spheres<K>(inpdb.model(0), std::ostream_iterator<K::Sphere_3>(out, "\n"));
|
||||
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -1,222 +0,0 @@
|
|||
/* Copyright 2004
|
||||
Stanford University
|
||||
|
||||
This file is part of the DSR PDB Library.
|
||||
|
||||
The DSR PDB Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The DSR PDB Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the DSR PDB Library; see the file LICENSE.LGPL. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include <CGAL/PDB/PDB.h>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include <CGAL/PDB/Transform.h>
|
||||
#include <CGAL/PDB/transforms.h>
|
||||
#include <CGAL/PDB/align.h>
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
std::string input_file, output_file;
|
||||
bool print_help=false;
|
||||
bool verbose=false;
|
||||
bool dali=false;
|
||||
bool matrix=false;
|
||||
bool simple=false;
|
||||
std::string refine;
|
||||
|
||||
boost::program_options::options_description o("Allowed options"), po, ao;
|
||||
o.add_options()
|
||||
("help", boost::program_options::bool_switch(&print_help),
|
||||
"produce help message")
|
||||
("dali,d", boost::program_options::bool_switch(&dali),
|
||||
"Use a DALI transformation matrix as pasted from an email from DALI.")
|
||||
("matrix,m", boost::program_options::bool_switch(&matrix),
|
||||
"Enter a single transformation matrix.")
|
||||
("simplified-input,s", boost::program_options::bool_switch(&simple),
|
||||
"Enter a translation vector and a quaternion (3 components).")
|
||||
("refine,r", boost::program_options::value(&refine),
|
||||
"refine the alignment relative to some pdb file.")
|
||||
("verbose,v", boost::program_options::bool_switch(&verbose),
|
||||
"print out any errors that occur during reading of the pdb file.");
|
||||
|
||||
po.add_options()
|
||||
("input-pdb", boost::program_options::value< std::string>(&input_file),
|
||||
"input file")
|
||||
("output-pdb", boost::program_options::value< std::string>(&output_file),
|
||||
"output file");
|
||||
ao.add(o).add(po);
|
||||
|
||||
boost::program_options::positional_options_description p;
|
||||
p.add("input-pdb", 1);
|
||||
p.add("output-pdb", 1);
|
||||
|
||||
boost::program_options::variables_map vm;
|
||||
boost::program_options::store(boost::program_options::command_line_parser(argc, argv).
|
||||
options(ao).positional(p).run(), vm);
|
||||
boost::program_options::notify(vm);
|
||||
|
||||
if (input_file.empty() || output_file.empty() || print_help || (dali && matrix)) {
|
||||
std::cout << "This program transforms a pdb file by reading a transformation"
|
||||
<< " matrix. The matrix is either specified by pasting the transform lines"
|
||||
<< " from a DALI email, entering a 4x4 transformation matrix (with a"
|
||||
<< " coordinate ordering x,y,z,w) or as separate rotational and "
|
||||
<< " translational components.\n";
|
||||
std::cout << "usage: " << argv[0] << " input-pdb output-pdb\n\n";
|
||||
std::cout << o << "\n";
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
// std::cout << input_file << " " << output_template << " " << split_domain << " " << split_chains << std::endl;
|
||||
|
||||
|
||||
|
||||
//= new char[strlen(argv[2]+1000)];
|
||||
|
||||
|
||||
|
||||
CGAL_PDB_NS::Transform t; //(rot, trans);
|
||||
|
||||
if (dali) {
|
||||
double rot[3][3];
|
||||
double trans[3];
|
||||
// const char format[]="%d: %d %s %s %le %le %le %le"
|
||||
const char format[]="%le %le %le %le";
|
||||
for (unsigned int i=0; i< 3; ++i){
|
||||
char buf[1000];
|
||||
std::cin.getline(buf, 1000);
|
||||
if (sscanf(buf+27, format, &rot[i][0], &rot[i][1], &rot[i][2], &trans[i]) != 4) {
|
||||
std::cerr << "Error parsing Dali matrix.\n";
|
||||
return EXIT_FAILURE;
|
||||
};
|
||||
//std::cin >> n >> jc >> js >> js >> x >> y >> z >> t;
|
||||
//std::cout << x << " " << y << " " << z << " " << t << std::endl;
|
||||
}
|
||||
t= CGAL_PDB_NS::Transform(rot, trans);
|
||||
} else if (matrix) {
|
||||
double rot[3][3];
|
||||
double trans[3];
|
||||
const char format[]="%le %le %le %le";
|
||||
for (unsigned int i=0; i< 4; ++i){
|
||||
char buf[1000];
|
||||
std::cin.getline(buf, 1000);
|
||||
if (sscanf(buf, format, &rot[i][0], &rot[i][1], &rot[i][2], &trans[i]) != 4) {
|
||||
std::cerr << "Error parsing matrix, expected 4 floats.\n";
|
||||
return EXIT_FAILURE;
|
||||
};
|
||||
}
|
||||
t= CGAL_PDB_NS::Transform(rot, trans);
|
||||
} else if (simple) {
|
||||
bool done=false;
|
||||
double x,y,z, q1, q2, q3;
|
||||
do {
|
||||
std::cout << "Please enter transformation as \"x y z q1 q2 q3\": " << std::flush;
|
||||
char buf[1000];
|
||||
std::cin.getline(buf, 1000);
|
||||
if (sscanf(buf, "%le %le %le %le %le %le", &x, &y, &z, &q1, &q2, &q3) ==6) {
|
||||
done=true;
|
||||
}
|
||||
} while (!done);
|
||||
|
||||
CGAL_PDB_NS::Quaternion q(q1, q2, q3);
|
||||
CGAL_PDB_NS::Vector v(x,y,z);
|
||||
t= CGAL_PDB_NS::Transform(v, q);
|
||||
|
||||
} else if (matrix) {
|
||||
double rot[3][3];
|
||||
double trans[3];
|
||||
std::cout << "Rotation:\n";
|
||||
std::cout << "> " << std::flush;
|
||||
for (unsigned int i=0; i< 3; ++i){
|
||||
char buf[1000];
|
||||
std::cin.getline(buf, 1000);
|
||||
if (sscanf(buf, "%le %le %le", &rot[i][0], &rot[i][1], &rot[i][2]) != 3) {
|
||||
std::cerr << "Error parsing rotation matrix, expected 3 floats.\n";
|
||||
return EXIT_FAILURE;
|
||||
};
|
||||
if (i != 2) {
|
||||
std::cout << "> " << std::flush;
|
||||
}
|
||||
}
|
||||
std::cout << "Translation:\n";
|
||||
std::cout << "> "<< std::flush;
|
||||
char buf[1000];
|
||||
std::cin.getline(buf, 1000);
|
||||
if (sscanf(buf, "%le %le %le", &trans[0], &trans[1], &trans[2]) != 3) {
|
||||
std::cerr << "Error parsing translation, expected 3 floats.\n";
|
||||
return EXIT_FAILURE;
|
||||
};
|
||||
t= CGAL_PDB_NS::Transform(rot, trans);
|
||||
}
|
||||
|
||||
std::cout << t;
|
||||
std::ifstream in(input_file.c_str());
|
||||
if (!in) {
|
||||
std::cerr << "Error opening input file " << input_file << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
CGAL_PDB_NS::PDB pdb(in, verbose);
|
||||
|
||||
if (verbose) std::cout << "Input PDB has " << pdb.number_of_models() << " models." << std::endl;
|
||||
|
||||
for (unsigned int i=0;i< pdb.number_of_models(); ++i){
|
||||
CGAL_PDB_NS::Model &m= pdb.model(i);
|
||||
std::cout << "Model " << i << " has " << m.number_of_chains() << " chains."<< std::endl;
|
||||
for (unsigned int j=0; j< m.number_of_chains(); ++j){
|
||||
CGAL_PDB_NS::Protein &p= m.chain(j);
|
||||
for (CGAL_PDB_NS::Protein::Residues_iterator rit= p.residues_begin(); rit != p.residues_end(); ++rit){
|
||||
for (CGAL_PDB_NS::Residue::Atoms_iterator ait= rit->atoms_begin(); ait != rit->atoms_end(); ++ait){
|
||||
ait->second.set_cartesian_coords(t(ait->second.cartesian_coords()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!refine.empty()) {
|
||||
std::ifstream rin(refine.c_str());
|
||||
if (!rin) {
|
||||
std::cerr << "Error opening input file " << refine << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
std::cout << "Refining against " << refine << std::endl;
|
||||
|
||||
CGAL_PDB_NS::PDB rpdb(rin, verbose);
|
||||
|
||||
for (unsigned int i=0;i< pdb.number_of_models(); ++i){
|
||||
CGAL_PDB_NS::Model &m= pdb.model(i);
|
||||
CGAL_PDB_NS::Model &rm= rpdb.model((std::min)(rpdb.number_of_models(),
|
||||
static_cast<size_t>(i)));
|
||||
for (unsigned int j=0; j< m.number_of_chains(); ++j){
|
||||
CGAL_PDB_NS::Protein &p= m.chain(j);
|
||||
CGAL_PDB_NS::Protein &rp= rm.chain(j);
|
||||
CGAL_PDB_NS::refine_alignment_of_second_protein_to_first(rp,p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::ofstream out(output_file.c_str());
|
||||
if (!out) {
|
||||
std::cerr << "Error opening output file " << output_file << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
pdb.write(out);
|
||||
|
||||
//delete[] buf;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
test/PDB/check_refine_alignment.cpp
|
||||
|
||||
|
|
@ -1,185 +0,0 @@
|
|||
/* Copyright 2004
|
||||
Stanford University
|
||||
|
||||
This file is part of the DSR PDB Library.
|
||||
|
||||
The DSR PDB Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The DSR PDB Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the DSR PDB Library; see the file LICENSE.LGPL. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#ifndef DSR_PDB_ATOM_H
|
||||
#define DSR_PDB_ATOM_H
|
||||
#include <CGAL/PDB/basic.h>
|
||||
#include <CGAL/PDB/Point.h>
|
||||
#include <CGAL/Tools/Label.h>
|
||||
#include <string>
|
||||
CGAL_PDB_BEGIN_NAMESPACE
|
||||
//! A class repesenting an atom.
|
||||
class Atom {
|
||||
friend class Residue;
|
||||
public:
|
||||
//! The type to represent the atoms index in the PDB file.
|
||||
typedef CGAL::Label<Atom> Index;
|
||||
|
||||
//! The type (element) of an atom. The currently supported types are C,N,H,O,S, INVALID
|
||||
enum Type {INVALID=0, C,N,H,O, S, FE, PT};
|
||||
|
||||
//! Construct and invalid atom
|
||||
inline Atom();
|
||||
//! The int index of the atom (atom number in a PDB -1)
|
||||
/*!
|
||||
\note these are 0 based, and the PDB is 1 based, so this is the PDB index -1
|
||||
*/
|
||||
inline Index index() const;
|
||||
//! Set the index
|
||||
inline void set_index(Index i);
|
||||
//inline Atom_label label() const;
|
||||
//! Cartesian coordinates (x,y,z) for the atom.
|
||||
inline const Point &cartesian_coords() const;
|
||||
//! Set the cartesian coordinates.
|
||||
inline void set_cartesian_coords(const Point &pt);
|
||||
inline bool operator<(const Atom &o) const;
|
||||
inline bool operator==(const Atom& al) const;
|
||||
inline bool operator!=(const Atom& al) const;
|
||||
//! The PDB occupancy field.
|
||||
inline float occupancy() const ;
|
||||
//! Set the PDB occupancy field.
|
||||
inline void set_occupancy(float o);
|
||||
//! The PDB temperature factor field.
|
||||
inline float temperature_factor() const;
|
||||
//! Set the PDB temperature factor field.
|
||||
inline void set_temperature_factor(float f);
|
||||
//! The PDB segment ID char
|
||||
inline const char *segment_id() const;
|
||||
//! Set the PDB segment ID char.
|
||||
inline void set_segment_id(const char *c);
|
||||
//! The PDB element field
|
||||
inline const char* element() const;
|
||||
//! Set the element.
|
||||
inline void set_element(const char *c);
|
||||
//! The PDB charge field.
|
||||
inline const char *charge() const;
|
||||
//! Set the PDB charge field value.
|
||||
inline void set_charge(const char*c);
|
||||
//! The type of the atoms (basically what element).
|
||||
inline Type type() const;
|
||||
//! Set the element.
|
||||
inline void set_type(Type t);
|
||||
//! Returns the van der Waals radius of the atom.
|
||||
/*! Values take from the wikipedia so beware.
|
||||
*/
|
||||
inline double radius() const;
|
||||
|
||||
static Type string_to_type(const char *c);
|
||||
protected:
|
||||
Index index_;
|
||||
Type type_;
|
||||
Point coordinates_;
|
||||
float occupancy_, temp_factor_;
|
||||
std::string segID_, element_, charge_;
|
||||
static double radii_[];
|
||||
};
|
||||
|
||||
inline Atom::Index Atom::index() const {
|
||||
assert(index_ != Atom::Index());
|
||||
return index_;
|
||||
}
|
||||
|
||||
inline void Atom::set_index(Atom::Index i) {
|
||||
assert(i != Atom::Index());
|
||||
index_=i;
|
||||
}
|
||||
|
||||
inline Atom::Type Atom::type() const {return type_;}
|
||||
|
||||
inline void Atom::set_type(Atom::Type t) {type_=t;}
|
||||
|
||||
inline const Point &Atom::cartesian_coords() const {
|
||||
return coordinates_;
|
||||
}
|
||||
|
||||
inline void Atom::set_cartesian_coords(const Point &pt){
|
||||
coordinates_=pt;
|
||||
}
|
||||
|
||||
inline bool Atom::operator<(const Atom &o) const {
|
||||
if (index_ < o.index_) return true;
|
||||
else if (index_ > o.index_) return false;
|
||||
else return type_ < o.type_;
|
||||
}
|
||||
|
||||
inline bool Atom::operator==(const Atom &o) const {
|
||||
if (index_ != o.index_) return false;
|
||||
else return type_ == o.type_;
|
||||
}
|
||||
|
||||
inline bool Atom::operator!=(const Atom &o) const {
|
||||
return !operator==(o);
|
||||
}
|
||||
|
||||
inline float Atom::occupancy() const {
|
||||
return occupancy_;
|
||||
}
|
||||
|
||||
inline void Atom::set_occupancy(float o) {
|
||||
occupancy_=o;
|
||||
}
|
||||
|
||||
inline float Atom::temperature_factor() const {
|
||||
return temp_factor_;
|
||||
}
|
||||
|
||||
inline void Atom::set_temperature_factor(float f) {
|
||||
temp_factor_=f;
|
||||
}
|
||||
|
||||
inline const char *Atom::segment_id() const {
|
||||
return segID_.c_str();
|
||||
}
|
||||
|
||||
inline void Atom::set_segment_id(const char *c) {
|
||||
segID_=c;
|
||||
}
|
||||
|
||||
inline const char* Atom::element() const {
|
||||
return element_.c_str();
|
||||
}
|
||||
|
||||
inline void Atom::set_element(const char *c) {
|
||||
element_=c;
|
||||
}
|
||||
|
||||
inline const char *Atom::charge() const {
|
||||
return charge_.c_str();
|
||||
}
|
||||
|
||||
inline void Atom::set_charge(const char*c) {
|
||||
charge_=c;
|
||||
}
|
||||
|
||||
inline Atom::Atom(): type_(Atom::INVALID) {
|
||||
}
|
||||
|
||||
inline double Atom::radius() const {
|
||||
return radii_[type()];
|
||||
}
|
||||
|
||||
/*Atom::Atom(Atom_label label): label_(label){
|
||||
index_=0;
|
||||
occupancy_=1.0; temp_factor_=0.0;
|
||||
}*/
|
||||
|
||||
|
||||
CGAL_PDB_END_NAMESPACE
|
||||
#endif
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
#ifndef CGAL_DSRPDB_MATRIX_H
|
||||
#define CGAL_DSRPDB_MATRIX_H
|
||||
#include <CGAL/PDB/basic.h>
|
||||
#include <CGAL/PDB/internal/tnt/tnt_array2d.h>
|
||||
|
||||
CGAL_PDB_BEGIN_NAMESPACE
|
||||
//! Use TNT::Array2D<double> as a matrix
|
||||
typedef TNT::Array2D<double> Matrix;
|
||||
CGAL_PDB_END_NAMESPACE
|
||||
#endif
|
||||
|
|
@ -1,123 +0,0 @@
|
|||
/* Copyright 2004
|
||||
Stanford University
|
||||
|
||||
This file is part of the DSR PDB Library.
|
||||
|
||||
The DSR PDB Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The DSR PDB Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the DSR PDB Library; see the file LICENSE.LGPL. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#ifndef DSR_MODEL_H_
|
||||
#define DSR_MODEL_H_
|
||||
#include <CGAL/PDB/Protein.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
CGAL_PDB_BEGIN_NAMESPACE
|
||||
|
||||
class PDB;
|
||||
|
||||
//! A class representing a single model from a PDB file.
|
||||
/*!
|
||||
You can iterator through the chains and soon the heterogens.
|
||||
*/
|
||||
class Model {
|
||||
friend class PDB;
|
||||
public:
|
||||
//! Construct an empty model
|
||||
Model();
|
||||
//! Construct an empty model with a number
|
||||
Model(unsigned int i);
|
||||
|
||||
//! The number of strands
|
||||
size_t number_of_chains() const;
|
||||
//! get the ith strand
|
||||
Protein &chain(unsigned int i);
|
||||
//! get the ith strand
|
||||
const Protein &chain(unsigned int i) const;
|
||||
|
||||
//! add a strand
|
||||
void new_chain(const Protein &p);
|
||||
|
||||
//! write to a pdb
|
||||
void write(std::ostream &out) const;
|
||||
|
||||
//! return the index or -1 if it is not valid
|
||||
int index() const{return index_;}
|
||||
|
||||
//! set the index
|
||||
void set_index(int ind) {index_=ind;}
|
||||
|
||||
typedef std::vector<Protein>::const_iterator Const_chains_iterator;
|
||||
//! Begin iterating through the chains.
|
||||
Const_chains_iterator chains_begin() const {
|
||||
return chains_.begin();
|
||||
}
|
||||
//! End iterating through the chains.
|
||||
Const_chains_iterator chains_end() const {
|
||||
return chains_.end();
|
||||
}
|
||||
|
||||
class Hetatom_data {
|
||||
public:
|
||||
Hetatom_data(const char *rnm,
|
||||
const char *anm, int rn, char ch): resname_(rnm),
|
||||
atomname_(anm),
|
||||
rnum_(rn), chain_(ch){
|
||||
}
|
||||
const char *molecule_name() const {
|
||||
return resname_.c_str();
|
||||
}
|
||||
const char *atom_name() const {
|
||||
return atomname_.c_str();
|
||||
}
|
||||
int molecule_number() const {
|
||||
return rnum_;
|
||||
}
|
||||
char chain() const {
|
||||
return chain_;
|
||||
}
|
||||
protected:
|
||||
std::string resname_;
|
||||
std::string atomname_;
|
||||
int rnum_;
|
||||
char chain_;
|
||||
|
||||
};
|
||||
|
||||
//! An iterator through CGAL::PDB::Atom values for the HETATM records.
|
||||
typedef std::vector<std::pair<Hetatom_data, Atom> >::const_iterator Const_hetatoms_iterator;
|
||||
//! Begin iterating through CGAL:PDB::Atom values for the HETATM records.
|
||||
Const_hetatoms_iterator hetatoms_begin() const {
|
||||
return hetatoms_.begin();
|
||||
}
|
||||
Const_hetatoms_iterator hetatoms_end() const {
|
||||
return hetatoms_.end();
|
||||
}
|
||||
|
||||
//! The number of hetatoms
|
||||
unsigned int hetatoms_size() const {
|
||||
return hetatoms_.size();
|
||||
}
|
||||
protected:
|
||||
void process_line(const char *c);
|
||||
|
||||
std::vector<std::string> extra_;
|
||||
std::vector<Protein> chains_;
|
||||
std::vector<std::pair<Hetatom_data, Atom> > hetatoms_;
|
||||
int index_;
|
||||
};
|
||||
|
||||
CGAL_PDB_END_NAMESPACE
|
||||
#endif
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
/* Copyright 2004
|
||||
Stanford University
|
||||
|
||||
This file is part of the DSR PDB Library.
|
||||
|
||||
The DSR PDB Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The DSR PDB Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the DSR PDB Library; see the file LICENSE.LGPL. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#ifndef CGAL_DSR_PDB_H
|
||||
#define CGAL_DSR_PDB_H
|
||||
|
||||
#include <CGAL/PDB/basic.h>
|
||||
#include <CGAL/PDB/Model.h>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
CGAL_PDB_BEGIN_NAMESPACE
|
||||
|
||||
//! A class for representing a whole PDB file with possibly several models.
|
||||
/*! See pdb_split.cc for an example manipulating a PDB by splitting
|
||||
it into parts.
|
||||
*/
|
||||
class PDB {
|
||||
public:
|
||||
//! Read a pdb file from the stream
|
||||
/*! The optional bool controls whether errors (such as unparsable
|
||||
PDB lines). Set it to false to disable printing errors.
|
||||
*/
|
||||
PDB(std::istream &in, bool print_errors=false);
|
||||
//! Construct a empty PDB
|
||||
PDB();
|
||||
~PDB();
|
||||
|
||||
//! Write a pdb file to the stream
|
||||
void write(std::ostream &out) const;
|
||||
|
||||
//! get the ith model
|
||||
const Model &model(unsigned int i) const;
|
||||
//! get the ith model
|
||||
Model &model(unsigned int i);
|
||||
//! set a model
|
||||
void new_model(const Model &m);
|
||||
//! how many models are there?
|
||||
size_t number_of_models() const;
|
||||
|
||||
typedef std::vector<std::string>::const_iterator Header_iterator;
|
||||
//! iterator through the lines of the header
|
||||
Header_iterator header_begin() const;
|
||||
//! end iterator
|
||||
Header_iterator header_end() const;
|
||||
|
||||
//! Set the header
|
||||
template <class It>
|
||||
void set_header(It b, It e){
|
||||
header_.clear();
|
||||
header_.insert(header_.end(), b,e);
|
||||
}
|
||||
|
||||
//! iterator for models
|
||||
typedef std::vector<Model>::const_iterator Const_models_iterator;
|
||||
//! non-const iterator for models
|
||||
typedef std::vector<Model>::iterator Models_iterator;
|
||||
|
||||
Const_models_iterator models_begin() const {
|
||||
return models_.begin();
|
||||
}
|
||||
Const_models_iterator models_end() const {
|
||||
return models_.end();
|
||||
}
|
||||
Models_iterator models_begin() {
|
||||
return models_.begin();
|
||||
}
|
||||
Models_iterator models_end() {
|
||||
return models_.end();
|
||||
}
|
||||
protected:
|
||||
void load(std::istream &in, bool print_errors);
|
||||
|
||||
std::vector<std::string> header_;
|
||||
std::vector<Model> models_;
|
||||
};
|
||||
|
||||
CGAL_PDB_END_NAMESPACE
|
||||
#endif
|
||||
|
|
@ -1,152 +0,0 @@
|
|||
/* Copyright 2004
|
||||
Stanford University
|
||||
|
||||
This file is part of the DSR PDB Library.
|
||||
|
||||
The DSR PDB Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The DSR PDB Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the DSR PDB Library; see the file LICENSE.LGPL. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#ifndef CGAL_DSR_PDB_POINT_H
|
||||
#define CGAL_DSR_PDB_POINT_H
|
||||
#include <CGAL/PDB/basic.h>
|
||||
#include <iostream>
|
||||
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/squared_distance_3.h>
|
||||
|
||||
CGAL_PDB_BEGIN_NAMESPACE
|
||||
// An alternative point class.
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel::Point_3 Point;
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel::Vector_3 Vector;
|
||||
|
||||
struct Squared_distance{
|
||||
double operator()(const Point &a, const Point &b) const {
|
||||
return CGAL::squared_distance(a,b);
|
||||
}
|
||||
};
|
||||
|
||||
//! Functor to compute the squared norm of a Vector
|
||||
struct Squared_norm{
|
||||
double operator()(const Vector &v) const {
|
||||
return v.x()*v.x()+v.y()*v.y()+ v.z()*v.z();
|
||||
}
|
||||
};
|
||||
|
||||
//! Functor to compute the cross product of two vectors
|
||||
struct Cross_product{
|
||||
Vector operator()(const Vector &a, const Vector &b) const {
|
||||
double x = a.y() * b.z() - b.y() * a.z();
|
||||
double y = a.z() * b.x() - b.z() * a.x();
|
||||
double z = a.x() * b.y() - b.x() * a.y();
|
||||
|
||||
return Vector(x,y,z);
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
This class represents a point in spherical coordinates.
|
||||
*/
|
||||
struct Spherical_point{
|
||||
//! Construct a spherical point from coordinates.
|
||||
Spherical_point(double r, double theta, double phi) {
|
||||
phi_=phi;
|
||||
theta_=theta;
|
||||
r_=r;
|
||||
}
|
||||
|
||||
//! Construct a point from a vector.
|
||||
Spherical_point(const Vector &v) {
|
||||
double xy2=v.x()*v.x()+v.y()*v.y();
|
||||
double sd= std::sqrt(xy2+v.z()*v.z());
|
||||
r_=sd;
|
||||
theta_= std::atan2(v.y(), v.x());
|
||||
double xy=std::sqrt(xy2);
|
||||
phi_= std::atan2(v.z(), xy);
|
||||
}
|
||||
|
||||
Spherical_point(){}
|
||||
|
||||
//! The r component.
|
||||
double r() const {
|
||||
return r_;
|
||||
}
|
||||
|
||||
|
||||
//! The polar angle.
|
||||
double phi() const {
|
||||
return phi_;
|
||||
}
|
||||
|
||||
//! The azimuthal angle in the x-y plane.
|
||||
double theta() const {
|
||||
return theta_;
|
||||
}
|
||||
|
||||
private:
|
||||
double phi_, theta_, r_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
//! Construct a spherical point with a certain axis.
|
||||
/*! \note This class is poorly designed having two completely
|
||||
separate usages just sharing internal code.
|
||||
*/
|
||||
struct Construct_spherical_point{
|
||||
Construct_spherical_point(const Vector &xaxis,
|
||||
const Vector &zaxis){
|
||||
make_axis(xaxis, zaxis);
|
||||
base_=Point(0,0,0);
|
||||
}
|
||||
|
||||
Construct_spherical_point(const Point &p,
|
||||
const Point &pop,
|
||||
const Point &popop){
|
||||
base_=p;
|
||||
make_axis(p-pop, popop-pop);
|
||||
}
|
||||
|
||||
//! Construct the spherical coordinates of a vector.
|
||||
Spherical_point operator()(const Vector &v) const {
|
||||
double vz= v*z_;
|
||||
double vx= v*x_;
|
||||
double vy= v*y_;
|
||||
return Spherical_point(vx, vy, vz);
|
||||
};
|
||||
|
||||
//! Construct the spherical coordinates of a point relative to the base passed in the constructor.
|
||||
Spherical_point operator()(const Point &p) const {
|
||||
return operator()(p-base_);
|
||||
}
|
||||
|
||||
private:
|
||||
void make_axis(const Vector &xaxis,
|
||||
const Vector &zaxis){
|
||||
Squared_norm sn;
|
||||
z_= zaxis/sn(zaxis);
|
||||
Vector xmz= xaxis- (xaxis*z_)*z_;
|
||||
x_= xmz/sn(xmz);
|
||||
Cross_product cp;
|
||||
y_= cp(z_, x_);
|
||||
}
|
||||
|
||||
Vector z_;
|
||||
Vector x_;
|
||||
Vector y_;
|
||||
Point base_;
|
||||
};
|
||||
|
||||
CGAL_PDB_END_NAMESPACE
|
||||
#endif
|
||||
|
|
@ -1,460 +0,0 @@
|
|||
/* Copyright 2004
|
||||
Stanford University
|
||||
|
||||
This file is part of the DSR PDB Library.
|
||||
|
||||
The DSR PDB Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The DSR PDB Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the DSR PDB Library; see the file LICENSE.LGPL. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#ifndef CGAL_DSR_PDB_PROTEIN_H
|
||||
#define CGAL_DSR_PDB_PROTEIN_H
|
||||
|
||||
#include <CGAL/PDB/basic.h>
|
||||
#include <CGAL/PDB/Point.h>
|
||||
#include <CGAL/PDB/Atom.h>
|
||||
#include <CGAL/PDB/Residue.h>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
CGAL_PDB_BEGIN_NAMESPACE
|
||||
|
||||
class Model;
|
||||
|
||||
//! A class representing a single chain of a protein.
|
||||
/*!
|
||||
It probably should be called chain, but it is not :-)
|
||||
*/
|
||||
class Protein {
|
||||
friend class Model;
|
||||
public:
|
||||
|
||||
/*!
|
||||
\example check_protein.cc
|
||||
*/
|
||||
|
||||
//! A chemical bond within the protein
|
||||
typedef std::pair<Atom::Index,Atom::Index> Bond;
|
||||
|
||||
/*! Build a protein from a pdb file.
|
||||
See check_protein.cc for an example of using this to read a
|
||||
pdb file.
|
||||
|
||||
The optional bool controls whether errors (such as unparsable
|
||||
PDB lines). Set it to false to disable printing errors.
|
||||
*/
|
||||
Protein(std::istream &in, bool print_errors=false);
|
||||
|
||||
//! Default
|
||||
Protein();
|
||||
|
||||
//! Return the chain id
|
||||
char chain() const;
|
||||
|
||||
//! Set the chain id.
|
||||
void set_chain(char c);
|
||||
|
||||
//! An iterator to go through all the residues
|
||||
typedef std::vector<Residue>::iterator Residues_iterator;
|
||||
//! Iterate through all the residues
|
||||
Residues_iterator residues_begin() {
|
||||
return residues_.begin();
|
||||
}
|
||||
//! End iterator through the residues.
|
||||
Residues_iterator residues_end() {
|
||||
return residues_.end();
|
||||
}
|
||||
//! Iterator for residues in order of addition.
|
||||
typedef std::vector<Residue>::const_iterator Const_residues_iterator;
|
||||
//! Begin iterating residues.
|
||||
Const_residues_iterator residues_begin() const {
|
||||
return residues_.begin();
|
||||
}
|
||||
//! End iterating residues.
|
||||
Const_residues_iterator residues_end() const {
|
||||
return residues_.end();
|
||||
}
|
||||
unsigned int number_of_residues() const {
|
||||
return residues_.size();
|
||||
}
|
||||
|
||||
void new_residue(const Residue &res);
|
||||
|
||||
//! An iterator to iterate through all the atoms of the protein
|
||||
class Atoms_iterator;
|
||||
//! Begin iterating through the atoms
|
||||
Atoms_iterator atoms_begin();
|
||||
//! End iterating through the atoms.
|
||||
Atoms_iterator atoms_end();
|
||||
|
||||
//! An iterator to iterate through all the atoms of the protein
|
||||
class Const_atoms_iterator;
|
||||
//! Begin iterating through the atoms
|
||||
Const_atoms_iterator atoms_begin() const;
|
||||
//! End iterating through the atoms.
|
||||
Const_atoms_iterator atoms_end() const;
|
||||
//! This is non-const time.
|
||||
unsigned int number_of_atoms() const;
|
||||
|
||||
//! An iterator to iterate through all the bonds of the protein
|
||||
class Bonds_iterator;
|
||||
/*! Begin iterating through all the bonds
|
||||
\note These bonds are indexed by the atom numbers in the pdb
|
||||
which will not correspond to the atom sequence numbers in the
|
||||
atoms_begin() sequence when the PDB atoms do not start from 1 or
|
||||
have missing residues. This is a bug (I think) and will be
|
||||
fixed. However, doing so is slightly complicated as I need to
|
||||
handle the case of missing residues.
|
||||
*/
|
||||
Bonds_iterator bonds_begin() const;
|
||||
//! End iterating through all the bonds.
|
||||
Bonds_iterator bonds_end() const;
|
||||
//! This is non-const time.
|
||||
unsigned int number_of_bonds() const;
|
||||
|
||||
//! Return the CGAL::PDB::Residue which contains the atoms with a particular index.
|
||||
/*! This operation is currently linear in the number of
|
||||
residues. Making it logrighmic should be easy, but it isn't
|
||||
done.
|
||||
*/
|
||||
const Residue& residue_containing_atom(Atom::Index atom_index) const;
|
||||
//! Return the CGAL::PDB::Residue which contains the atom witha particular index.
|
||||
Residue& residue_containing_atom(Atom::Index atom_index);
|
||||
|
||||
//! Return the atom which has the pdb index passed.
|
||||
const Atom& atom(Atom::Index atom_index) const;
|
||||
|
||||
//! Return the atom which has the pdb index passed.
|
||||
void set_atom(Atom::Index atom_index, const Atom &a);
|
||||
|
||||
//! Remove the corresponding atom from the protein
|
||||
void erase_atom(Atom::Index atom_index);
|
||||
|
||||
//! Return the spherical_coordinates of the atom relative to its parent.
|
||||
/*!
|
||||
Currently the atom must be a Ca, N, or C.
|
||||
*/
|
||||
Spherical_point spherical_coordinates(Atom::Index atom_index) const;
|
||||
|
||||
//! Return the parent of an atom with regards to computing spherical coordinates.
|
||||
Atom::Index parent_atom(Atom::Index atom_index) const;
|
||||
|
||||
|
||||
//! The sequence of residue types.
|
||||
std::vector<Residue::Type> sequence() const;
|
||||
|
||||
//! Write as part of pdb file.
|
||||
void write(std::ostream &out) const;
|
||||
//! Write a pdb file.
|
||||
/*!
|
||||
See check_protein.cc for an example of using this to write a
|
||||
pdb file.
|
||||
*/
|
||||
void write_pdb(std::ostream &out) const;
|
||||
//! Dump as human readable.
|
||||
void dump(std::ostream &out) const;
|
||||
|
||||
|
||||
//! Return the residue with a particular index.
|
||||
/*! \note This function has changed. Use the iterators if you
|
||||
just want to go through the list.
|
||||
*/
|
||||
const Residue& residue(Residue::Index i) const;
|
||||
|
||||
//! Return true if there is a residue with that index
|
||||
bool has_residue(Residue::Index i) const;
|
||||
|
||||
/*const Atom &atom(unsigned int i) const {
|
||||
for (Const_residues_iterator it = residues_begin(); it != residues_.end(); ++it){
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
//! Return whether bonds have been computed for this protein.
|
||||
bool has_bonds() const {
|
||||
return residues_[0].has_bonds();
|
||||
}
|
||||
|
||||
//! Set whether the protein has bonds or not.
|
||||
void set_has_bonds(bool tf) {
|
||||
for (unsigned int i=0; i< residues_.size(); ++i){
|
||||
residues_[i].set_has_bonds(tf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
//! An interator through the backbone coordinates.
|
||||
/*!
|
||||
The value_type is a dsr::Point.
|
||||
*/
|
||||
class Backbone_coordinates_iterator;
|
||||
//! Begin iterating through the backbone coordinates.
|
||||
Backbone_coordinates_iterator backbone_coordinates_begin() const;
|
||||
//! End iterating through the backbone coordinates.
|
||||
Backbone_coordinates_iterator backbone_coordinates_end() const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void process_line(const char *line);
|
||||
|
||||
unsigned int residue_offset_of_atom_index(Atom::Index i) const;
|
||||
|
||||
unsigned int residue_offset(Residue::Index i) const;
|
||||
|
||||
std::vector<Residue> residues_;
|
||||
std::vector<std::string> header_;
|
||||
//static Residue dummy_residue_;
|
||||
std::map<Residue::Index,
|
||||
std::vector<std::pair<char, Residue> > > insert_residues_;
|
||||
char chain_;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//! An iterator through the atoms of a CGAL::PDB::Protein.
|
||||
class Protein::Atoms_iterator {
|
||||
friend class Protein;
|
||||
friend class Protein::Const_atoms_iterator;
|
||||
public:
|
||||
//! The value_type is a CGAL::PDB::Atom
|
||||
typedef Atom value_type;
|
||||
typedef std::forward_iterator_tag iterator_category;
|
||||
typedef std::size_t difference_type;
|
||||
typedef std::iterator_traits<Residue::Atoms_iterator>::reference reference;
|
||||
typedef std::iterator_traits<Residue::Atoms_iterator>::pointer pointer;
|
||||
|
||||
reference operator*() {
|
||||
return *ait_;
|
||||
}
|
||||
pointer operator->() {
|
||||
return deref(ait_);
|
||||
}
|
||||
Atoms_iterator operator++() {
|
||||
++ait_;
|
||||
if (ait_== rit_->atoms_end()) {
|
||||
++rit_;
|
||||
if (rit_!= rend_){
|
||||
ait_=rit_->atoms_begin();
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator==(const Atoms_iterator& o) const {
|
||||
if (rit_ == rend_) return rit_==o.rit_;
|
||||
else return rit_== o.rit_ && ait_ == o.ait_;
|
||||
}
|
||||
bool operator!=(const Atoms_iterator& o) const {
|
||||
if (rit_== rend_) return rit_!= o.rit_;
|
||||
else return rit_!= o.rit_ || ait_ != o.ait_;
|
||||
}
|
||||
Atoms_iterator(const Atoms_iterator &o) {
|
||||
operator=(o);
|
||||
}
|
||||
Atoms_iterator& operator=(const Atoms_iterator &o) {
|
||||
rit_= o.rit_;
|
||||
rend_= o.rend_;
|
||||
if (rit_!= rend_) {
|
||||
ait_=o.ait_;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
protected:
|
||||
Atoms_iterator(std::vector<Residue>::iterator b,
|
||||
std::vector<Residue>::iterator e): rit_(b), rend_(e){
|
||||
if (b != e) {
|
||||
ait_= rit_->atoms_begin();
|
||||
}
|
||||
}
|
||||
std::vector<Residue>::iterator rit_, rend_;
|
||||
Residue::Atoms_iterator ait_;
|
||||
private:
|
||||
template < typename T >
|
||||
static pointer deref(const T& t) { return t.operator->(); }
|
||||
template < typename T >
|
||||
static pointer deref(T* t) { return t; }
|
||||
};
|
||||
|
||||
|
||||
//! An iterator through the atoms of a CGAL::PDB::Protein.
|
||||
class Protein::Const_atoms_iterator {
|
||||
friend class Protein;
|
||||
public:
|
||||
//! The value_type is a CGAL::PDB::Atom
|
||||
typedef Atom value_type;
|
||||
typedef std::forward_iterator_tag iterator_category;
|
||||
typedef std::size_t difference_type;
|
||||
typedef std::iterator_traits<Residue::Const_atoms_iterator>::reference reference;
|
||||
typedef std::iterator_traits<Residue::Const_atoms_iterator>::pointer pointer;
|
||||
|
||||
reference operator*() const {
|
||||
return *ait_;
|
||||
}
|
||||
pointer operator->() const {
|
||||
return deref(ait_);
|
||||
}
|
||||
Const_atoms_iterator operator++() {
|
||||
++ait_;
|
||||
if (ait_== rit_->atoms_end()) {
|
||||
++rit_;
|
||||
if (rit_!= rend_){
|
||||
ait_=rit_->atoms_begin();
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator==(const Const_atoms_iterator& o) const {
|
||||
if (rit_ == rend_) return rit_==o.rit_;
|
||||
else return rit_== o.rit_ && ait_ == o.ait_;
|
||||
}
|
||||
bool operator!=(const Const_atoms_iterator& o) const {
|
||||
if (rit_== rend_) return rit_!= o.rit_;
|
||||
else return rit_!= o.rit_ || ait_ != o.ait_;
|
||||
}
|
||||
|
||||
Const_atoms_iterator(Protein::Atoms_iterator it){
|
||||
rit_= it.rit_;
|
||||
rend_= it.rend_;
|
||||
if (rit_ != rend_) {
|
||||
ait_= it.ait_;
|
||||
}
|
||||
}
|
||||
Const_atoms_iterator(const Const_atoms_iterator &o) {
|
||||
operator=(o);
|
||||
}
|
||||
Const_atoms_iterator& operator=(const Const_atoms_iterator &o) {
|
||||
rit_= o.rit_;
|
||||
rend_= o.rend_;
|
||||
if (rit_!= rend_) {
|
||||
ait_=o.ait_;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
protected:
|
||||
Const_atoms_iterator(std::vector<Residue>::const_iterator b,
|
||||
std::vector<Residue>::const_iterator e): rit_(b), rend_(e){
|
||||
if (b != e) {
|
||||
ait_= rit_->atoms_begin();
|
||||
}
|
||||
}
|
||||
std::vector<Residue>::const_iterator rit_, rend_;
|
||||
Residue::Const_atoms_iterator ait_;
|
||||
private:
|
||||
template < typename T >
|
||||
static pointer deref(const T& t) { return t.operator->(); }
|
||||
template < typename T >
|
||||
static pointer deref(const T* t) { return t; }
|
||||
};
|
||||
|
||||
|
||||
//! An iterator through the bonds of a CGAL::PDB::Protein
|
||||
class Protein::Bonds_iterator {
|
||||
friend class Protein;
|
||||
public:
|
||||
//! The value_type is a CGAL::PDB::Protein::Bond
|
||||
typedef Bond value_type;
|
||||
typedef std::forward_iterator_tag iterator_category;
|
||||
typedef std::size_t difference_type;
|
||||
typedef const Bond& reference;
|
||||
typedef const Bond* pointer;
|
||||
|
||||
reference operator*() const {
|
||||
return cur_bond();
|
||||
}
|
||||
pointer operator->() const {
|
||||
return &cur_bond();
|
||||
}
|
||||
Bonds_iterator operator++() {
|
||||
if (between_) {
|
||||
between_=false;
|
||||
++rit_;
|
||||
if (rit_ != rend_) {
|
||||
ait_= rit_->bonds_begin();
|
||||
}
|
||||
} else {
|
||||
++ait_;
|
||||
if (ait_== rit_->bonds_end()) {
|
||||
std::vector<Residue>::const_iterator nrit= rit_;
|
||||
++nrit;
|
||||
between_=true;
|
||||
if (nrit == rend_
|
||||
|| nrit->index().to_index() != rit_->index().to_index()+1
|
||||
|| !nrit->has_atom(Residue::AL_N) || !rit_->has_atom(Residue::AL_C)){
|
||||
operator++();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
bool operator==(const Bonds_iterator& o) const {
|
||||
if (between_ != o.between_) return false;
|
||||
if (rit_ == rend_) return rit_==o.rit_;
|
||||
else return rit_== o.rit_ && ait_ == o.ait_;
|
||||
}
|
||||
bool operator!=(const Bonds_iterator& o) const {
|
||||
return !operator==(o);
|
||||
}
|
||||
|
||||
Bonds_iterator(){}
|
||||
|
||||
Bonds_iterator(const Bonds_iterator &o) {
|
||||
operator=(o);
|
||||
}
|
||||
Bonds_iterator &operator=(const Bonds_iterator &o) {
|
||||
rit_= o.rit_;
|
||||
rend_= o.rend_;
|
||||
between_= o.between_;
|
||||
if (rit_ != rend_) {
|
||||
ait_= o.ait_;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
protected:
|
||||
Bonds_iterator(std::vector<Residue>::const_iterator b,
|
||||
std::vector<Residue>::const_iterator e): rit_(b), rend_(e),
|
||||
between_(false){
|
||||
if (b != e) {
|
||||
ait_= rit_->bonds_begin();
|
||||
}
|
||||
}
|
||||
|
||||
const Bond &cur_bond() const {
|
||||
if (between_) {
|
||||
assert(rit_+1 != rend_);
|
||||
static Bond b;
|
||||
b= Bond((rit_)->atom(Residue::AL_C).index(),
|
||||
(rit_+1)->atom(Residue::AL_N).index());
|
||||
return b;
|
||||
} else return *ait_;
|
||||
}
|
||||
|
||||
std::vector<Residue>::const_iterator rit_, rend_;
|
||||
Residue::Bonds_iterator ait_;
|
||||
bool between_;
|
||||
};
|
||||
|
||||
CGAL_PDB_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
#ifndef CGAL_DSRPDB_QUATERNION_H_
|
||||
#define CGAL_DSRPDB_QUATERNION_H_
|
||||
#include <CGAL/PDB/basic.h>
|
||||
#include <cmath>
|
||||
#include <CGAL/PDB/Point.h>
|
||||
#include <iostream>
|
||||
|
||||
CGAL_PDB_BEGIN_NAMESPACE
|
||||
|
||||
//! A trivial class for representing quaternions
|
||||
class Quaternion {
|
||||
protected:
|
||||
typedef double NT;
|
||||
NT q_[4];
|
||||
|
||||
public:
|
||||
Quaternion(){
|
||||
q_[0]=0;
|
||||
q_[1]=0;
|
||||
q_[2]=0;
|
||||
q_[3]=0;
|
||||
};
|
||||
//! Construct it from the four doubles.
|
||||
Quaternion(NT a, NT b, NT c, NT d){
|
||||
q_[0]=a;
|
||||
q_[1]=b;
|
||||
q_[2]=c;
|
||||
q_[3]=d;
|
||||
};
|
||||
|
||||
|
||||
//! Construct from 3 doubles (the first quaternion value is implicit)
|
||||
Quaternion(NT b, NT c, NT d){
|
||||
q_[1]=b;
|
||||
q_[2]=c;
|
||||
q_[3]=d;
|
||||
q_[0]=std::sqrt(1-b*b-c*c-d*d);
|
||||
};
|
||||
|
||||
//! Construct a quaternion for a rotation by angle around the axis
|
||||
Quaternion(const Vector &axis, double angle) {
|
||||
const double mypi= 3.14159265358979323846264338327950288;
|
||||
double f= angle/(2*mypi);
|
||||
double sf= std::sqrt(f);
|
||||
double n2= axis[0]*axis[0] + axis[1]*axis[1] + axis[2]*axis[2];
|
||||
double n= std::sqrt(n2);
|
||||
q_[0]= std::sqrt(1-f);
|
||||
q_[1]= sf*axis[0]/n;
|
||||
q_[2]= sf*axis[1]/n;
|
||||
q_[3]= sf*axis[2]/n;
|
||||
assert(q_[0]*q_[0]+ q_[1]*q_[1] + q_[2]*q_[2] + q_[3]*q_[3] < 1.1);
|
||||
assert(q_[0]*q_[0]+ q_[1]*q_[1] + q_[2]*q_[2] + q_[3]*q_[3] > 0.9);
|
||||
}
|
||||
|
||||
template <class Arr>
|
||||
Quaternion(Arr va){
|
||||
for (int i=0; i<4; ++i){
|
||||
q_[i]=va[i];
|
||||
}
|
||||
}
|
||||
|
||||
Quaternion(const double m[3][3]);
|
||||
|
||||
NT& operator[](unsigned int i) {
|
||||
assert(i<4);
|
||||
return q_[i];
|
||||
}
|
||||
|
||||
NT operator[](unsigned int i) const {
|
||||
assert(i<4);
|
||||
return q_[i];
|
||||
}
|
||||
};
|
||||
|
||||
inline std::ostream &operator<<(std::ostream &out, const Quaternion &q) {
|
||||
out << "(" << q[0] << ", " << q[1] << ", " << q[2] << ", " << q[3] << ")";
|
||||
return out;
|
||||
}
|
||||
|
||||
CGAL_PDB_END_NAMESPACE
|
||||
#endif
|
||||
|
|
@ -1,283 +0,0 @@
|
|||
/* Copyright 2004
|
||||
Stanford University
|
||||
|
||||
This file is part of the DSR PDB Library.
|
||||
|
||||
The DSR PDB Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The DSR PDB Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the DSR PDB Library; see the file LICENSE.LGPL. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#ifndef CGAL_DSR_PDB_RESIDUE_H
|
||||
#define CGAL_DSR_PDB_RESIDUE_H
|
||||
#include <CGAL/PDB/basic.h>
|
||||
#include <CGAL/PDB/Point.h>
|
||||
//#include <dsr/pdb/Protein.h>
|
||||
#include <CGAL/PDB/Atom.h>
|
||||
#include <CGAL/PDB/small_map.h>
|
||||
#include <CGAL/Tools/Label.h>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
CGAL_PDB_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
class Protein;
|
||||
|
||||
//! The class representing a residue.
|
||||
/*! All the information concerning atoms and bonds for each residue
|
||||
is stored here. To add atoms to residues, new residues, or bonds
|
||||
to residues, look in Residue_data.cc. There is documentation there
|
||||
of what you need to do.
|
||||
*/
|
||||
class Residue {
|
||||
friend class Protein;
|
||||
struct Residue_type_tag{};
|
||||
struct Atom_type_tag{};
|
||||
public:
|
||||
//! The type for storing residue indices in the PDB
|
||||
typedef CGAL::Label<Residue> Index;
|
||||
|
||||
//! The labels for the types of residues.
|
||||
enum Type { GLY=0, ALA, VAL, LEU, ILE,
|
||||
SER, THR, CYS, MET, PRO,
|
||||
ASP, ASN, GLU, GLN, LYS,
|
||||
ARG, HIS, PHE, TYR, TRP,
|
||||
ACE, NH2, INV };
|
||||
|
||||
|
||||
//! The labels of atoms within residues
|
||||
/*! These are the labels for each atom in each residue. The
|
||||
identifiers are attempting to following the PDB specs. Feel free to add more if needed.
|
||||
|
||||
AL_N must be before AL_CA which must be before AL_C to get the backbone order correct.
|
||||
*/
|
||||
enum Atom_label {AL_OTHER, AL_INVALID,
|
||||
AL_N, AL_H, AL_1H, AL_2H, AL_3H,
|
||||
|
||||
|
||||
AL_CA, AL_HA, AL_1HA, AL_2HA,
|
||||
|
||||
AL_CB, AL_HB, AL_1HB, AL_2HB, AL_3HB,
|
||||
|
||||
AL_C, AL_O, AL_OXT, AL_CH3,
|
||||
|
||||
AL_CG, AL_CG1, AL_CG2, AL_HG, AL_1HG, AL_2HG, //AL_HG1,
|
||||
AL_1HG1, AL_2HG1, AL_3HG1, AL_1HG2,
|
||||
|
||||
AL_2HG2, AL_3HG2, AL_OG, AL_OG1, AL_SG,
|
||||
|
||||
// AL_HD1, AL_HD2,
|
||||
AL_CD, AL_CD1, AL_CD2, AL_HD, AL_1HD, AL_2HD, AL_3HD, AL_1HD1,
|
||||
AL_2HD1, AL_3HD1, AL_1HD2, AL_2HD2, AL_3HD2, AL_SD,
|
||||
AL_OD1, AL_OD2, AL_ND1, AL_ND2,
|
||||
|
||||
AL_CE, AL_CE1, AL_CE2, AL_CE3, AL_HE, AL_1HE, AL_2HE,
|
||||
AL_3HE, //AL_HE1, AL_HE2, AL_HE3,
|
||||
AL_1HE2, AL_2HE2,
|
||||
AL_OE1, AL_OE2, AL_NE, AL_NE1, AL_NE2,
|
||||
|
||||
AL_CZ, AL_CZ2, AL_CZ3, AL_NZ, AL_HZ, AL_1HZ, AL_2HZ,
|
||||
AL_3HZ, // AL_HZ2, AL_HZ3,
|
||||
|
||||
AL_CH2, AL_NH1, AL_NH2, AL_OH, AL_HH, AL_1HH1,
|
||||
AL_2HH1, AL_HH2, AL_1HH2, AL_2HH2,
|
||||
AL_1HH3, AL_2HH3, AL_3HH3};
|
||||
|
||||
|
||||
|
||||
//! A bond between two atoms in a residue.
|
||||
/*!
|
||||
The ints refer the the atom index.
|
||||
*/
|
||||
typedef std::pair<Atom::Index,Atom::Index> Bond;
|
||||
|
||||
typedef small_map<Atom_label, Atom> Atoms;
|
||||
|
||||
//! Default constructor. Makes and invalid residue.
|
||||
Residue(){}
|
||||
|
||||
//! Make a residue of a given type
|
||||
Residue(Type al);
|
||||
|
||||
//! The label for the residue
|
||||
Type type() const;
|
||||
|
||||
|
||||
//! Return a list of all the bonds in the residue
|
||||
typedef std::vector<Bond>::const_iterator Bonds_iterator;
|
||||
|
||||
//! Begin iterating through the list of all the bonds
|
||||
/*!
|
||||
Note that the iterator will be invalidated if the residue is changed.
|
||||
|
||||
Note that if Residue::has_bonds() is false, this returns an empty sequence.
|
||||
*/
|
||||
Bonds_iterator bonds_begin() const {
|
||||
return bonds_.begin();
|
||||
}
|
||||
//! End bond iteration
|
||||
Bonds_iterator bonds_end() const {
|
||||
return bonds_.end();
|
||||
}
|
||||
//! The number of atoms present in the residue
|
||||
unsigned int number_of_bonds() const;
|
||||
|
||||
|
||||
//! An iterator to list all the atoms
|
||||
typedef Atoms::iterator Atoms_iterator;
|
||||
|
||||
//! Return a list of the labels of all the atoms which are present
|
||||
Atoms_iterator atoms_begin() {
|
||||
return atoms_.begin();
|
||||
}
|
||||
|
||||
//! End iterating through the atoms
|
||||
Atoms_iterator atoms_end() {
|
||||
return atoms_.end();
|
||||
}
|
||||
|
||||
//! An iterator to list all the atoms
|
||||
typedef Atoms::const_iterator Const_atoms_iterator;
|
||||
|
||||
//! Return a list of the labels of all the atoms which are present
|
||||
Const_atoms_iterator atoms_begin() const {
|
||||
return atoms_.begin();
|
||||
}
|
||||
|
||||
//! End iterating through the atoms
|
||||
Const_atoms_iterator atoms_end() const {
|
||||
return atoms_.end();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! The number of atoms present in the residue
|
||||
unsigned int number_of_atoms() const;
|
||||
|
||||
|
||||
//! Return true if the atom is in the atoms() list
|
||||
bool has_atom(Atom_label al) const;
|
||||
|
||||
//! Return true if residues of this type can have atoms of that type
|
||||
bool can_have_atom(Atom_label al) const;
|
||||
|
||||
|
||||
//! Return the data for an atom
|
||||
const Atom& atom(Atom_label al) const;
|
||||
|
||||
//! Return the label of the atom with this index.
|
||||
Atom_label atom_label(Atom::Index model_index) const;
|
||||
|
||||
//! Set an atom
|
||||
/*!
|
||||
If the atom is not already there, then the bonds iterators are invalidated.
|
||||
*/
|
||||
void set_atom(Atom_label al, const Atom &a);
|
||||
|
||||
//! Set an atom using a string as a label
|
||||
void set_atom_from_string(const char *str, const Atom &a) {
|
||||
set_atom(atom_label(str), a);
|
||||
}
|
||||
|
||||
//! Remove an atom from the residue
|
||||
void erase_atom(Atom_label al);
|
||||
|
||||
//! The index of the last atom in the residue
|
||||
Atom::Index last_atom_index() const;
|
||||
|
||||
//! The index for the residue
|
||||
/*!
|
||||
This is 0 based index so it is the PDB index -1.
|
||||
*/
|
||||
Index index() const {
|
||||
return index_;
|
||||
}
|
||||
|
||||
//! Set the index for the residue
|
||||
void set_index(Index i);
|
||||
|
||||
|
||||
//! Write it for debugging
|
||||
void dump(std::ostream &out) const;
|
||||
//! Write the lines for a pdb file
|
||||
void write(char chain, char insert_code, std::ostream &out) const;
|
||||
|
||||
|
||||
|
||||
//! Return a point representing the sidechain
|
||||
/*! If the sidechain is empty this returns the CA
|
||||
location. Otherwise it returns the location of some atom or the
|
||||
average of some atom locations.
|
||||
*/
|
||||
Point sidechain_point() const;
|
||||
|
||||
|
||||
//! Set whether all the inter-atom bonds are present or not.
|
||||
/*!
|
||||
This must be true before Residue::bonds_begin() is called.
|
||||
*/
|
||||
void set_has_bonds(bool tf);
|
||||
|
||||
//! Return whether this residue has the inter-atom bonds computed.
|
||||
bool has_bonds() const {
|
||||
return !bonds_.empty();
|
||||
}
|
||||
|
||||
|
||||
//----- Static functions
|
||||
|
||||
//! Convert a string for an amino acid type into a tag
|
||||
static Type type(const std::string &st);
|
||||
//! A string so you can write an amino acid type
|
||||
static std::string type_string(Type rl);
|
||||
|
||||
//! Return the element corresponding to an atom label
|
||||
static Atom::Type element(Atom_label al);
|
||||
|
||||
//! return the string corresponding to an atom label
|
||||
static std::string atom_label_string(Atom_label al);
|
||||
//! Return an atom label from a string
|
||||
/*! Note, this label may be adjusted when the atoms is added to a
|
||||
residue to address naming inconsistencies.
|
||||
*/
|
||||
static Atom_label atom_label(const char *c);
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
/*Residue( Label al,
|
||||
std::vector<Residue::Atom_label> * atoms,
|
||||
std::vector<std::pair<Residue::Atom_label,
|
||||
Residue::Atom_label> > *bonds);*/
|
||||
Atom::Index index(Residue::Atom_label al) const;
|
||||
|
||||
Atom::Index min_atom_index() const {
|
||||
return min_atom_index_;
|
||||
}
|
||||
|
||||
Atoms_iterator atoms_iterator_from_index(Atom::Index ind);
|
||||
Const_atoms_iterator atoms_iterator_from_index(Atom::Index ind) const;
|
||||
private:
|
||||
|
||||
/*--------------- Data members-----------------------------------*/
|
||||
Atoms atoms_;
|
||||
std::vector<Bond> bonds_;
|
||||
Type label_;
|
||||
Index index_;
|
||||
Atom::Index min_atom_index_;
|
||||
};
|
||||
|
||||
CGAL_PDB_END_NAMESPACE
|
||||
#endif
|
||||
|
|
@ -1,111 +0,0 @@
|
|||
#ifndef DSRPDB_TRANSFORM_H
|
||||
#define DSRPDB_TRANSFORM_H
|
||||
#include <CGAL/PDB/basic.h>
|
||||
#include <CGAL/PDB/Quaternion.h>
|
||||
#include <CGAL/PDB/Point.h>
|
||||
#include <iostream>
|
||||
|
||||
CGAL_PDB_BEGIN_NAMESPACE
|
||||
//! This class provides a simple rigid transformation matrix
|
||||
/*! The matrix has a rotational an a translational part. However,
|
||||
it is not enforced that the rotational part is actually just a
|
||||
rotation (this is slightly tricky due to possible numeric errors.
|
||||
*/
|
||||
struct Transform {
|
||||
typedef double NT;
|
||||
Transform(){
|
||||
for (unsigned int i=0; i< 3; ++i){
|
||||
rot_[i][0]=0;
|
||||
rot_[i][1]=0;
|
||||
rot_[i][2]=0;
|
||||
rot_[i][i]=1;
|
||||
trans_[i]=0;
|
||||
}
|
||||
}
|
||||
|
||||
//! Construct a transform from a rotation matrix and an offset vector.
|
||||
template <class TA, class TB>
|
||||
Transform(TA rot, TB trans){
|
||||
for (unsigned int i=0; i< 3; ++i){
|
||||
trans_[i]=trans[i];
|
||||
for (unsigned int j=0; j< 3; ++j){
|
||||
rot_[i][j]=rot[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
NT m01 = rot[0][0]*rot[1][1] - rot[1][0]*rot[0][1];
|
||||
NT m02 = rot[0][0]*rot[2][1] - rot[2][0]*rot[0][1];
|
||||
NT m12 = rot[1][0]*rot[2][1] - rot[2][0]*rot[1][1];
|
||||
NT det = m01*rot[2][2] - m02*rot[1][2] + m12*rot[0][2];
|
||||
assert(det >0);
|
||||
assert(std::abs(1-det) < .25);
|
||||
#endif
|
||||
}
|
||||
|
||||
Transform(const Vector &trans, const Quaternion &q);
|
||||
|
||||
|
||||
//! Apply a transformation to a point
|
||||
template <class Point>
|
||||
Point operator()(const Point &pt) const {
|
||||
NT ix= pt.x();// + trans_[0];
|
||||
NT iy= pt.y();// + trans_[1];
|
||||
NT iz= pt.z();// + trans_[2];
|
||||
NT x= ix*rot_[0][0] + iy*rot_[0][1] + iz*rot_[0][2] + trans_[0];
|
||||
NT y= ix*rot_[1][0] + iy*rot_[1][1] + iz*rot_[1][2] + trans_[1];
|
||||
NT z= ix*rot_[2][0] + iy*rot_[2][1] + iz*rot_[2][2] + trans_[2];
|
||||
return Point(x,y,z);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Set the translation part of the transformation matrix.
|
||||
template <class Pt>
|
||||
void set_translation(Pt tr){
|
||||
trans_[0]=tr.x();
|
||||
trans_[1]=tr.y();
|
||||
trans_[2]=tr.z();
|
||||
}
|
||||
|
||||
const NT* translation() const {
|
||||
return trans_;
|
||||
}
|
||||
|
||||
Quaternion quaternion() const {
|
||||
return Quaternion(rot_);
|
||||
}
|
||||
|
||||
void write(std::ostream &out) const;
|
||||
|
||||
NT error(const Transform &o) const {
|
||||
NT n=0;
|
||||
for (unsigned int i=0; i< 3; ++i){
|
||||
n += std::abs(o.trans_[i]- trans_[i]);
|
||||
for (unsigned int j=0; j< 3; ++j){
|
||||
n+= std::abs(o.rot_[i][j]- rot_[i][j]);
|
||||
}
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
private:
|
||||
NT rot_[3][3];
|
||||
NT trans_[3];
|
||||
};
|
||||
|
||||
//! Write the transformation matrix to a stream.
|
||||
/*!
|
||||
The output format is
|
||||
r r r t
|
||||
r r r t
|
||||
r r r t
|
||||
0 0 0 1
|
||||
*/
|
||||
inline std::ostream &operator<<(std::ostream &out, const Transform &t) {
|
||||
t.write(out);
|
||||
return out;
|
||||
}
|
||||
CGAL_PDB_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
#ifndef CGAL_DSRPDB_ALIGN_H
|
||||
#define CGAL_DSRPDB_ALIGN_H
|
||||
#include <CGAL/PDB/basic.h>
|
||||
#include <CGAL/PDB/Protein.h>
|
||||
#include <CGAL/PDB/Transform.h>
|
||||
#include <vector>
|
||||
|
||||
CGAL_PDB_BEGIN_NAMESPACE
|
||||
|
||||
/*! Compute an optimal rigid alignment of the second protein to the
|
||||
first and transform it accordingly. The two proteins must have the
|
||||
same number of residues and all C_alpha atom possitions must be
|
||||
defined.
|
||||
|
||||
\example pdb_align.cc
|
||||
*/
|
||||
void align_second_protein_to_first(const Protein &base, Protein &o);
|
||||
|
||||
/*!
|
||||
Compute the transformation matrix which maps the second point set
|
||||
to the first.
|
||||
|
||||
\example pdb_align_points.cc
|
||||
*/
|
||||
Transform transform_taking_first_to_second(const std::vector<Point> &a,
|
||||
const std::vector<Point> &b);
|
||||
|
||||
/*! Use a Structal or ICP-like algorithm alternating finding atom
|
||||
associations using dynamic programming and rigid alignment to
|
||||
improve the alignment of two proteins.
|
||||
*/
|
||||
Transform refine_alignment_of_second_protein_to_first(const Protein &base,
|
||||
Protein &o);
|
||||
|
||||
/*!
|
||||
Use a structal or ICP-like algorithm to refine the alignment of one set of
|
||||
points to the other. The point sets must be matched in order (with gaps).
|
||||
*/
|
||||
Transform transform_taking_first_to_second(const std::vector<Point> &a,
|
||||
const std::vector<Point> &b);
|
||||
|
||||
CGAL_PDB_END_NAMESPACE
|
||||
#endif
|
||||
|
|
@ -1,396 +0,0 @@
|
|||
#ifndef CGAL_DSR_ALIGN_POINTS_H_
|
||||
#define CGAL_DSR_ALIGN_POINTS_H_
|
||||
#include <CGAL/PDB/basic.h>
|
||||
#include <CGAL/PDB/internal/tnt/tnt_cmat.h>
|
||||
#include <CGAL/PDB/Point.h>
|
||||
#include <CGAL/PDB/Transform.h>
|
||||
#include <CGAL/PDB/internal/tnt/tnt_array2d.h>
|
||||
#include <CGAL/PDB/internal/tnt/tnt_array2d_utils.h>
|
||||
#include <CGAL/PDB/internal/tnt/jama_svd.h>
|
||||
#include <cassert>
|
||||
#include <vector>
|
||||
#include <iterator>
|
||||
|
||||
CGAL_PDB_BEGIN_INTERNAL_NAMESPACE
|
||||
namespace Align {
|
||||
template <class T>
|
||||
T det(const CGAL_TNT_NS::Array2D<T>& m) {
|
||||
assert(m.dim1() == 3);
|
||||
assert(m.dim2() == 3);
|
||||
|
||||
return (m[0][0]*(m[1][1]*m[2][2] - m[1][2]*m[2][1]) -
|
||||
m[0][1]*(m[1][0]*m[2][2] - m[1][2]*m[2][0]) +
|
||||
m[0][2]*(m[1][0]*m[2][1] - m[1][1]*m[2][0]));
|
||||
}
|
||||
|
||||
// Transpose a matrix
|
||||
template <class T>
|
||||
CGAL_TNT_NS::Array2D<T> transpose(const CGAL_TNT_NS::Array2D<T>& m) {
|
||||
CGAL_TNT_NS::Array2D<T> mt(m.dim2(), m.dim1());
|
||||
for (int i = 0; i < m.dim1(); i++) {
|
||||
for (int j = 0; j < m.dim2(); j++) {
|
||||
mt[j][i] = m[i][j];
|
||||
}
|
||||
}
|
||||
return mt;
|
||||
}
|
||||
|
||||
|
||||
inline double structal_score(const CGAL_PDB_NS::Point& a,
|
||||
const CGAL_PDB_NS::Point& b) {
|
||||
CGAL_PDB_NS::Squared_distance sd;
|
||||
return 20.0/(1.0+sd(a,b)*5.0);
|
||||
}
|
||||
|
||||
inline double gap_score() {
|
||||
return -10.0;
|
||||
}
|
||||
|
||||
struct DpP {
|
||||
double first;
|
||||
int second;
|
||||
DpP(double d, int s): first(d), second(s){}
|
||||
DpP(): first(-1), second(-3){}
|
||||
};
|
||||
|
||||
inline std::ostream &operator<<(std::ostream &o, DpP p){
|
||||
return o << "(" << p.first << " " << p.second << ")";
|
||||
}
|
||||
}
|
||||
CGAL_PDB_END_INTERNAL_NAMESPACE
|
||||
|
||||
CGAL_PDB_BEGIN_NAMESPACE
|
||||
|
||||
/*! This computes the optimal rigid transform minimizing the least
|
||||
squares distance between the point sets defined by the two
|
||||
ranges. The two point sets must have equal size (since the points
|
||||
are taken to be in one-to-one correspondence.
|
||||
|
||||
The value_types of InputIteratorP and InputIteratorQ must be both
|
||||
be convertible to CGAL::PDB::Point.
|
||||
*/
|
||||
template <class InputIteratorP, class InputIteratorQ>
|
||||
Transform transform_taking_first_to_second(InputIteratorP pBegin, InputIteratorP pEnd,
|
||||
InputIteratorQ qBegin, InputIteratorQ qEnd) {
|
||||
using namespace CGAL_PDB_INTERNAL_NS::Align;
|
||||
assert(std::distance(pBegin, pEnd) == std::distance(qBegin, qEnd));
|
||||
// compute the centroid of the points and transform
|
||||
// pointsets so that their centroids coinside
|
||||
|
||||
typedef typename std::iterator_traits<InputIteratorP>::value_type Point;
|
||||
typedef double RT;
|
||||
|
||||
Vector center_p(0,0,0), center_q(0,0,0);
|
||||
int num_p = 0;
|
||||
int num_q = 0;
|
||||
for (InputIteratorP p_it = pBegin; p_it != pEnd; ++p_it) {
|
||||
//double x= p_it->x();
|
||||
center_p = center_p+Vector(p_it->x(), p_it->y(), p_it->z());//((*p_it)-CGAL::ORIGIN);
|
||||
num_p++;
|
||||
}
|
||||
center_p = center_p/num_p;
|
||||
|
||||
for (InputIteratorQ q_it = qBegin; q_it != qEnd; ++q_it) {
|
||||
center_q = center_q + Vector(q_it->x(), q_it->y(), q_it->z()); //((*q_it)-CGAL::ORIGIN);
|
||||
num_q++;
|
||||
}
|
||||
center_q = center_q/num_q;
|
||||
|
||||
assert(num_p == num_q);
|
||||
|
||||
std::vector<Point> p_shifted, q_shifted;
|
||||
p_shifted.reserve(num_p);
|
||||
q_shifted.reserve(num_q);
|
||||
for (InputIteratorP p_it = pBegin; p_it != pEnd; ++p_it) {
|
||||
p_shifted.push_back((*p_it) - center_p);
|
||||
}
|
||||
for (InputIteratorQ q_it = qBegin; q_it != qEnd; ++q_it) {
|
||||
q_shifted.push_back((*q_it) - center_q);
|
||||
}
|
||||
|
||||
|
||||
// covariance matrix
|
||||
CGAL_TNT_NS::Array2D<RT> H(3, 3);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
H[i][j] = 0;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < num_p; i++) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
for (int k = 0; k < 3; k++) {
|
||||
H[j][k] += p_shifted[i][j]*q_shifted[i][k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CGAL_JAMA_NS::SVD<RT> svd(H);
|
||||
CGAL_TNT_NS::Array2D<RT> U(3, 3), V(3, 3);
|
||||
svd.getU(U);
|
||||
svd.getV(V);
|
||||
|
||||
// the rotation matrix is R = VU^T
|
||||
CGAL_TNT_NS::Array2D<RT> UT = transpose(U);
|
||||
CGAL_TNT_NS::Array2D<RT> rot(3, 3);
|
||||
rot = matmult(V, UT);
|
||||
|
||||
// check for reflection
|
||||
if (det(rot) < 0) {
|
||||
CGAL_TNT_NS::Array2D<RT> VT = transpose(V);
|
||||
CGAL_TNT_NS::Array2D<RT> UVT = matmult(U, VT);
|
||||
CGAL_TNT_NS::Array2D<RT> S(3, 3);
|
||||
S[0][0] = S[1][1] = 1;
|
||||
S[2][2] = det(UVT);
|
||||
S[0][1] = S[0][2] = S[1][0] = S[1][2] = S[2][0] = S[2][1] = 0;
|
||||
rot = matmult(matmult(U, S), VT);
|
||||
}
|
||||
|
||||
Transform xf(rot, Point(0,0,0));
|
||||
|
||||
xf.set_translation(center_q - xf(center_p));
|
||||
|
||||
return xf;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*! This function computes the optimal fixed matching between the
|
||||
two point sets defined by the two ranges. The matching is put into
|
||||
the range (b_m...e_m) which must have the same size as
|
||||
(b_0...e_0). The matching is represented as an iterator in the
|
||||
range (b_1...e_1) for each element in (b_0...e_0) with e_1 used to
|
||||
designate that there is no matching (i.e. that there is a gap).
|
||||
|
||||
The value_types of It0 and It1 must both be convertible to
|
||||
CGAL::PDB::Point.
|
||||
|
||||
The run time is the product of distance(b_0,e_0)*distance(b_1,e_1).
|
||||
|
||||
Return the structal score.
|
||||
*/
|
||||
template <class It0, class It1, class ItM>
|
||||
double optimal_fixed_matching(It0 b_0, It0 e_0,
|
||||
It1 b_1, It1 e_1,
|
||||
ItM b_m, ItM e_m) {
|
||||
using namespace CGAL_PDB_INTERNAL_NS::Align;
|
||||
assert(std::distance(b_0, e_0) == std::distance(b_m, e_m));
|
||||
const double gap_cost=10.0;
|
||||
unsigned int d_0= std::distance(b_0, e_0);
|
||||
unsigned int d_1= std::distance(b_1, e_1);
|
||||
//typedef std::pair<double, int> DpP;
|
||||
CGAL_TNT_NS::Array2D<DpP> dp_matrix(d_0+2, d_1+2);
|
||||
|
||||
|
||||
std::vector<int> best_i(d_1+2);
|
||||
int best_j(0);
|
||||
|
||||
for (unsigned int i=0; i< d_0+1; ++i){
|
||||
dp_matrix[i][0]=DpP(-gap_cost*i,0);
|
||||
}
|
||||
for (unsigned int j=0; j< d_1+2; ++j){
|
||||
best_i[j]= 0;
|
||||
}
|
||||
//best_i.back()= 0;
|
||||
|
||||
for (unsigned int j=0; j< d_1+1; ++j){
|
||||
dp_matrix[0][j]=DpP(-gap_cost*j,0);
|
||||
}
|
||||
|
||||
dp_matrix[0][d_1+1]=DpP(-gap_cost*d_1, 0);
|
||||
dp_matrix[d_0+1][0]=DpP(-gap_cost*d_0, 0);
|
||||
|
||||
{
|
||||
It0 c_0=b_0;
|
||||
for (unsigned int i=1; i< d_0+2; ++i, ++c_0){
|
||||
It1 c_1= b_1;
|
||||
best_j= 0;
|
||||
for (unsigned int j=1; j< d_1+2; ++j, ++c_1){
|
||||
double ss;
|
||||
if (c_0== e_0 || c_1==e_1) {
|
||||
ss= 0;
|
||||
} else {
|
||||
ss= structal_score(*c_0, *c_1);
|
||||
}
|
||||
|
||||
|
||||
double v_d= dp_matrix[i-1][j-1].first;
|
||||
double v_i= -gap_cost*best_i[j-1] + dp_matrix[i-best_i[j-1]-1][j-1].first;
|
||||
double v_j= -gap_cost*best_j + dp_matrix[i-1][j-best_j-1].first;
|
||||
|
||||
if (v_d >= v_i && v_d >= v_j){
|
||||
dp_matrix[i][j]= DpP(ss+v_d, 0);
|
||||
best_i[j-1]=0;
|
||||
best_j=0;
|
||||
} else if (v_i >= v_j){
|
||||
dp_matrix[i][j] = DpP(ss+v_i, best_i[j-1]);
|
||||
assert(v_i > v_d);
|
||||
if (v_d >= v_j) best_j=0;
|
||||
} else {
|
||||
dp_matrix[i][j] = DpP(ss+v_j, -best_j);
|
||||
if (v_d >= v_i) best_i[j-1]=0;
|
||||
}
|
||||
|
||||
/*const double eps=.00001;
|
||||
|
||||
for (unsigned int k=0; k< i; ++k){
|
||||
assert(dp_matrix[i-k-1][j-1].first -gap_cost*k +ss <= dp_matrix[i][j].first + eps);
|
||||
if (dp_matrix[i][j].second == static_cast<int>(k)) {
|
||||
assert(std::abs(dp_matrix[i-k-1][j-1].first - gap_cost*k + ss - dp_matrix[i][j].first) < eps);
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned int k=0; k< j; ++k){
|
||||
assert(dp_matrix[i-1][j-k-1].first -gap_cost*k + ss <= dp_matrix[i][j].first + eps);
|
||||
if (dp_matrix[i][j].second == -static_cast<int>(k)) {
|
||||
assert( std::abs(ss - gap_cost*k + dp_matrix[i-1][j-k-1].first - dp_matrix[i][j].first) < eps);
|
||||
}
|
||||
}*/
|
||||
|
||||
++best_i[j-1];
|
||||
++best_j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*std::cout.precision(2);
|
||||
std::cout << dp_matrix << std::endl;*/
|
||||
|
||||
// backtrace
|
||||
{
|
||||
unsigned int i=d_0+1, j= d_1+1;
|
||||
It1 c_1= e_1;
|
||||
ItM c_m= e_m; //--c_m;
|
||||
//int d= c_1-b_1;
|
||||
assert(c_1-b_1 == static_cast<int>(j)-1);
|
||||
|
||||
//bool set=false;
|
||||
while (i >0 && j > 0) {
|
||||
if (dp_matrix[i][j].second ==0){
|
||||
|
||||
} else if (dp_matrix[i][j].second < 0) {
|
||||
for (int k=0; k< std::abs(dp_matrix[i][j].second); ++k) --c_1;
|
||||
j-= std::abs(dp_matrix[i][j].second);
|
||||
} else {
|
||||
for (int k =0; k< dp_matrix[i][j].second; ++k){
|
||||
--c_m;
|
||||
*c_m=e_1;
|
||||
}
|
||||
i-= dp_matrix[i][j].second;
|
||||
}
|
||||
--i;
|
||||
--j;
|
||||
--c_1;
|
||||
|
||||
if (i==0 || j==0) break;
|
||||
assert(c_m != b_m);
|
||||
--c_m;
|
||||
assert(j < d_1+1);
|
||||
assert(i < d_0+1);
|
||||
*c_m=c_1; //j-1;
|
||||
|
||||
//int d= c_1-b_1;
|
||||
assert(c_1-b_1 == static_cast<int>(j)-1);
|
||||
//std::cout << i << " " << j << std::endl;
|
||||
}
|
||||
}
|
||||
return dp_matrix[d_0+1][d_1+1].first + gap_cost*(std::max BOOST_PREVENT_MACRO_SUBSTITUTION(d_0, d_1)- std::min BOOST_PREVENT_MACRO_SUBSTITUTION (d_0, d_1));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*! This function refines the alignment between the two point sets
|
||||
represented by the ranges by alternating dynamic programming based
|
||||
sequence alignement and then rigid transformation of the point
|
||||
set. The final correspondence is put into m as a sequence of
|
||||
iterators in the range (b_1...e_1). motion is the minimal amount
|
||||
that the points must move in an iteration for the process to
|
||||
continue (if they move less than that amount the function
|
||||
returns).
|
||||
|
||||
The run time is the
|
||||
number_of_iterators*distance(b_0,e_0)*distance(b_1,e_1).
|
||||
|
||||
*/
|
||||
template <class It0, class It1, class OItM>
|
||||
Transform refine_alignment(It0 b_0, It0 e_0,
|
||||
It1 b_1, It1 e_1,
|
||||
double motion,
|
||||
OItM m) {
|
||||
|
||||
std::vector<Point> p_0(b_0, e_0);
|
||||
double dist= std::numeric_limits<double>::infinity();
|
||||
Squared_distance sd;
|
||||
|
||||
typedef typename std::vector<It1>::const_iterator ItM;
|
||||
std::vector<It1> cur_matching(std::distance(b_0, e_0), e_1);
|
||||
Transform tr;
|
||||
|
||||
double last_score=-std::numeric_limits<double>::infinity();
|
||||
do {
|
||||
double score = optimal_fixed_matching(p_0.begin(), p_0.end(),
|
||||
b_1, e_1,
|
||||
cur_matching.begin(), cur_matching.end());
|
||||
if (score < last_score) break;
|
||||
last_score=score;
|
||||
std::cout << score << std::endl;
|
||||
/*for (unsigned int i=0; i< cur_matching.size(); ++i){
|
||||
if (cur_matching[i] != e_1) {
|
||||
std::cout << cur_matching[i]- b_1 << " ";
|
||||
} else {
|
||||
std::cout << -1 << " ";
|
||||
}
|
||||
}
|
||||
std::cout << std::endl;*/
|
||||
|
||||
std::vector<Point> cp_0, cp_1;
|
||||
{
|
||||
It0 c_0= b_0;
|
||||
for (ItM c_m= cur_matching.begin(); c_m != cur_matching.end(); ++c_m, ++c_0 ){
|
||||
if (*c_m != e_1){
|
||||
cp_0.push_back(*c_0);
|
||||
cp_1.push_back(**c_m);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tr = transform_taking_first_to_second(cp_0.begin(),cp_0.end(),
|
||||
cp_1.begin(), cp_1.end());
|
||||
//std::cout << tr << std::endl;
|
||||
|
||||
double sum_dist=0;
|
||||
unsigned int i=0;
|
||||
for (It0 c_0=b_0; c_0 != e_0; ++c_0, ++i){
|
||||
Point pn= tr(*c_0);
|
||||
sum_dist+= std::sqrt(sd(pn, p_0[i]));
|
||||
p_0[i]=pn;
|
||||
}
|
||||
|
||||
dist=sum_dist/(std::distance(b_0, e_0));
|
||||
|
||||
std::cout << "Moved " << dist << std::endl;
|
||||
|
||||
} while (dist > motion);
|
||||
|
||||
It1 c_1= b_1;
|
||||
int o_1=0;
|
||||
for (typename std::vector<It1>::const_iterator it= cur_matching.begin();
|
||||
it != cur_matching.end(); ++it){
|
||||
if (*it == e_1){
|
||||
*m= e_1;
|
||||
++m;
|
||||
} else {
|
||||
while (o_1 < std::distance(b_1, *it)){
|
||||
++o_1;
|
||||
++c_1;
|
||||
}
|
||||
*m= c_1;
|
||||
++m;
|
||||
}
|
||||
}
|
||||
|
||||
return tr;
|
||||
}
|
||||
|
||||
CGAL_PDB_END_NAMESPACE
|
||||
#endif
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
#ifndef CGAL_PDB_BASIC_H
|
||||
#define CGAL_PDB_BASIC_H
|
||||
#include <CGAL/basic.h>
|
||||
|
||||
#define CGAL_PDB_BEGIN_NAMESPACE CGAL_BEGIN_NAMESPACE namespace PDB{
|
||||
#define CGAL_PDB_END_NAMESPACE CGAL_END_NAMESPACE }
|
||||
#define CGAL_PDB_NS CGAL::PDB
|
||||
|
||||
#define CGAL_PDB_BEGIN_INTERNAL_NAMESPACE CGAL_BEGIN_NAMESPACE namespace PDB_internal{
|
||||
#define CGAL_PDB_END_INTERNAL_NAMESPACE CGAL_END_NAMESPACE }
|
||||
#define CGAL_PDB_INTERNAL_NS CGAL::PDB_internal
|
||||
|
||||
#define CGAL_TNT_BEGIN_NAMESPACE CGAL_BEGIN_NAMESPACE namespace TNT {
|
||||
#define CGAL_TNT_END_NAMESPACE CGAL_END_NAMESPACE }
|
||||
#define CGAL_TNT_NS CGAL::TNT
|
||||
|
||||
#define CGAL_JAMA_BEGIN_NAMESPACE CGAL_BEGIN_NAMESPACE namespace JAMA {
|
||||
#define CGAL_JAMA_END_NAMESPACE CGAL_END_NAMESPACE }
|
||||
#define CGAL_JAMA_NS CGAL::JAMA
|
||||
|
||||
|
||||
CGAL_BEGIN_NAMESPACE
|
||||
//! All exposed classes are put in this namespace.
|
||||
namespace PDB {
|
||||
}
|
||||
CGAL_END_NAMESPACE
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -1,102 +0,0 @@
|
|||
/* Copyright 2004
|
||||
Stanford University
|
||||
|
||||
This file is part of the DSR PDB Library.
|
||||
|
||||
The DSR PDB Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The DSR PDB Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the DSR PDB Library; see the file LICENSE.LGPL. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#ifndef CGAL_DSR_PDB_CGAL_H
|
||||
#define CGAL_DSR_PDB_CGAL_H
|
||||
#include <CGAL/PDB/basic.h>
|
||||
#include <CGAL/PDB/Protein.h>
|
||||
#include <CGAL/PDB/PDB.h>
|
||||
#include <CGAL/PDB/iterator.h>
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
CGAL_PDB_BEGIN_NAMESPACE
|
||||
|
||||
/*! Output a CGAL::Weighted_point_3 for each atom. It takes an
|
||||
instance of CGAL::Regular_triangulation_traits_3 as an argument to
|
||||
get the types from it.
|
||||
|
||||
The weight is the squared radius.
|
||||
*/
|
||||
template <class It, class K, class Voit>
|
||||
inline void all_weighted_points(It b, It e, K, Voit out){
|
||||
typedef typename K::Weighted_point WP;
|
||||
typedef typename K::Bare_point BP;
|
||||
for (; b != e; ++b){
|
||||
*out= WP(BP(b->second.cartesian_coords().x(), b->second.cartesian_coords().y(), b->second.cartesian_coords().z()),
|
||||
b->second.radius()*b->second.radius());
|
||||
++out;
|
||||
}
|
||||
}
|
||||
|
||||
/*! Output a CGAL::Weighted_point_3 for each atom. It takes an
|
||||
instance of CGAL::Regular_triangulation_traits_3 as an argument to
|
||||
get the types from it. The points for HETATM records are also
|
||||
returned.
|
||||
|
||||
The weight is the squared radius.
|
||||
*/
|
||||
template <class K, class Voit>
|
||||
inline void all_weighted_points(const Model &m, K k, Voit out){
|
||||
for (typename Model::Const_chains_iterator it2= m.chains_begin();
|
||||
it2 != m.chains_end(); ++it2){
|
||||
all_weighted_points(it2->atoms_begin(), it2->atoms_end(), k, out);
|
||||
}
|
||||
all_weighted_points(m.hetatoms_begin(), m.hetatoms_end(), k, out);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*! Output a CGAL::Weighted_point_3 for each atom. It takes an
|
||||
instance of CGAL::Regular_triangulation_traits_3 as an argument to
|
||||
get the types from it.
|
||||
|
||||
The weight is the squared radius.
|
||||
*/
|
||||
template < class K, class It, class Voit>
|
||||
inline void all_spheres(It b, It e, Voit out){
|
||||
typedef typename K::Sphere_3 S;
|
||||
typedef typename K::Point_3 P;
|
||||
for (; b != e; ++b){
|
||||
*out= S(P(b->second.cartesian_coords().x(),
|
||||
b->second.cartesian_coords().y(),
|
||||
b->second.cartesian_coords().z()),
|
||||
b->second.radius()*b->second.radius());
|
||||
++out;
|
||||
}
|
||||
}
|
||||
|
||||
/*! Output a CGAL::Sphere_3 for each atom. The points for HETATM
|
||||
records are also returned.
|
||||
|
||||
The weight is the squared radius.
|
||||
*/
|
||||
template <class K, class Voit>
|
||||
inline void all_spheres(const Model &m,Voit out){
|
||||
for (typename Model::Const_chains_iterator it2= m.chains_begin();
|
||||
it2 != m.chains_end(); ++it2){
|
||||
all_spheres<K>(it2->atoms_begin(), it2->atoms_end(), out);
|
||||
}
|
||||
all_spheres<K>(m.hetatoms_begin(), m.hetatoms_end(), out);
|
||||
}
|
||||
|
||||
CGAL_PDB_END_NAMESPACE
|
||||
#endif
|
||||
|
|
@ -1,108 +0,0 @@
|
|||
/* Copyright 2004
|
||||
Stanford University
|
||||
|
||||
This file is part of the DSR PDB Library.
|
||||
|
||||
The DSR PDB Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The DSR PDB Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the DSR PDB Library; see the file LICENSE.LGPL. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
|
||||
#ifndef CGAL_DSRPDB_RMS_H
|
||||
#define CGAL_DSRPDB_RMS_H
|
||||
#include <CGAL/PDB/basic.h>
|
||||
#include <CGAL/PDB/Protein.h>
|
||||
#include <CGAL/PDB/geometry.h>
|
||||
#include <CGAL/PDB/Matrix.h>
|
||||
#include <cmath>
|
||||
#include <vector>
|
||||
CGAL_PDB_BEGIN_NAMESPACE
|
||||
//! Compute the all-atom cRMS with no alignment.
|
||||
/*! This function assumes that a, and b have already been rigidly
|
||||
aligned externally.
|
||||
|
||||
\pre {a and b must have the same number of atoms. This is checked.}
|
||||
|
||||
See pdb_distance.cc for an example.
|
||||
*/
|
||||
double no_align_cRMS(const Protein &a, const Protein &b);
|
||||
|
||||
|
||||
//! Compute the calpha cRMS without aligning the proteins.
|
||||
/*!
|
||||
\pre {a and b must have the same number of atoms. This is checked.}
|
||||
|
||||
See pdb_distance.cc for an example.
|
||||
*/
|
||||
double no_align_ca_cRMS(const Protein &a, const Protein &b);
|
||||
|
||||
|
||||
//! Compute the all-atom cRMS between two proteins
|
||||
/*!
|
||||
\pre {a and b must have the same number of atoms. This is checked.}
|
||||
*/
|
||||
double cRMS(const Protein &a, const Protein &b);
|
||||
|
||||
|
||||
//! Compute the C_alpha cRMS between two proteins
|
||||
/*!
|
||||
\pre {a and b must have the same number of atoms. This is checked.}
|
||||
*/
|
||||
double ca_cRMS(const Protein &a, const Protein &b);
|
||||
|
||||
|
||||
//! Compute the all-atom dRMS between two proteins
|
||||
/*!
|
||||
\pre {a and b must have the same number of atoms. This is checked.}
|
||||
|
||||
See pdb_distance.cc for an example.
|
||||
*/
|
||||
double dRMS(const Protein &a, const Protein &b);
|
||||
|
||||
|
||||
//! Compute the C_alpha cRMS between two proteins
|
||||
/*!
|
||||
\pre {a and b must have the same number of atoms. This is checked.}
|
||||
|
||||
See pdb_distance.cc for an example.
|
||||
*/
|
||||
double ca_dRMS(const Protein &a, const Protein &b);
|
||||
|
||||
|
||||
//! Return the distance matrix of a protein
|
||||
/*!
|
||||
See pdb_distance_matrix.cc for an example.
|
||||
*/
|
||||
Matrix distance_matrix(const Protein &a);
|
||||
|
||||
|
||||
//! Return the C_alpha distance matrix of a protein
|
||||
Matrix ca_distance_matrix(const Protein &a);
|
||||
|
||||
//! Return the backbone atom distance matrix of a protein
|
||||
Matrix backbone_distance_matrix(const Protein &a);
|
||||
|
||||
|
||||
//! Return the distance matrix of a protein
|
||||
Matrix distance_matrix(const Model &a);
|
||||
|
||||
|
||||
//! Return the C_alpha distance matrix of a protein
|
||||
Matrix ca_distance_matrix(const Model &a);
|
||||
|
||||
//! Return the backbone atom distance matrix of a protein
|
||||
Matrix backbone_distance_matrix(const Model &a);
|
||||
|
||||
CGAL_PDB_END_NAMESPACE
|
||||
#endif
|
||||
|
|
@ -1,159 +0,0 @@
|
|||
/* Copyright 2004
|
||||
Stanford University
|
||||
|
||||
This file is part of the DSR PDB Library.
|
||||
|
||||
The DSR PDB Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The DSR PDB Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the DSR PDB Library; see the file LICENSE.LGPL. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#ifndef CGAL_DSR_PDB_GEOMETRY_H
|
||||
#define CGAL_DSR_PDB_GEOMETRY_H
|
||||
#include <CGAL/PDB/basic.h>
|
||||
#include <CGAL/PDB/Protein.h>
|
||||
#include <CGAL/PDB/PDB.h>
|
||||
#include <CGAL/PDB/iterator.h>
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
#include <CGAL/PDB/geometry_internal.h>
|
||||
CGAL_PDB_BEGIN_NAMESPACE
|
||||
//! Insert all the atom coordinates from the list in to the output iterator.
|
||||
/*! See the file check_protein.cc for an example of usage. Either
|
||||
CGAL::PDB::Residue::Atoms_iterator or CGAL::PDB::Protein::Atoms_iterator
|
||||
are appropriate input.
|
||||
*/
|
||||
template <class Ait, class Voit>
|
||||
inline void coordinates(Ait ab, Ait ae, Voit out){
|
||||
CGAL_PDB_INTERNAL_NS::filtered_coordinates(ab, ae, Yes(), out);
|
||||
}
|
||||
|
||||
//! Insert all the backbone atom coordinates from the list in to the output iterator.
|
||||
/*! See the file check_protein.cc for an example of usage. Either
|
||||
CGAL::PDB::Residue::Atoms_iterator or CGAL::PDB::Protein::Atoms_iterator
|
||||
are appropriate input.
|
||||
*/
|
||||
template <class Ait, class Voit>
|
||||
inline void backbone_coordinates(Ait ab, Ait ae, Voit out){
|
||||
CGAL_PDB_INTERNAL_NS::filtered_coordinates(ab, ae, Is_backbone(), out);
|
||||
}
|
||||
|
||||
//! Insert all the c_alpha coordinates from the list in to the output iterator.
|
||||
/*! See the file check_protein.cc for an example of usage. Either
|
||||
CGAL::PDB::Residue::Atoms_iterator or CGAL::PDB::Protein::Atoms_iterator
|
||||
are appropriate input.
|
||||
*/
|
||||
template <class Ait, class Voit>
|
||||
inline void ca_coordinates(Ait ab, Ait ae, Voit out){
|
||||
CGAL_PDB_INTERNAL_NS::filtered_coordinates(ab, ae, Is_CA(), out);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*! Insert all the atom coordinates from the protein in to the
|
||||
output iterator and an edge corresponding to each bond in the
|
||||
second output iterator. The bonds differ from those returned by
|
||||
the bonds returned by the protein in that they are renumbered to
|
||||
correspond to the sequence positions of the atom coordinates.
|
||||
*/
|
||||
template <class Voit, class Boit>
|
||||
inline void coordinates_and_bonds(const Protein &p,
|
||||
Voit out, Boit bout){
|
||||
CGAL_PDB_INTERNAL_NS::filtered_coordinates_and_bonds(p, Yes(), out, bout);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*! Insert the backbone atom coordinates from the protein in to the
|
||||
output iterator and an edge corresponding to each bond in the
|
||||
second output iterator. The bonds differ from those returned by
|
||||
the bonds returned by the protein in that they are renumbered to
|
||||
correspond to the sequence positions of the atom coordinates.
|
||||
*/
|
||||
template <class Voit, class Boit>
|
||||
inline void backbone_coordinates_and_bonds(const Protein &p,
|
||||
Voit out, Boit bout){
|
||||
CGAL_PDB_INTERNAL_NS::filtered_coordinates_and_bonds(p, Is_backbone(), out, bout);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Inserts the backbone atoms and the sidechain centroids and appropriate bonds into the iterators
|
||||
/*! Note that this now returns all the backbone atoms and puts all
|
||||
the sidechains after allthe backbone atoms. The number of backbone
|
||||
atoms is returned.
|
||||
*/
|
||||
template <class Voit, class Boit>
|
||||
inline int simplified_coordinates_and_bonds(const Protein &p,
|
||||
Voit out, Boit bout){
|
||||
int index=-1;
|
||||
std::vector<int> ca_indices;
|
||||
//const Residue::Atom_label als[]={ Residue::AL_CA};
|
||||
for (Protein::Const_residues_iterator rit= p.residues_begin();
|
||||
rit != p.residues_end(); ++rit){
|
||||
//for (unsigned int i=0; i< 3; ++i){
|
||||
if (rit->has_atom(Residue::AL_N)){
|
||||
*out= rit->atom(Residue::AL_N).cartesian_coords();
|
||||
++out;
|
||||
++index;
|
||||
if (index != 0) {
|
||||
*bout = std::pair<int,int>(index-1, index);
|
||||
++bout;
|
||||
}
|
||||
}
|
||||
if (rit->has_atom(Residue::AL_CA)){
|
||||
*out= rit->atom(Residue::AL_CA).cartesian_coords();
|
||||
++out;
|
||||
|
||||
++index;
|
||||
if (index != 0) {
|
||||
*bout = std::pair<int,int>(index-1, index);
|
||||
++bout;
|
||||
}
|
||||
ca_indices.push_back(index);
|
||||
}
|
||||
if (rit->has_atom(Residue::AL_C)){
|
||||
*out= rit->atom(Residue::AL_C).cartesian_coords();
|
||||
++out;
|
||||
++index;
|
||||
if (index != 0) {
|
||||
*bout = std::pair<int,int>(index-1, index);
|
||||
++bout;
|
||||
}
|
||||
}
|
||||
}
|
||||
int nbackbone=index+1;
|
||||
int rindex=0;
|
||||
for (Protein::Const_residues_iterator rit= p.residues_begin();
|
||||
rit != p.residues_end(); ++rit){
|
||||
//for (unsigned int i=0; i< 3; ++i){
|
||||
if (rit->has_atom(Residue::AL_CA)){
|
||||
|
||||
Point spt= rit->sidechain_point();
|
||||
if (spt != rit->atom(Residue::AL_CA).cartesian_coords()) {
|
||||
*out = rit->sidechain_point();
|
||||
++out;
|
||||
|
||||
++index;
|
||||
|
||||
*bout = std::pair<int,int>(ca_indices[rindex], index);
|
||||
++bout;
|
||||
}
|
||||
++rindex;
|
||||
}
|
||||
}
|
||||
return nbackbone;
|
||||
}
|
||||
|
||||
CGAL_PDB_END_NAMESPACE
|
||||
#endif
|
||||
|
|
@ -1,69 +0,0 @@
|
|||
/* Copyright 2004
|
||||
Stanford University
|
||||
|
||||
This file is part of the DSR PDB Library.
|
||||
|
||||
The DSR PDB Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The DSR PDB Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the DSR PDB Library; see the file LICENSE.LGPL. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#ifndef CGAL_DSR_PDB_GEOMETRY_INTERNAL_H
|
||||
#define CGAL_DSR_PDB_GEOMETRY_INTERNAL_H
|
||||
#include <CGAL/PDB/basic.h>
|
||||
#include <CGAL/PDB/Protein.h>
|
||||
CGAL_PDB_BEGIN_INTERNAL_NAMESPACE
|
||||
|
||||
|
||||
template <class Filt, class Ait, class Voit>
|
||||
void filtered_coordinates(Ait ab, Ait ae, Filt f, Voit out){
|
||||
for (; ab != ae; ++ab){
|
||||
if (f(*ab)) {
|
||||
*out = ab->second.cartesian_coords();
|
||||
++out;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class Filt, class Voit, class Boit>
|
||||
void filtered_coordinates_and_bonds(const CGAL_PDB_NS::Protein &p, Filt f, Voit out, Boit bout){
|
||||
int na= p.number_of_atoms();
|
||||
std::vector<int> map(na, -1);
|
||||
int seen=0;
|
||||
for (typename CGAL_PDB_NS::Protein::Const_atoms_iterator it= p.atoms_begin(); it != p.atoms_end(); ++it){
|
||||
unsigned int index= it->second.index().to_index();
|
||||
if (index >= map.size()){
|
||||
map.resize(index+1, -1);
|
||||
}
|
||||
if (f(*it)) {
|
||||
map[index]= seen;
|
||||
++seen;
|
||||
*out = it->second.cartesian_coords();
|
||||
++out;
|
||||
}
|
||||
}
|
||||
|
||||
for (typename CGAL_PDB_NS::Protein::Bonds_iterator it= p.bonds_begin(); it != p.bonds_end(); ++it){
|
||||
assert(it->first != CGAL_PDB_NS::Atom::Index()
|
||||
&& it->second != CGAL_PDB_NS::Atom::Index());
|
||||
unsigned int a= it->first.to_index();
|
||||
unsigned int b= it->second.to_index();
|
||||
assert(a < map.size() && b < map.size());
|
||||
if (map[a] !=-1 && map[b]!=-1) {
|
||||
*bout = std::pair<int,int>(map[a], map[b]);
|
||||
++bout;
|
||||
}
|
||||
}
|
||||
}
|
||||
CGAL_PDB_END_INTERNAL_NAMESPACE
|
||||
#endif
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
#ifndef CGAL_DSR_PDB_ERROR_LOGGER_H
|
||||
#define CGAL_DSR_PDB_ERROR_LOGGER_H
|
||||
#include <CGAL/PDB/basic.h>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
CGAL_PDB_BEGIN_INTERNAL_NAMESPACE
|
||||
class Error_logger {
|
||||
public:
|
||||
Error_logger():enabled_(true){}
|
||||
~Error_logger(){dump();}
|
||||
|
||||
bool is_output() const {return enabled_;}
|
||||
void set_is_output(bool tf) { enabled_=tf;}
|
||||
|
||||
void set_context(const char *c) {
|
||||
context_=c;
|
||||
}
|
||||
|
||||
void new_warning(const char *c);
|
||||
|
||||
void new_fatal_error(const char *c);
|
||||
|
||||
void new_internal_error(const char *c);
|
||||
|
||||
void dump();
|
||||
|
||||
std::map<std::string, int> warnings_;
|
||||
bool enabled_;
|
||||
std::string context_;
|
||||
};
|
||||
|
||||
extern Error_logger error_logger;
|
||||
|
||||
CGAL_PDB_END_INTERNAL_NAMESPACE
|
||||
#endif
|
||||
|
|
@ -1,91 +0,0 @@
|
|||
#ifndef CGAL_DSR_PDB_INTERNAL_RESIDUE_DATA_H
|
||||
#define CGAL_DSR_PDB_INTERNAL_RESIDUE_DATA_H
|
||||
#include <CGAL/PDB/basic.h>
|
||||
#include <CGAL/PDB/Residue.h>
|
||||
|
||||
CGAL_PDB_BEGIN_NAMESPACE
|
||||
|
||||
//! This namespace holds the data for initializating residue data.
|
||||
/*!
|
||||
\ingroup expansion
|
||||
*/
|
||||
namespace Residue_data {
|
||||
//! A bond which might be in the residue.
|
||||
/*!
|
||||
Bonds might not be there due to missing atoms.
|
||||
*/
|
||||
typedef std::pair<Residue::Atom_label, Residue::Atom_label> Possible_bond;
|
||||
|
||||
//! This structure is used to store the bonds and atoms in each residue type.
|
||||
/*!
|
||||
\ingroup expansion
|
||||
*/
|
||||
struct Amino_acid_data {
|
||||
std::vector<Residue::Atom_label> atoms;
|
||||
std::vector<Possible_bond > bonds;
|
||||
std::vector<Residue::Atom_label> extremes;
|
||||
};
|
||||
|
||||
|
||||
//! This is the mapping between strings PDB::Residue::Atom_label and PDB::Atom::Type
|
||||
/*!
|
||||
\ingroup expansion
|
||||
*/
|
||||
class Atom_data {
|
||||
public:
|
||||
char s[5];
|
||||
Residue::Atom_label l;
|
||||
Atom::Type t;
|
||||
};
|
||||
|
||||
|
||||
//! This structure is used to initialize the per-residue atom and bond data.
|
||||
/*!
|
||||
\ingroup expansion
|
||||
*/
|
||||
struct Residue_init_data {
|
||||
Residue::Atom_label* atms_;
|
||||
Residue::Atom_label* bnds_;
|
||||
Residue::Atom_label* extr_;
|
||||
};
|
||||
|
||||
|
||||
//! This struct is used to map between alternate names of atoms.
|
||||
/*!
|
||||
\ingroup expansion
|
||||
*/
|
||||
struct Atom_fallback_data {
|
||||
Residue::Atom_label l;
|
||||
Residue::Atom_label lr;
|
||||
};
|
||||
|
||||
extern std::vector<Amino_acid_data > amino_acid_data_; // used
|
||||
extern Atom_fallback_data atom_fallback_data_[]; // used
|
||||
extern Atom_data atom_name_data_[]; // used
|
||||
|
||||
//! This is the mapping between atom string names in the pdb and atom labels.
|
||||
/*! See Residue_data.cc to change this.
|
||||
|
||||
\ingroup expansion
|
||||
*/
|
||||
extern Atom_data clean_atom_name_data_[]; //used
|
||||
extern bool amino_acid_initialized_;
|
||||
|
||||
Residue_init_data get_residue_initialization_data(Residue::Type rl);
|
||||
|
||||
const Amino_acid_data& amino_acid_data(int i);
|
||||
|
||||
void do_initialize();
|
||||
|
||||
inline void initialize() {
|
||||
if (!amino_acid_initialized_) {
|
||||
do_initialize();
|
||||
}
|
||||
}
|
||||
|
||||
Residue::Atom_label fix_atom_label(Residue::Type t, Residue::Atom_label al);
|
||||
|
||||
|
||||
}
|
||||
CGAL_PDB_END_NAMESPACE
|
||||
#endif
|
||||
|
|
@ -1,313 +0,0 @@
|
|||
#ifndef CGAL_DSR_ALIGN_POINTS_H_
|
||||
#define CGAL_DSR_ALIGN_POINTS_H_
|
||||
#include <CGAL/PDB/basic.h>
|
||||
#include <tnt/tnt_cmat.h>
|
||||
#include <CGAL/PDB/Point.h>
|
||||
#include <CGAL/PDB/Transform.h>
|
||||
#include <CGAL/PDB/internal/tnt/tnt_array2d.h>
|
||||
#include <CGAL/PDB/internal/tnt/tnt_array2d_utils.h>
|
||||
#include <CGAL/PDB/internal/tnt/jama_svd.h>
|
||||
#include <cassert>
|
||||
#include <vector>
|
||||
#include <iterator>
|
||||
|
||||
CGAL_PDB_BEGIN_INTERNAL_NAMESPACE
|
||||
|
||||
|
||||
template <class T>
|
||||
T det(const CGAL_TNT_NS::Array2D<T>& m) {
|
||||
assert(m.dim1() == 3);
|
||||
assert(m.dim2() == 3);
|
||||
|
||||
return (m[0][0]*(m[1][1]*m[2][2] - m[1][2]*m[2][1]) -
|
||||
m[0][1]*(m[1][0]*m[2][2] - m[1][2]*m[2][0]) +
|
||||
m[0][2]*(m[1][0]*m[2][1] - m[1][1]*m[2][0]));
|
||||
}
|
||||
|
||||
// Transpose a matrix
|
||||
template <class T>
|
||||
CGAL_TNT_NS::Array2D<T> transpose(const CGAL_TNT_NS::Array2D<T>& m) {
|
||||
CGAL_TNT_NS::Array2D<T> mt(m.dim2(), m.dim1());
|
||||
for (int i = 0; i < m.dim1(); i++) {
|
||||
for (int j = 0; j < m.dim2(); j++) {
|
||||
mt[j][i] = m[i][j];
|
||||
}
|
||||
}
|
||||
return mt;
|
||||
}
|
||||
|
||||
template <class InputIterator>
|
||||
CGAL_PDB_NS::Transform transform_taking_first_to_second(InputIterator pBegin, InputIterator pEnd,
|
||||
InputIterator qBegin, InputIterator qEnd) {
|
||||
|
||||
// compute the centroid of the points and transform
|
||||
// pointsets so that their centroids coinside
|
||||
|
||||
typedef typename InputIterator::value_type Point;
|
||||
typedef double RT;
|
||||
|
||||
CGAL_PDB_NS::Vector center_p(0,0,0), center_q(0,0,0);
|
||||
int num_p = 0;
|
||||
int num_q = 0;
|
||||
for (InputIterator p_it = pBegin; p_it != pEnd; ++p_it) {
|
||||
//double x= p_it->x();
|
||||
center_p = center_p+CGAL_PDB_NS::Vector(p_it->x(), p_it->y(), p_it->z());//((*p_it)-CGAL::ORIGIN);
|
||||
num_p++;
|
||||
}
|
||||
center_p = center_p/num_p;
|
||||
|
||||
for (InputIterator q_it = qBegin; q_it != qEnd; ++q_it) {
|
||||
center_q = center_q + CGAL_PDB_NS::Vector(q_it->x(), q_it->y(), q_it->z()); //((*q_it)-CGAL::ORIGIN);
|
||||
num_q++;
|
||||
}
|
||||
center_q = center_q/num_q;
|
||||
|
||||
assert(num_p == num_q);
|
||||
|
||||
std::vector<Point> p_shifted, q_shifted;
|
||||
p_shifted.reserve(num_p);
|
||||
q_shifted.reserve(num_q);
|
||||
for (InputIterator p_it = pBegin; p_it != pEnd; ++p_it) {
|
||||
p_shifted.push_back((*p_it) - center_p);
|
||||
}
|
||||
for (InputIterator q_it = qBegin; q_it != qEnd; ++q_it) {
|
||||
q_shifted.push_back((*q_it) - center_q);
|
||||
}
|
||||
|
||||
|
||||
// covariance matrix
|
||||
CGAL_TNT_NS::Array2D<RT> H(3, 3);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
H[i][j] = 0;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < num_p; i++) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
for (int k = 0; k < 3; k++) {
|
||||
H[j][k] += p_shifted[i][j]*q_shifted[i][k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CGAL_JAMA_NS::SVD<RT> svd(H);
|
||||
CGAL_TNT_NS::Array2D<RT> U(3, 3), V(3, 3);
|
||||
svd.getU(U);
|
||||
svd.getV(V);
|
||||
|
||||
// the rotation matrix is R = VU^T
|
||||
CGAL_TNT_NS::Array2D<RT> UT = transpose(U);
|
||||
CGAL_TNT_NS::Array2D<RT> rot(3, 3);
|
||||
rot = matmult(V, UT);
|
||||
|
||||
// check for reflection
|
||||
if (det(rot) < 0) {
|
||||
CGAL_TNT_NS::Array2D<RT> VT = transpose(V);
|
||||
CGAL_TNT_NS::Array2D<RT> UVT = matmult(U, VT);
|
||||
CGAL_TNT_NS::Array2D<RT> S(3, 3);
|
||||
S[0][0] = S[1][1] = 1;
|
||||
S[2][2] = det(UVT);
|
||||
S[0][1] = S[0][2] = S[1][0] = S[1][2] = S[2][0] = S[2][1] = 0;
|
||||
rot = matmult(matmult(U, S), VT);
|
||||
}
|
||||
|
||||
CGAL_PDB_NS::Transform xf(rot, Point(0,0,0));
|
||||
|
||||
xf.set_translation(center_q - xf(center_p));
|
||||
|
||||
return xf;
|
||||
}
|
||||
|
||||
|
||||
inline double structal_score(const dsrpdb::Point& a, const dsrpdb::Point& b) {
|
||||
dsrpdb::Squared_distance sd;
|
||||
return 20.0/(1.0+sd(a,b)/5.0);
|
||||
}
|
||||
|
||||
inline double gap_score() {
|
||||
return -10.0;
|
||||
}
|
||||
|
||||
struct DpP {
|
||||
double first;
|
||||
int second;
|
||||
DpP(double d, int s): first(d), second(s){}
|
||||
DpP(): first(-1), second(-3){}
|
||||
};
|
||||
|
||||
inline std::ostream &operator<<(std::ostream &o, DpP p){
|
||||
return o << "(" << p.first << " " << p.second << ")";
|
||||
}
|
||||
|
||||
template <class ItP, class ItM>
|
||||
void greedy_matching(ItP b_0, ItP e_0,
|
||||
ItP b_1, ItP e_1,
|
||||
ItM b_m, ItM e_m) {
|
||||
const double gap_cost=10.0;
|
||||
unsigned int d_0= std::distance(b_0, e_0);
|
||||
unsigned int d_1= std::distance(b_1, e_1);
|
||||
//typedef std::pair<double, int> DpP;
|
||||
CGAL_TNT_NS::Array2D<DpP> dp_matrix(d_0+2, d_1+2);
|
||||
|
||||
|
||||
std::vector<int> best_i(d_1+2);
|
||||
int best_j(0);
|
||||
|
||||
for (unsigned int i=0; i< d_0+1; ++i){
|
||||
dp_matrix[i][0]=DpP(-gap_cost*i,0);
|
||||
best_i[i]= 0;
|
||||
}
|
||||
best_i.back()= 0;
|
||||
|
||||
for (unsigned int i=0; i< d_1+1; ++i){
|
||||
dp_matrix[0][i]=DpP(-gap_cost*i,0);
|
||||
}
|
||||
|
||||
dp_matrix[0][d_1+1]=DpP(-gap_cost*d_1, 0);
|
||||
dp_matrix[d_0+1][0]=DpP(-gap_cost*d_0, 0);
|
||||
|
||||
{
|
||||
ItP c_0=b_0;
|
||||
for (unsigned int i=1; i< d_0+2; ++i, ++c_0){
|
||||
ItP c_1= b_1;
|
||||
best_j= 0;
|
||||
for (unsigned int j=1; j< d_1+2; ++j, ++c_1){
|
||||
double ss;
|
||||
if (c_0== e_0 || c_1==e_1) {
|
||||
ss= 0;
|
||||
} else {
|
||||
ss= structal_score(*c_0, *c_1);
|
||||
}
|
||||
|
||||
|
||||
double v_d= dp_matrix[i-1][j-1].first;
|
||||
double v_i= -gap_cost*best_i[j-1] + dp_matrix[i-best_i[j-1]-1][j-1].first;
|
||||
double v_j= -gap_cost*best_j + dp_matrix[i-1][j-best_j-1].first;
|
||||
|
||||
if (v_d >= v_i && v_d >= v_j){
|
||||
dp_matrix[i][j]= DpP(ss+v_d, 0);
|
||||
best_i[j-1]=0;
|
||||
best_j=0;
|
||||
} else if (v_i >= v_j){
|
||||
dp_matrix[i][j] = DpP(ss+v_i, best_i[j-1]);
|
||||
assert(v_i > v_d);
|
||||
if (v_d >= v_j) best_j=0;
|
||||
} else {
|
||||
dp_matrix[i][j] = DpP(ss+v_j, -best_j);
|
||||
if (v_d >= v_i) best_i[j-1]=0;
|
||||
}
|
||||
|
||||
const double eps=.00001;
|
||||
|
||||
for (unsigned int k=0; k< i; ++k){
|
||||
assert(dp_matrix[i-k-1][j-1].first -gap_cost*k +ss <= dp_matrix[i][j].first + eps);
|
||||
if (dp_matrix[i][j].second == static_cast<int>(k)) {
|
||||
assert(std::abs(dp_matrix[i-k-1][j-1].first - gap_cost*k + ss - dp_matrix[i][j].first) < eps);
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned int k=0; k< j; ++k){
|
||||
assert(dp_matrix[i-1][j-k-1].first -gap_cost*k + ss <= dp_matrix[i][j].first + eps);
|
||||
if (dp_matrix[i][j].second == -static_cast<int>(k)) {
|
||||
assert( std::abs(ss - gap_cost*k + dp_matrix[i-1][j-k-1].first - dp_matrix[i][j].first) < eps);
|
||||
}
|
||||
}
|
||||
|
||||
++best_i[j-1];
|
||||
++best_j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*std::cout.precision(2);
|
||||
std::cout << dp_matrix << std::endl;*/
|
||||
|
||||
// backtrace
|
||||
{
|
||||
unsigned int i=d_0+1, j= d_1+1;
|
||||
|
||||
ItM c_m= e_m; //--c_m;
|
||||
//bool set=false;
|
||||
while (i >0 && j > 0) {
|
||||
if (dp_matrix[i][j].second ==0){
|
||||
|
||||
} else if (dp_matrix[i][j].second < 0) {
|
||||
j-= std::abs(dp_matrix[i][j].second);
|
||||
} else {
|
||||
for (int k =0; k< dp_matrix[i][j].second; ++k){
|
||||
--c_m;
|
||||
*c_m=-1;
|
||||
}
|
||||
i-= dp_matrix[i][j].second;
|
||||
}
|
||||
--i;
|
||||
--j;
|
||||
|
||||
if (i==0 || j==0) break;
|
||||
assert(c_m != b_m);
|
||||
--c_m;
|
||||
assert(j < d_1+1);
|
||||
assert(i < d_0+1);
|
||||
*c_m=j-1;
|
||||
//std::cout << i << " " << j << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <class ItP, class OItM>
|
||||
CGAL_PDB_NS::Transform refine_alignment(ItP b_0, ItP e_0,
|
||||
ItP b_1, ItP e_1,
|
||||
double motion,
|
||||
OItM m) {
|
||||
|
||||
std::vector<CGAL_PDB_NS::Point> p_0(b_0, e_0), p_1(b_1, e_1);
|
||||
double dist= std::numeric_limits<double>::infinity();
|
||||
CGAL_PDB_NS::Squared_distance sd;
|
||||
|
||||
typedef std::vector<int>::const_iterator ItM;
|
||||
std::vector<int> cur_matching(std::distance(b_0, e_0), -1);
|
||||
CGAL_PDB_NS::Transform tr;
|
||||
do {
|
||||
greedy_matching(p_0.begin(), p_0.end(),
|
||||
p_1.begin(), p_1.end(),
|
||||
cur_matching.begin(), cur_matching.end());
|
||||
|
||||
/*std::copy(cur_matching.begin(), cur_matching.end(), std::ostream_iterator<int>(std::cout, " "));
|
||||
std::cout << std::endl;*/
|
||||
|
||||
std::vector<CGAL_PDB_NS::Point> cp_0, cp_1;
|
||||
{
|
||||
ItP c_0= b_0;
|
||||
for (ItM c_m= cur_matching.begin(); c_m != cur_matching.end(); ++c_m, ++c_0 ){
|
||||
if (*c_m != -1){
|
||||
cp_0.push_back(*c_0);
|
||||
cp_1.push_back(p_1[*c_m]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tr = transform_taking_first_to_second(cp_0.begin(),cp_0.end(),
|
||||
cp_1.begin(), cp_1.end());
|
||||
//std::cout << tr << std::endl;
|
||||
|
||||
double sum_dist=0;
|
||||
unsigned int i=0;
|
||||
for (ItP c_0=b_0; c_0 != e_0; ++c_0, ++i){
|
||||
dsrpdb::Point pn= tr(*c_0);
|
||||
sum_dist+= sd(pn, p_0[i]);
|
||||
p_0[i]=pn;
|
||||
}
|
||||
|
||||
dist=std::sqrt(sum_dist)/std::distance(b_0, e_0);
|
||||
|
||||
std::cout << "Moved " << dist << std::endl;
|
||||
|
||||
} while (dist > motion);
|
||||
std::copy(cur_matching.begin(), cur_matching.end(), m);
|
||||
return tr;
|
||||
}
|
||||
|
||||
CGAL_PDB_END_INTERNAL_NAMESPACE
|
||||
#endif
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
/* Copyright 2004
|
||||
Stanford University
|
||||
|
||||
This file is part of the DSR PDB Library.
|
||||
|
||||
The DSR PDB Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The DSR PDB Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the DSR PDB Library; see the file LICENSE.LGPL. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#ifndef CGAL_DSR_PDB_UTILS_H
|
||||
#define CGAL_DSR_PDB_UTILS_H
|
||||
#include <CGAL/PDB/basic.h>
|
||||
|
||||
CGAL_PDB_BEGIN_INTERNAL_NAMESPACE
|
||||
typedef enum Line_type {HEADER, DBREF, SEQRES, ATOM, HETATM, MASTER, ENDMDL, OTHER, TER, MODEL, END} Line_type;
|
||||
|
||||
Line_type line_type (const char* line);
|
||||
extern const char atom_line_iformat_[];
|
||||
extern const char hetatom_line_iformat_[];
|
||||
extern const char atom_line_oformat_[];
|
||||
extern const char hetatom_line_oformat_[];
|
||||
|
||||
CGAL_PDB_END_INTERNAL_NAMESPACE
|
||||
#endif
|
||||
|
|
@ -1,254 +0,0 @@
|
|||
|
||||
#ifndef CGAL_JAMA_CHOLESKY_H
|
||||
#define CGAL_JAMA_CHOLESKY_H
|
||||
#include <CGAL/PDB/basic.h>
|
||||
#include "math.h"
|
||||
/* needed for sqrt() below. */
|
||||
|
||||
CGAL_JAMA_BEGIN_NAMESPACE
|
||||
|
||||
using namespace CGAL_TNT_NS;
|
||||
|
||||
/**
|
||||
<P>
|
||||
For a symmetric, positive definite matrix A, this function
|
||||
computes the Cholesky factorization, i.e. it computes a lower
|
||||
triangular matrix L such that A = L*L'.
|
||||
If the matrix is not symmetric or positive definite, the function
|
||||
computes only a partial decomposition. This can be tested with
|
||||
the is_spd() flag.
|
||||
|
||||
<p>Typical usage looks like:
|
||||
<pre>
|
||||
Array2D<double> A(n,n);
|
||||
Array2D<double> L;
|
||||
|
||||
...
|
||||
|
||||
Cholesky<double> chol(A);
|
||||
|
||||
if (chol.is_spd())
|
||||
L = chol.getL();
|
||||
|
||||
else
|
||||
cout << "factorization was not complete.\n";
|
||||
|
||||
</pre>
|
||||
|
||||
|
||||
<p>
|
||||
(Adapted from JAMA, a Java Matrix Library, developed by jointly
|
||||
by the Mathworks and NIST; see http://math.nist.gov/javanumerics/jama).
|
||||
|
||||
*/
|
||||
|
||||
template <class Real>
|
||||
class Cholesky
|
||||
{
|
||||
Array2D<Real> L_; // lower triangular factor
|
||||
int isspd; // 1 if matrix to be factored was SPD
|
||||
|
||||
public:
|
||||
|
||||
Cholesky();
|
||||
Cholesky(const Array2D<Real> &A);
|
||||
Array2D<Real> getL() const;
|
||||
Array1D<Real> solve(const Array1D<Real> &B);
|
||||
Array2D<Real> solve(const Array2D<Real> &B);
|
||||
int is_spd() const;
|
||||
|
||||
};
|
||||
|
||||
template <class Real>
|
||||
Cholesky<Real>::Cholesky() : L_(0,0), isspd(0) {}
|
||||
|
||||
/**
|
||||
@return 1, if original matrix to be factored was symmetric
|
||||
positive-definite (SPD).
|
||||
*/
|
||||
template <class Real>
|
||||
int Cholesky<Real>::is_spd() const
|
||||
{
|
||||
return isspd;
|
||||
}
|
||||
|
||||
/**
|
||||
@return the lower triangular factor, L, such that L*L'=A.
|
||||
*/
|
||||
template <class Real>
|
||||
Array2D<Real> Cholesky<Real>::getL() const
|
||||
{
|
||||
return L_;
|
||||
}
|
||||
|
||||
/**
|
||||
Constructs a lower triangular matrix L, such that L*L'= A.
|
||||
If A is not symmetric positive-definite (SPD), only a
|
||||
partial factorization is performed. If is_spd()
|
||||
evalutate true (1) then the factorizaiton was successful.
|
||||
*/
|
||||
template <class Real>
|
||||
Cholesky<Real>::Cholesky(const Array2D<Real> &A)
|
||||
{
|
||||
|
||||
|
||||
int m = A.dim1();
|
||||
int n = A.dim2();
|
||||
|
||||
isspd = (m == n);
|
||||
|
||||
if (m != n)
|
||||
{
|
||||
L_ = Array2D<Real>(0,0);
|
||||
return;
|
||||
}
|
||||
|
||||
L_ = Array2D<Real>(n,n);
|
||||
|
||||
|
||||
// Main loop.
|
||||
for (int j = 0; j < n; j++)
|
||||
{
|
||||
double d = 0.0;
|
||||
for (int k = 0; k < j; k++)
|
||||
{
|
||||
Real s = 0.0;
|
||||
for (int i = 0; i < k; i++)
|
||||
{
|
||||
s += L_[k][i]*L_[j][i];
|
||||
}
|
||||
L_[j][k] = s = (A[j][k] - s)/L_[k][k];
|
||||
d = d + s*s;
|
||||
isspd = isspd && (A[k][j] == A[j][k]);
|
||||
}
|
||||
d = A[j][j] - d;
|
||||
isspd = isspd && (d > 0.0);
|
||||
L_[j][j] = sqrt(d > 0.0 ? d : 0.0);
|
||||
for (int k = j+1; k < n; k++)
|
||||
{
|
||||
L_[j][k] = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Solve a linear system A*x = b, using the previously computed
|
||||
cholesky factorization of A: L*L'.
|
||||
|
||||
@param B A Matrix with as many rows as A and any number of columns.
|
||||
@return x so that L*L'*x = b. If b is nonconformat, or if A
|
||||
was not symmetric posidtive definite, a null (0x0)
|
||||
array is returned.
|
||||
*/
|
||||
template <class Real>
|
||||
Array1D<Real> Cholesky<Real>::solve(const Array1D<Real> &b)
|
||||
{
|
||||
int n = L_.dim1();
|
||||
if (b.dim1() != n)
|
||||
return Array1D<Real>();
|
||||
|
||||
|
||||
Array1D<Real> x = b.copy();
|
||||
|
||||
|
||||
// Solve L*y = b;
|
||||
for (int k = 0; k < n; k++)
|
||||
{
|
||||
for (int i = 0; i < k; i++)
|
||||
x[k] -= x[i]*L_[k][i];
|
||||
x[k] /= L_[k][k];
|
||||
|
||||
}
|
||||
|
||||
// Solve L'*X = Y;
|
||||
for (int k = n-1; k >= 0; k--)
|
||||
{
|
||||
for (int i = k+1; i < n; i++)
|
||||
x[k] -= x[i]*L_[i][k];
|
||||
x[k] /= L_[k][k];
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Solve a linear system A*X = B, using the previously computed
|
||||
cholesky factorization of A: L*L'.
|
||||
|
||||
@param B A Matrix with as many rows as A and any number of columns.
|
||||
@return X so that L*L'*X = B. If B is nonconformat, or if A
|
||||
was not symmetric posidtive definite, a null (0x0)
|
||||
array is returned.
|
||||
*/
|
||||
template <class Real>
|
||||
Array2D<Real> Cholesky<Real>::solve(const Array2D<Real> &B)
|
||||
{
|
||||
int n = L_.dim1();
|
||||
if (B.dim1() != n)
|
||||
return Array2D<Real>();
|
||||
|
||||
|
||||
Array2D<Real> X = B.copy();
|
||||
int nx = B.dim2();
|
||||
|
||||
// Cleve's original code
|
||||
#if 0
|
||||
// Solve L*Y = B;
|
||||
for (int k = 0; k < n; k++) {
|
||||
for (int i = k+1; i < n; i++) {
|
||||
for (int j = 0; j < nx; j++) {
|
||||
X[i][j] -= X[k][j]*L_[k][i];
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < nx; j++) {
|
||||
X[k][j] /= L_[k][k];
|
||||
}
|
||||
}
|
||||
|
||||
// Solve L'*X = Y;
|
||||
for (int k = n-1; k >= 0; k--) {
|
||||
for (int j = 0; j < nx; j++) {
|
||||
X[k][j] /= L_[k][k];
|
||||
}
|
||||
for (int i = 0; i < k; i++) {
|
||||
for (int j = 0; j < nx; j++) {
|
||||
X[i][j] -= X[k][j]*L_[k][i];
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// Solve L*y = b;
|
||||
for (int j=0; j< nx; j++)
|
||||
{
|
||||
for (int k = 0; k < n; k++)
|
||||
{
|
||||
for (int i = 0; i < k; i++)
|
||||
X[k][j] -= X[i][j]*L_[k][i];
|
||||
X[k][j] /= L_[k][k];
|
||||
}
|
||||
}
|
||||
|
||||
// Solve L'*X = Y;
|
||||
for (int j=0; j<nx; j++)
|
||||
{
|
||||
for (int k = n-1; k >= 0; k--)
|
||||
{
|
||||
for (int i = k+1; i < n; i++)
|
||||
X[k][j] -= X[i][j]*L_[i][k];
|
||||
X[k][j] /= L_[k][k];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return X;
|
||||
}
|
||||
|
||||
CGAL_JAMA_END_NAMESPACE
|
||||
#endif
|
||||
// JAMA_CHOLESKY_H
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,315 +0,0 @@
|
|||
#ifndef CGAL_JAMA_LU_H
|
||||
#define CGAL_JAMA_LU_H
|
||||
#include <CGAL/PDB/basic.h>
|
||||
#include "tnt.h"
|
||||
#include <algorithm>
|
||||
//for min(), max() below
|
||||
|
||||
CGAL_JAMA_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
/** LU Decomposition.
|
||||
<P>
|
||||
For an m-by-n matrix A with m >= n, the LU decomposition is an m-by-n
|
||||
unit lower triangular matrix L, an n-by-n upper triangular matrix U,
|
||||
and a permutation vector piv of length m so that A(piv,:) = L*U.
|
||||
If m < n, then L is m-by-m and U is m-by-n.
|
||||
<P>
|
||||
The LU decompostion with pivoting always exists, even if the matrix is
|
||||
singular, so the constructor will never fail. The primary use of the
|
||||
LU decomposition is in the solution of square systems of simultaneous
|
||||
linear equations. This will fail if isNonsingular() returns false.
|
||||
*/
|
||||
template <class Real>
|
||||
class LU
|
||||
{
|
||||
|
||||
|
||||
|
||||
/* Array for internal storage of decomposition. */
|
||||
Array2D<Real> LU_;
|
||||
int m, n, pivsign;
|
||||
Array1D<int> piv;
|
||||
|
||||
|
||||
Array2D<Real> permute_copy(const Array2D<Real> &A,
|
||||
const Array1D<int> &piv, int j0, int j1)
|
||||
{
|
||||
int piv_length = piv.dim();
|
||||
|
||||
Array2D<Real> X(piv_length, j1-j0+1);
|
||||
|
||||
|
||||
for (int i = 0; i < piv_length; i++)
|
||||
for (int j = j0; j <= j1; j++)
|
||||
X[i][j-j0] = A[piv[i]][j];
|
||||
|
||||
return X;
|
||||
}
|
||||
|
||||
Array1D<Real> permute_copy(const Array1D<Real> &A,
|
||||
const Array1D<int> &piv)
|
||||
{
|
||||
int piv_length = piv.dim();
|
||||
if (piv_length != A.dim())
|
||||
return Array1D<Real>();
|
||||
|
||||
Array1D<Real> x(piv_length);
|
||||
|
||||
|
||||
for (int i = 0; i < piv_length; i++)
|
||||
x[i] = A[piv[i]];
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
public :
|
||||
|
||||
/** LU Decomposition
|
||||
@param A Rectangular matrix
|
||||
@return LU Decomposition object to access L, U and piv.
|
||||
*/
|
||||
|
||||
LU (const Array2D<Real> &A) : LU_(A.copy()), m(A.dim1()), n(A.dim2()),
|
||||
piv(A.dim1())
|
||||
|
||||
{
|
||||
|
||||
// Use a "left-looking", dot-product, Crout/Doolittle algorithm.
|
||||
|
||||
|
||||
for (int i = 0; i < m; i++) {
|
||||
piv[i] = i;
|
||||
}
|
||||
pivsign = 1;
|
||||
Real *LUrowi = 0;;
|
||||
Array1D<Real> LUcolj(m);
|
||||
|
||||
// Outer loop.
|
||||
|
||||
for (int j = 0; j < n; j++) {
|
||||
|
||||
// Make a copy of the j-th column to localize references.
|
||||
|
||||
for (int i = 0; i < m; i++) {
|
||||
LUcolj[i] = LU_[i][j];
|
||||
}
|
||||
|
||||
// Apply previous transformations.
|
||||
|
||||
for (int i = 0; i < m; i++) {
|
||||
LUrowi = LU_[i];
|
||||
|
||||
// Most of the time is spent in the following dot product.
|
||||
|
||||
int kmax = min(i,j);
|
||||
double s = 0.0;
|
||||
for (int k = 0; k < kmax; k++) {
|
||||
s += LUrowi[k]*LUcolj[k];
|
||||
}
|
||||
|
||||
LUrowi[j] = LUcolj[i] -= s;
|
||||
}
|
||||
|
||||
// Find pivot and exchange if necessary.
|
||||
|
||||
int p = j;
|
||||
for (int i = j+1; i < m; i++) {
|
||||
if (abs(LUcolj[i]) > abs(LUcolj[p])) {
|
||||
p = i;
|
||||
}
|
||||
}
|
||||
if (p != j) {
|
||||
int k=0;
|
||||
for (k = 0; k < n; k++) {
|
||||
double t = LU_[p][k];
|
||||
LU_[p][k] = LU_[j][k];
|
||||
LU_[j][k] = t;
|
||||
}
|
||||
k = piv[p];
|
||||
piv[p] = piv[j];
|
||||
piv[j] = k;
|
||||
pivsign = -pivsign;
|
||||
}
|
||||
|
||||
// Compute multipliers.
|
||||
|
||||
if ((j < m) && (LU_[j][j] != 0.0)) {
|
||||
for (int i = j+1; i < m; i++) {
|
||||
LU_[i][j] /= LU_[j][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Is the matrix nonsingular?
|
||||
@return 1 (true) if upper triangular factor U (and hence A)
|
||||
is nonsingular, 0 otherwise.
|
||||
*/
|
||||
|
||||
int isNonsingular () {
|
||||
for (int j = 0; j < n; j++) {
|
||||
if (LU_[j][j] == 0)
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/** Return lower triangular factor
|
||||
@return L
|
||||
*/
|
||||
|
||||
Array2D<Real> getL () {
|
||||
Array2D<Real> L_(m,n);
|
||||
for (int i = 0; i < m; i++) {
|
||||
for (int j = 0; j < n; j++) {
|
||||
if (i > j) {
|
||||
L_[i][j] = LU_[i][j];
|
||||
} else if (i == j) {
|
||||
L_[i][j] = 1.0;
|
||||
} else {
|
||||
L_[i][j] = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return L_;
|
||||
}
|
||||
|
||||
/** Return upper triangular factor
|
||||
@return U portion of LU factorization.
|
||||
*/
|
||||
|
||||
Array2D<Real> getU () {
|
||||
Array2D<Real> U_(n,n);
|
||||
for (int i = 0; i < n; i++) {
|
||||
for (int j = 0; j < n; j++) {
|
||||
if (i <= j) {
|
||||
U_[i][j] = LU_[i][j];
|
||||
} else {
|
||||
U_[i][j] = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return U_;
|
||||
}
|
||||
|
||||
/** Return pivot permutation vector
|
||||
@return piv
|
||||
*/
|
||||
|
||||
Array1D<int> getPivot () {
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
/** Compute determinant using LU factors.
|
||||
@return determinant of A, or 0 if A is not square.
|
||||
*/
|
||||
|
||||
Real det () {
|
||||
if (m != n) {
|
||||
return Real(0);
|
||||
}
|
||||
Real d = Real(pivsign);
|
||||
for (int j = 0; j < n; j++) {
|
||||
d *= LU_[j][j];
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
/** Solve A*X = B
|
||||
@param B A Matrix with as many rows as A and any number of columns.
|
||||
@return X so that L*U*X = B(piv,:), if B is nonconformant, returns
|
||||
0x0 (null) array.
|
||||
*/
|
||||
|
||||
Array2D<Real> solve (const Array2D<Real> &B)
|
||||
{
|
||||
|
||||
/* Dimensions: A is mxn, X is nxk, B is mxk */
|
||||
|
||||
if (B.dim1() != m) {
|
||||
return Array2D<Real>(0,0);
|
||||
}
|
||||
if (!isNonsingular()) {
|
||||
return Array2D<Real>(0,0);
|
||||
}
|
||||
|
||||
// Copy right hand side with pivoting
|
||||
int nx = B.dim2();
|
||||
|
||||
|
||||
Array2D<Real> X = permute_copy(B, piv, 0, nx-1);
|
||||
|
||||
// Solve L*Y = B(piv,:)
|
||||
for (int k = 0; k < n; k++) {
|
||||
for (int i = k+1; i < n; i++) {
|
||||
for (int j = 0; j < nx; j++) {
|
||||
X[i][j] -= X[k][j]*LU_[i][k];
|
||||
}
|
||||
}
|
||||
}
|
||||
// Solve U*X = Y;
|
||||
for (int k = n-1; k >= 0; k--) {
|
||||
for (int j = 0; j < nx; j++) {
|
||||
X[k][j] /= LU_[k][k];
|
||||
}
|
||||
for (int i = 0; i < k; i++) {
|
||||
for (int j = 0; j < nx; j++) {
|
||||
X[i][j] -= X[k][j]*LU_[i][k];
|
||||
}
|
||||
}
|
||||
}
|
||||
return X;
|
||||
}
|
||||
|
||||
|
||||
/** Solve A*x = b, where x and b are vectors of length equal
|
||||
to the number of rows in A.
|
||||
|
||||
@param b a vector (Array1D> of length equal to the first dimension
|
||||
of A.
|
||||
@return x a vector (Array1D> so that L*U*x = b(piv), if B is nonconformant,
|
||||
returns 0x0 (null) array.
|
||||
*/
|
||||
|
||||
Array1D<Real> solve (const Array1D<Real> &b)
|
||||
{
|
||||
|
||||
/* Dimensions: A is mxn, X is nxk, B is mxk */
|
||||
|
||||
if (b.dim1() != m) {
|
||||
return Array1D<Real>();
|
||||
}
|
||||
if (!isNonsingular()) {
|
||||
return Array1D<Real>();
|
||||
}
|
||||
|
||||
|
||||
Array1D<Real> x = permute_copy(b, piv);
|
||||
|
||||
// Solve L*Y = B(piv)
|
||||
for (int k = 0; k < n; k++) {
|
||||
for (int i = k+1; i < n; i++) {
|
||||
x[i] -= x[k]*LU_[i][k];
|
||||
}
|
||||
}
|
||||
|
||||
// Solve U*X = Y;
|
||||
for (int k = n-1; k >= 0; k--) {
|
||||
x[k] /= LU_[k][k];
|
||||
for (int i = 0; i < k; i++)
|
||||
x[i] -= x[k]*LU_[i][k];
|
||||
}
|
||||
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
}; /* class LU */
|
||||
|
||||
CGAL_JAMA_END_NAMESPACE
|
||||
#endif
|
||||
/* JAMA_LU_H */
|
||||
|
|
@ -1,323 +0,0 @@
|
|||
#ifndef CGAL_JAMA_QR_H
|
||||
#define CGAL_JAMA_QR_H
|
||||
#include <CGAL/PDB/basic.h>
|
||||
#include "tnt_array1d.h"
|
||||
#include "tnt_array2d.h"
|
||||
#include "tnt_math_utils.h"
|
||||
CGAL_JAMA_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
/**
|
||||
<p>
|
||||
Classical QR Decompisition:
|
||||
for an m-by-n matrix A with m >= n, the QR decomposition is an m-by-n
|
||||
orthogonal matrix Q and an n-by-n upper triangular matrix R so that
|
||||
A = Q*R.
|
||||
<P>
|
||||
The QR decompostion always exists, even if the matrix does not have
|
||||
full rank, so the constructor will never fail. The primary use of the
|
||||
QR decomposition is in the least squares solution of nonsquare systems
|
||||
of simultaneous linear equations. This will fail if isFullRank()
|
||||
returns 0 (false).
|
||||
|
||||
<p>
|
||||
The Q and R factors can be retrived via the getQ() and getR()
|
||||
methods. Furthermore, a solve() method is provided to find the
|
||||
least squares solution of Ax=b using the QR factors.
|
||||
|
||||
<p>
|
||||
(Adapted from JAMA, a Java Matrix Library, developed by jointly
|
||||
by the Mathworks and NIST; see http://math.nist.gov/javanumerics/jama).
|
||||
*/
|
||||
|
||||
template <class Real>
|
||||
class QR {
|
||||
|
||||
|
||||
/** Array for internal storage of decomposition.
|
||||
@serial internal array storage.
|
||||
*/
|
||||
|
||||
TNT::Array2D<Real> QR_;
|
||||
|
||||
/** Row and column dimensions.
|
||||
@serial column dimension.
|
||||
@serial row dimension.
|
||||
*/
|
||||
int m, n;
|
||||
|
||||
/** Array for internal storage of diagonal of R.
|
||||
@serial diagonal of R.
|
||||
*/
|
||||
TNT::Array1D<Real> Rdiag;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
Create a QR factorization object for A.
|
||||
|
||||
@param A rectangular (m>=n) matrix.
|
||||
*/
|
||||
QR(const TNT::Array2D<Real> &A) /* constructor */
|
||||
{
|
||||
QR_ = A.copy();
|
||||
m = A.dim1();
|
||||
n = A.dim2();
|
||||
Rdiag = TNT::Array1D<Real>(n);
|
||||
int i=0, j=0, k=0;
|
||||
|
||||
// Main loop.
|
||||
for (k = 0; k < n; k++) {
|
||||
// Compute 2-norm of k-th column without under/overflow.
|
||||
Real nrm = 0;
|
||||
for (i = k; i < m; i++) {
|
||||
nrm = hypot(nrm,QR_[i][k]);
|
||||
}
|
||||
|
||||
if (nrm != 0.0) {
|
||||
// Form k-th Householder vector.
|
||||
if (QR_[k][k] < 0) {
|
||||
nrm = -nrm;
|
||||
}
|
||||
for (i = k; i < m; i++) {
|
||||
QR_[i][k] /= nrm;
|
||||
}
|
||||
QR_[k][k] += 1.0;
|
||||
|
||||
// Apply transformation to remaining columns.
|
||||
for (j = k+1; j < n; j++) {
|
||||
Real s = 0.0;
|
||||
for (i = k; i < m; i++) {
|
||||
s += QR_[i][k]*QR_[i][j];
|
||||
}
|
||||
s = -s/QR_[k][k];
|
||||
for (i = k; i < m; i++) {
|
||||
QR_[i][j] += s*QR_[i][k];
|
||||
}
|
||||
}
|
||||
}
|
||||
Rdiag[k] = -nrm;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Flag to denote the matrix is of full rank.
|
||||
|
||||
@return 1 if matrix is full rank, 0 otherwise.
|
||||
*/
|
||||
int isFullRank() const
|
||||
{
|
||||
for (int j = 0; j < n; j++)
|
||||
{
|
||||
if (Rdiag[j] == 0)
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Retreive the Householder vectors from QR factorization
|
||||
@returns lower trapezoidal matrix whose columns define the reflections
|
||||
*/
|
||||
|
||||
TNT::Array2D<Real> getHouseholder (void) const
|
||||
{
|
||||
TNT::Array2D<Real> H(m,n);
|
||||
|
||||
/* note: H is completely filled in by algorithm, so
|
||||
initializaiton of H is not necessary.
|
||||
*/
|
||||
for (int i = 0; i < m; i++)
|
||||
{
|
||||
for (int j = 0; j < n; j++)
|
||||
{
|
||||
if (i >= j) {
|
||||
H[i][j] = QR_[i][j];
|
||||
} else {
|
||||
H[i][j] = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return H;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Return the upper triangular factor, R, of the QR factorization
|
||||
@return R
|
||||
*/
|
||||
|
||||
TNT::Array2D<Real> getR() const
|
||||
{
|
||||
TNT::Array2D<Real> R(n,n);
|
||||
for (int i = 0; i < n; i++) {
|
||||
for (int j = 0; j < n; j++) {
|
||||
if (i < j) {
|
||||
R[i][j] = QR_[i][j];
|
||||
} else if (i == j) {
|
||||
R[i][j] = Rdiag[i];
|
||||
} else {
|
||||
R[i][j] = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return R;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Generate and return the (economy-sized) orthogonal factor
|
||||
@param Q the (ecnomy-sized) orthogonal factor (Q*R=A).
|
||||
*/
|
||||
|
||||
TNT::Array2D<Real> getQ() const
|
||||
{
|
||||
int i=0, j=0, k=0;
|
||||
|
||||
TNT::Array2D<Real> Q(m,n);
|
||||
for (k = n-1; k >= 0; k--) {
|
||||
for (i = 0; i < m; i++) {
|
||||
Q[i][k] = 0.0;
|
||||
}
|
||||
Q[k][k] = 1.0;
|
||||
for (j = k; j < n; j++) {
|
||||
if (QR_[k][k] != 0) {
|
||||
Real s = 0.0;
|
||||
for (i = k; i < m; i++) {
|
||||
s += QR_[i][k]*Q[i][j];
|
||||
}
|
||||
s = -s/QR_[k][k];
|
||||
for (i = k; i < m; i++) {
|
||||
Q[i][j] += s*QR_[i][k];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Q;
|
||||
}
|
||||
|
||||
|
||||
/** Least squares solution of A*x = b
|
||||
@param B m-length array (vector).
|
||||
@return x n-length array (vector) that minimizes the two norm of Q*R*X-B.
|
||||
If B is non-conformant, or if QR.isFullRank() is false,
|
||||
the routine returns a null (0-length) vector.
|
||||
*/
|
||||
|
||||
TNT::Array1D<Real> solve(const TNT::Array1D<Real> &b) const
|
||||
{
|
||||
if (b.dim1() != m) /* arrays must be conformant */
|
||||
return TNT::Array1D<Real>();
|
||||
|
||||
if ( !isFullRank() ) /* matrix is rank deficient */
|
||||
{
|
||||
return TNT::Array1D<Real>();
|
||||
}
|
||||
|
||||
TNT::Array1D<Real> x = b.copy();
|
||||
|
||||
// Compute Y = transpose(Q)*b
|
||||
for (int k = 0; k < n; k++)
|
||||
{
|
||||
Real s = 0.0;
|
||||
for (int i = k; i < m; i++)
|
||||
{
|
||||
s += QR_[i][k]*x[i];
|
||||
}
|
||||
s = -s/QR_[k][k];
|
||||
for (int i = k; i < m; i++)
|
||||
{
|
||||
x[i] += s*QR_[i][k];
|
||||
}
|
||||
}
|
||||
// Solve R*X = Y;
|
||||
for (int k = n-1; k >= 0; k--)
|
||||
{
|
||||
x[k] /= Rdiag[k];
|
||||
for (int i = 0; i < k; i++) {
|
||||
x[i] -= x[k]*QR_[i][k];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* return n x nx portion of X */
|
||||
TNT::Array1D<Real> x_(n);
|
||||
for (int i=0; i<n; i++)
|
||||
x_[i] = x[i];
|
||||
|
||||
return x_;
|
||||
}
|
||||
|
||||
/** Least squares solution of A*X = B
|
||||
@param B m x k Array (must conform).
|
||||
@return X n x k Array that minimizes the two norm of Q*R*X-B. If
|
||||
B is non-conformant, or if QR.isFullRank() is false,
|
||||
the routine returns a null (0x0) array.
|
||||
*/
|
||||
|
||||
TNT::Array2D<Real> solve(const TNT::Array2D<Real> &B) const
|
||||
{
|
||||
if (B.dim1() != m) /* arrays must be conformant */
|
||||
return TNT::Array2D<Real>(0,0);
|
||||
|
||||
if ( !isFullRank() ) /* matrix is rank deficient */
|
||||
{
|
||||
return TNT::Array2D<Real>(0,0);
|
||||
}
|
||||
|
||||
int nx = B.dim2();
|
||||
TNT::Array2D<Real> X = B.copy();
|
||||
int i=0, j=0, k=0;
|
||||
|
||||
// Compute Y = transpose(Q)*B
|
||||
for (k = 0; k < n; k++) {
|
||||
for (j = 0; j < nx; j++) {
|
||||
Real s = 0.0;
|
||||
for (i = k; i < m; i++) {
|
||||
s += QR_[i][k]*X[i][j];
|
||||
}
|
||||
s = -s/QR_[k][k];
|
||||
for (i = k; i < m; i++) {
|
||||
X[i][j] += s*QR_[i][k];
|
||||
}
|
||||
}
|
||||
}
|
||||
// Solve R*X = Y;
|
||||
for (k = n-1; k >= 0; k--) {
|
||||
for (j = 0; j < nx; j++) {
|
||||
X[k][j] /= Rdiag[k];
|
||||
}
|
||||
for (i = 0; i < k; i++) {
|
||||
for (j = 0; j < nx; j++) {
|
||||
X[i][j] -= X[k][j]*QR_[i][k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* return n x nx portion of X */
|
||||
TNT::Array2D<Real> X_(n,nx);
|
||||
for (i=0; i<n; i++)
|
||||
for (j=0; j<nx; j++)
|
||||
X_[i][j] = X[i][j];
|
||||
|
||||
return X_;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
// namespace JAMA
|
||||
CGAL_JAMA_END_NAMESPACE
|
||||
#endif
|
||||
// JAMA_QR__H
|
||||
|
||||
|
|
@ -1,537 +0,0 @@
|
|||
#ifndef CGAL_JAMA_SVD_H
|
||||
#define CGAL_JAMA_SVD_H
|
||||
#include <CGAL/PDB/basic.h>
|
||||
|
||||
#include "tnt_array1d.h"
|
||||
#include "tnt_array1d_utils.h"
|
||||
#include "tnt_array2d.h"
|
||||
#include "tnt_array2d_utils.h"
|
||||
#include "tnt_math_utils.h"
|
||||
|
||||
#include <algorithm>
|
||||
// for min(), max() below
|
||||
#include <cmath>
|
||||
// for abs() below
|
||||
|
||||
CGAL_JAMA_BEGIN_NAMESPACE
|
||||
using namespace CGAL_TNT_NS;
|
||||
|
||||
|
||||
/** Singular Value Decomposition.
|
||||
<P>
|
||||
For an m-by-n matrix A with m >= n, the singular value decomposition is
|
||||
an m-by-n orthogonal matrix U, an n-by-n diagonal matrix S, and
|
||||
an n-by-n orthogonal matrix V so that A = U*S*V'.
|
||||
<P>
|
||||
The singular values, sigma[k] = S[k][k], are ordered so that
|
||||
sigma[0] >= sigma[1] >= ... >= sigma[n-1].
|
||||
<P>
|
||||
The singular value decompostion always exists, so the constructor will
|
||||
never fail. The matrix condition number and the effective numerical
|
||||
rank can be computed from this decomposition.
|
||||
|
||||
<p>
|
||||
(Adapted from JAMA, a Java Matrix Library, developed by jointly
|
||||
by the Mathworks and NIST; see http://math.nist.gov/javanumerics/jama).
|
||||
*/
|
||||
template <class Real>
|
||||
class SVD
|
||||
{
|
||||
|
||||
|
||||
Array2D<Real> U, V;
|
||||
Array1D<Real> s;
|
||||
int m, n;
|
||||
|
||||
public:
|
||||
|
||||
|
||||
SVD (const Array2D<Real> &Arg) {
|
||||
|
||||
|
||||
m = Arg.dim1();
|
||||
n = Arg.dim2();
|
||||
int nu = min(m,n);
|
||||
s = Array1D<Real>(min(m+1,n));
|
||||
U = Array2D<Real>(m, nu, Real(0));
|
||||
V = Array2D<Real>(n,n);
|
||||
Array1D<Real> e(n);
|
||||
Array1D<Real> work(m);
|
||||
Array2D<Real> A(Arg.copy());
|
||||
int wantu = 1; /* boolean */
|
||||
int wantv = 1; /* boolean */
|
||||
int i=0, j=0, k=0;
|
||||
|
||||
// Reduce A to bidiagonal form, storing the diagonal elements
|
||||
// in s and the super-diagonal elements in e.
|
||||
|
||||
int nct = min(m-1,n);
|
||||
int nrt = max(0,min(n-2,m));
|
||||
for (k = 0; k < max(nct,nrt); k++) {
|
||||
if (k < nct) {
|
||||
|
||||
// Compute the transformation for the k-th column and
|
||||
// place the k-th diagonal in s[k].
|
||||
// Compute 2-norm of k-th column without under/overflow.
|
||||
s[k] = 0;
|
||||
for (i = k; i < m; i++) {
|
||||
s[k] = hypot(s[k],A[i][k]);
|
||||
}
|
||||
if (s[k] != 0.0) {
|
||||
if (A[k][k] < 0.0) {
|
||||
s[k] = -s[k];
|
||||
}
|
||||
for (i = k; i < m; i++) {
|
||||
A[i][k] /= s[k];
|
||||
}
|
||||
A[k][k] += 1.0;
|
||||
}
|
||||
s[k] = -s[k];
|
||||
}
|
||||
for (j = k+1; j < n; j++) {
|
||||
if ((k < nct) && (s[k] != 0.0)) {
|
||||
|
||||
// Apply the transformation.
|
||||
|
||||
double t = 0;
|
||||
for (i = k; i < m; i++) {
|
||||
t += A[i][k]*A[i][j];
|
||||
}
|
||||
t = -t/A[k][k];
|
||||
for (i = k; i < m; i++) {
|
||||
A[i][j] += t*A[i][k];
|
||||
}
|
||||
}
|
||||
|
||||
// Place the k-th row of A into e for the
|
||||
// subsequent calculation of the row transformation.
|
||||
|
||||
e[j] = A[k][j];
|
||||
}
|
||||
if (wantu & (k < nct)) {
|
||||
|
||||
// Place the transformation in U for subsequent back
|
||||
// multiplication.
|
||||
|
||||
for (i = k; i < m; i++) {
|
||||
U[i][k] = A[i][k];
|
||||
}
|
||||
}
|
||||
if (k < nrt) {
|
||||
|
||||
// Compute the k-th row transformation and place the
|
||||
// k-th super-diagonal in e[k].
|
||||
// Compute 2-norm without under/overflow.
|
||||
e[k] = 0;
|
||||
for (i = k+1; i < n; i++) {
|
||||
e[k] = hypot(e[k],e[i]);
|
||||
}
|
||||
if (e[k] != 0.0) {
|
||||
if (e[k+1] < 0.0) {
|
||||
e[k] = -e[k];
|
||||
}
|
||||
for (i = k+1; i < n; i++) {
|
||||
e[i] /= e[k];
|
||||
}
|
||||
e[k+1] += 1.0;
|
||||
}
|
||||
e[k] = -e[k];
|
||||
if ((k+1 < m) & (e[k] != 0.0)) {
|
||||
|
||||
// Apply the transformation.
|
||||
|
||||
for (i = k+1; i < m; i++) {
|
||||
work[i] = 0.0;
|
||||
}
|
||||
for (j = k+1; j < n; j++) {
|
||||
for (i = k+1; i < m; i++) {
|
||||
work[i] += e[j]*A[i][j];
|
||||
}
|
||||
}
|
||||
for (j = k+1; j < n; j++) {
|
||||
double t = -e[j]/e[k+1];
|
||||
for (i = k+1; i < m; i++) {
|
||||
A[i][j] += t*work[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (wantv) {
|
||||
|
||||
// Place the transformation in V for subsequent
|
||||
// back multiplication.
|
||||
|
||||
for (i = k+1; i < n; i++) {
|
||||
V[i][k] = e[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set up the final bidiagonal matrix or order p.
|
||||
|
||||
int p = min(n,m+1);
|
||||
if (nct < n) {
|
||||
s[nct] = A[nct][nct];
|
||||
}
|
||||
if (m < p) {
|
||||
s[p-1] = 0.0;
|
||||
}
|
||||
if (nrt+1 < p) {
|
||||
e[nrt] = A[nrt][p-1];
|
||||
}
|
||||
e[p-1] = 0.0;
|
||||
|
||||
// If required, generate U.
|
||||
|
||||
if (wantu) {
|
||||
for (j = nct; j < nu; j++) {
|
||||
for (i = 0; i < m; i++) {
|
||||
U[i][j] = 0.0;
|
||||
}
|
||||
U[j][j] = 1.0;
|
||||
}
|
||||
for (k = nct-1; k >= 0; k--) {
|
||||
if (s[k] != 0.0) {
|
||||
for (j = k+1; j < nu; j++) {
|
||||
double t = 0;
|
||||
for (i = k; i < m; i++) {
|
||||
t += U[i][k]*U[i][j];
|
||||
}
|
||||
t = -t/U[k][k];
|
||||
for (i = k; i < m; i++) {
|
||||
U[i][j] += t*U[i][k];
|
||||
}
|
||||
}
|
||||
for (i = k; i < m; i++ ) {
|
||||
U[i][k] = -U[i][k];
|
||||
}
|
||||
U[k][k] = 1.0 + U[k][k];
|
||||
for (i = 0; i < k-1; i++) {
|
||||
U[i][k] = 0.0;
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < m; i++) {
|
||||
U[i][k] = 0.0;
|
||||
}
|
||||
U[k][k] = 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If required, generate V.
|
||||
|
||||
if (wantv) {
|
||||
for (k = n-1; k >= 0; k--) {
|
||||
if ((k < nrt) & (e[k] != 0.0)) {
|
||||
for (j = k+1; j < nu; j++) {
|
||||
double t = 0;
|
||||
for (i = k+1; i < n; i++) {
|
||||
t += V[i][k]*V[i][j];
|
||||
}
|
||||
t = -t/V[k+1][k];
|
||||
for (i = k+1; i < n; i++) {
|
||||
V[i][j] += t*V[i][k];
|
||||
}
|
||||
}
|
||||
}
|
||||
for (i = 0; i < n; i++) {
|
||||
V[i][k] = 0.0;
|
||||
}
|
||||
V[k][k] = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
// Main iteration loop for the singular values.
|
||||
|
||||
int pp = p-1;
|
||||
int iter = 0;
|
||||
double eps = pow(2.0,-52.0);
|
||||
while (p > 0) {
|
||||
int k=0;
|
||||
int kase=0;
|
||||
|
||||
// Here is where a test for too many iterations would go.
|
||||
|
||||
// This section of the program inspects for
|
||||
// negligible elements in the s and e arrays. On
|
||||
// completion the variables kase and k are set as follows.
|
||||
|
||||
// kase = 1 if s(p) and e[k-1] are negligible and k<p
|
||||
// kase = 2 if s(k) is negligible and k<p
|
||||
// kase = 3 if e[k-1] is negligible, k<p, and
|
||||
// s(k), ..., s(p) are not negligible (qr step).
|
||||
// kase = 4 if e(p-1) is negligible (convergence).
|
||||
|
||||
for (k = p-2; k >= -1; k--) {
|
||||
if (k == -1) {
|
||||
break;
|
||||
}
|
||||
if (abs(e[k]) <= eps*(abs(s[k]) + abs(s[k+1]))) {
|
||||
e[k] = 0.0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (k == p-2) {
|
||||
kase = 4;
|
||||
} else {
|
||||
int ks;
|
||||
for (ks = p-1; ks >= k; ks--) {
|
||||
if (ks == k) {
|
||||
break;
|
||||
}
|
||||
double t = (ks != p ? abs(e[ks]) : 0.) +
|
||||
(ks != k+1 ? abs(e[ks-1]) : 0.);
|
||||
if (abs(s[ks]) <= eps*t) {
|
||||
s[ks] = 0.0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ks == k) {
|
||||
kase = 3;
|
||||
} else if (ks == p-1) {
|
||||
kase = 1;
|
||||
} else {
|
||||
kase = 2;
|
||||
k = ks;
|
||||
}
|
||||
}
|
||||
k++;
|
||||
|
||||
// Perform the task indicated by kase.
|
||||
|
||||
switch (kase) {
|
||||
|
||||
// Deflate negligible s(p).
|
||||
|
||||
case 1: {
|
||||
double f = e[p-2];
|
||||
e[p-2] = 0.0;
|
||||
for (j = p-2; j >= k; j--) {
|
||||
double t = hypot(s[j],f);
|
||||
double cs = s[j]/t;
|
||||
double sn = f/t;
|
||||
s[j] = t;
|
||||
if (j != k) {
|
||||
f = -sn*e[j-1];
|
||||
e[j-1] = cs*e[j-1];
|
||||
}
|
||||
if (wantv) {
|
||||
for (i = 0; i < n; i++) {
|
||||
t = cs*V[i][j] + sn*V[i][p-1];
|
||||
V[i][p-1] = -sn*V[i][j] + cs*V[i][p-1];
|
||||
V[i][j] = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// Split at negligible s(k).
|
||||
|
||||
case 2: {
|
||||
double f = e[k-1];
|
||||
e[k-1] = 0.0;
|
||||
for (j = k; j < p; j++) {
|
||||
double t = hypot(s[j],f);
|
||||
double cs = s[j]/t;
|
||||
double sn = f/t;
|
||||
s[j] = t;
|
||||
f = -sn*e[j];
|
||||
e[j] = cs*e[j];
|
||||
if (wantu) {
|
||||
for (i = 0; i < m; i++) {
|
||||
t = cs*U[i][j] + sn*U[i][k-1];
|
||||
U[i][k-1] = -sn*U[i][j] + cs*U[i][k-1];
|
||||
U[i][j] = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// Perform one qr step.
|
||||
|
||||
case 3: {
|
||||
|
||||
// Calculate the shift.
|
||||
|
||||
double scale = max(max(max(max(
|
||||
abs(s[p-1]),abs(s[p-2])),abs(e[p-2])),
|
||||
abs(s[k])),abs(e[k]));
|
||||
double sp = s[p-1]/scale;
|
||||
double spm1 = s[p-2]/scale;
|
||||
double epm1 = e[p-2]/scale;
|
||||
double sk = s[k]/scale;
|
||||
double ek = e[k]/scale;
|
||||
double b = ((spm1 + sp)*(spm1 - sp) + epm1*epm1)/2.0;
|
||||
double c = (sp*epm1)*(sp*epm1);
|
||||
double shift = 0.0;
|
||||
if ((b != 0.0) || (c != 0.0)) {
|
||||
shift = sqrt(b*b + c);
|
||||
if (b < 0.0) {
|
||||
shift = -shift;
|
||||
}
|
||||
shift = c/(b + shift);
|
||||
}
|
||||
double f = (sk + sp)*(sk - sp) + shift;
|
||||
double g = sk*ek;
|
||||
|
||||
// Chase zeros.
|
||||
|
||||
for (j = k; j < p-1; j++) {
|
||||
double t = hypot(f,g);
|
||||
double cs = f/t;
|
||||
double sn = g/t;
|
||||
if (j != k) {
|
||||
e[j-1] = t;
|
||||
}
|
||||
f = cs*s[j] + sn*e[j];
|
||||
e[j] = cs*e[j] - sn*s[j];
|
||||
g = sn*s[j+1];
|
||||
s[j+1] = cs*s[j+1];
|
||||
if (wantv) {
|
||||
for (i = 0; i < n; i++) {
|
||||
t = cs*V[i][j] + sn*V[i][j+1];
|
||||
V[i][j+1] = -sn*V[i][j] + cs*V[i][j+1];
|
||||
V[i][j] = t;
|
||||
}
|
||||
}
|
||||
t = hypot(f,g);
|
||||
cs = f/t;
|
||||
sn = g/t;
|
||||
s[j] = t;
|
||||
f = cs*e[j] + sn*s[j+1];
|
||||
s[j+1] = -sn*e[j] + cs*s[j+1];
|
||||
g = sn*e[j+1];
|
||||
e[j+1] = cs*e[j+1];
|
||||
if (wantu && (j < m-1)) {
|
||||
for (i = 0; i < m; i++) {
|
||||
t = cs*U[i][j] + sn*U[i][j+1];
|
||||
U[i][j+1] = -sn*U[i][j] + cs*U[i][j+1];
|
||||
U[i][j] = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
e[p-2] = f;
|
||||
iter = iter + 1;
|
||||
}
|
||||
break;
|
||||
|
||||
// Convergence.
|
||||
|
||||
case 4: {
|
||||
|
||||
// Make the singular values positive.
|
||||
|
||||
if (s[k] <= 0.0) {
|
||||
s[k] = (s[k] < 0.0 ? -s[k] : 0.0);
|
||||
if (wantv) {
|
||||
for (i = 0; i <= pp; i++) {
|
||||
V[i][k] = -V[i][k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Order the singular values.
|
||||
|
||||
while (k < pp) {
|
||||
if (s[k] >= s[k+1]) {
|
||||
break;
|
||||
}
|
||||
double t = s[k];
|
||||
s[k] = s[k+1];
|
||||
s[k+1] = t;
|
||||
if (wantv && (k < n-1)) {
|
||||
for (i = 0; i < n; i++) {
|
||||
t = V[i][k+1]; V[i][k+1] = V[i][k]; V[i][k] = t;
|
||||
}
|
||||
}
|
||||
if (wantu && (k < m-1)) {
|
||||
for (i = 0; i < m; i++) {
|
||||
t = U[i][k+1]; U[i][k+1] = U[i][k]; U[i][k] = t;
|
||||
}
|
||||
}
|
||||
k++;
|
||||
}
|
||||
iter = 0;
|
||||
p--;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void getU (Array2D<Real> &A)
|
||||
{
|
||||
int minm = min(m+1,n);
|
||||
|
||||
A = Array2D<Real>(m, minm);
|
||||
|
||||
for (int i=0; i<m; i++)
|
||||
for (int j=0; j<minm; j++)
|
||||
A[i][j] = U[i][j];
|
||||
|
||||
}
|
||||
|
||||
/* Return the right singular vectors */
|
||||
|
||||
void getV (Array2D<Real> &A)
|
||||
{
|
||||
A = V;
|
||||
}
|
||||
|
||||
/** Return the one-dimensional array of singular values */
|
||||
|
||||
void getSingularValues (Array1D<Real> &x)
|
||||
{
|
||||
x = s;
|
||||
}
|
||||
|
||||
/** Return the diagonal matrix of singular values
|
||||
@return S
|
||||
*/
|
||||
|
||||
void getS (Array2D<Real> &A) {
|
||||
A = Array2D<Real>(n,n);
|
||||
for (int i = 0; i < n; i++) {
|
||||
for (int j = 0; j < n; j++) {
|
||||
A[i][j] = 0.0;
|
||||
}
|
||||
A[i][i] = s[i];
|
||||
}
|
||||
}
|
||||
|
||||
/** Two norm (max(S)) */
|
||||
|
||||
double norm2 () {
|
||||
return s[0];
|
||||
}
|
||||
|
||||
/** Two norm of condition number (max(S)/min(S)) */
|
||||
|
||||
double cond () {
|
||||
return s[0]/s[min(m,n)-1];
|
||||
}
|
||||
|
||||
/** Effective numerical matrix rank
|
||||
@return Number of nonnegligible singular values.
|
||||
*/
|
||||
|
||||
int rank ()
|
||||
{
|
||||
double eps = pow(2.0,-52.0);
|
||||
double tol = max(m,n)*s[0]*eps;
|
||||
int r = 0;
|
||||
for (int i = 0; i < s.dim(); i++) {
|
||||
if (s[i] > tol) {
|
||||
r++;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
};
|
||||
|
||||
CGAL_JAMA_END_NAMESPACE
|
||||
#endif
|
||||
// JAMA_SVD_H
|
||||
|
|
@ -1,272 +0,0 @@
|
|||
/*
|
||||
*
|
||||
* Template Numerical Toolkit (TNT)
|
||||
*
|
||||
* Mathematical and Computational Sciences Division
|
||||
* National Institute of Technology,
|
||||
* Gaithersburg, MD USA
|
||||
*
|
||||
*
|
||||
* This software was developed at the National Institute of Standards and
|
||||
* Technology (NIST) by employees of the Federal Government in the course
|
||||
* of their official duties. Pursuant to title 17 Section 105 of the
|
||||
* United States Code, this software is not subject to copyright protection
|
||||
* and is in the public domain. NIST assumes no responsibility whatsoever for
|
||||
* its use by other parties, and makes no guarantees, expressed or implied,
|
||||
* about its quality, reliability, or any other characteristic.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef CGAL_TNT_ARRAY1D_H
|
||||
#define CGAL_TNT_ARRAY1D_H
|
||||
#include <CGAL/PDB/basic.h>
|
||||
//#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include "tnt_i_refvec.h"
|
||||
|
||||
|
||||
CGAL_TNT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
template <class T>
|
||||
class Array1D
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
/* ... */
|
||||
i_refvec<T> v_;
|
||||
int n_;
|
||||
T* data_; /* this normally points to v_.begin(), but
|
||||
* could also point to a portion (subvector)
|
||||
* of v_.
|
||||
*/
|
||||
|
||||
void copy_(T* p, const T* q, int len) const;
|
||||
void set_(T* begin, T* end, const T& val);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
typedef T value_type;
|
||||
|
||||
|
||||
Array1D();
|
||||
explicit Array1D(int n);
|
||||
Array1D(int n, const T &a);
|
||||
Array1D(int n, T *a);
|
||||
inline Array1D(const Array1D &A);
|
||||
inline operator T*();
|
||||
inline operator const T*();
|
||||
inline Array1D & operator=(const T &a);
|
||||
inline Array1D & operator=(const Array1D &A);
|
||||
inline Array1D & ref(const Array1D &A);
|
||||
Array1D copy() const;
|
||||
Array1D & inject(const Array1D & A);
|
||||
inline T& operator[](int i);
|
||||
inline const T& operator[](int i) const;
|
||||
inline int dim1() const;
|
||||
inline int dim() const;
|
||||
~Array1D();
|
||||
|
||||
|
||||
/* ... extended interface ... */
|
||||
|
||||
inline int ref_count() const;
|
||||
inline Array1D<T> subarray(int i0, int i1);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
template <class T>
|
||||
Array1D<T>::Array1D() : v_(), n_(0), data_(0) {}
|
||||
|
||||
template <class T>
|
||||
Array1D<T>::Array1D(const Array1D<T> &A) : v_(A.v_), n_(A.n_),
|
||||
data_(A.data_)
|
||||
{
|
||||
#ifdef TNT_DEBUG
|
||||
std::cout << "Created Array1D(const Array1D<T> &A) \n";
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
Array1D<T>::Array1D(int n) : v_(n), n_(n), data_(v_.begin())
|
||||
{
|
||||
#ifdef DEBUG
|
||||
std::cout << "Created Array1D(int n) \n";
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Array1D<T>::Array1D(int n, const T &val) : v_(n), n_(n), data_(v_.begin())
|
||||
{
|
||||
#ifdef TNT_DEBUG
|
||||
std::cout << "Created Array1D(int n, const T& val) \n";
|
||||
#endif
|
||||
set_(data_, data_+ n, val);
|
||||
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Array1D<T>::Array1D(int n, T *a) : v_(a), n_(n) , data_(v_.begin())
|
||||
{
|
||||
#ifdef DEBUG
|
||||
std::cout << "Created Array1D(int n, T* a) \n";
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Array1D<T>::operator T*()
|
||||
{
|
||||
return &(v_[0]);
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline Array1D<T>::operator const T*()
|
||||
{
|
||||
return &(v_[0]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <class T>
|
||||
inline T& Array1D<T>::operator[](int i)
|
||||
{
|
||||
#ifdef TNT_BOUNDS_CHECK
|
||||
assert(i>= 0);
|
||||
assert(i < n_);
|
||||
#endif
|
||||
return data_[i];
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline const T& Array1D<T>::operator[](int i) const
|
||||
{
|
||||
#ifdef TNT_BOUNDS_CHECK
|
||||
assert(i>= 0);
|
||||
assert(i < n_);
|
||||
#endif
|
||||
return data_[i];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template <class T>
|
||||
Array1D<T> & Array1D<T>::operator=(const T &a)
|
||||
{
|
||||
set_(data_, data_+n_, a);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Array1D<T> Array1D<T>::copy() const
|
||||
{
|
||||
Array1D A( n_);
|
||||
copy_(A.data_, data_, n_);
|
||||
|
||||
return A;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
Array1D<T> & Array1D<T>::inject(const Array1D &A)
|
||||
{
|
||||
if (A.n_ == n_)
|
||||
copy_(data_, A.data_, n_);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
template <class T>
|
||||
Array1D<T> & Array1D<T>::ref(const Array1D<T> &A)
|
||||
{
|
||||
if (this != &A)
|
||||
{
|
||||
v_ = A.v_; /* operator= handles the reference counting. */
|
||||
n_ = A.n_;
|
||||
data_ = A.data_;
|
||||
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Array1D<T> & Array1D<T>::operator=(const Array1D<T> &A)
|
||||
{
|
||||
return ref(A);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline int Array1D<T>::dim1() const { return n_; }
|
||||
|
||||
template <class T>
|
||||
inline int Array1D<T>::dim() const { return n_; }
|
||||
|
||||
template <class T>
|
||||
Array1D<T>::~Array1D() {}
|
||||
|
||||
|
||||
/* ............................ exented interface ......................*/
|
||||
|
||||
template <class T>
|
||||
inline int Array1D<T>::ref_count() const
|
||||
{
|
||||
return v_.ref_count();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Array1D<T> Array1D<T>::subarray(int i0, int i1)
|
||||
{
|
||||
if ((i0 > 0) && (i1 < n_) || (i0 <= i1))
|
||||
{
|
||||
Array1D<T> X(*this); /* create a new instance of this array. */
|
||||
X.n_ = i1-i0+1;
|
||||
X.data_ += i0;
|
||||
|
||||
return X;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Array1D<T>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* private internal functions */
|
||||
|
||||
|
||||
template <class T>
|
||||
void Array1D<T>::set_(T* begin, T* end, const T& a)
|
||||
{
|
||||
for (T* p=begin; p<end; p++)
|
||||
*p = a;
|
||||
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void Array1D<T>::copy_(T* p, const T* q, int len) const
|
||||
{
|
||||
T *end = p + len;
|
||||
while (p<end )
|
||||
*p++ = *q++;
|
||||
|
||||
}
|
||||
|
||||
|
||||
CGAL_TNT_END_NAMESPACE
|
||||
#endif
|
||||
/* TNT_ARRAY1D_H */
|
||||
|
||||
|
|
@ -1,231 +0,0 @@
|
|||
/*
|
||||
*
|
||||
* Template Numerical Toolkit (TNT)
|
||||
*
|
||||
* Mathematical and Computational Sciences Division
|
||||
* National Institute of Technology,
|
||||
* Gaithersburg, MD USA
|
||||
*
|
||||
*
|
||||
* This software was developed at the National Institute of Standards and
|
||||
* Technology (NIST) by employees of the Federal Government in the course
|
||||
* of their official duties. Pursuant to title 17 Section 105 of the
|
||||
* United States Code, this software is not subject to copyright protection
|
||||
* and is in the public domain. NIST assumes no responsibility whatsoever for
|
||||
* its use by other parties, and makes no guarantees, expressed or implied,
|
||||
* about its quality, reliability, or any other characteristic.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CGAL_TNT_ARRAY1D_UTILS_H
|
||||
#define CGAL_TNT_ARRAY1D_UTILS_H
|
||||
|
||||
#include <CGAL/PDB/basic.h>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
#include "tnt_array1d.h"
|
||||
|
||||
CGAL_TNT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
|
||||
template <class T>
|
||||
std::ostream& operator<<(std::ostream &s, const Array1D<T> &A)
|
||||
{
|
||||
int N=A.dim1();
|
||||
|
||||
#ifdef CGAL_TNT_DEBUG
|
||||
s << "addr: " << (void *) &A[0] << "\n";
|
||||
#endif
|
||||
s << N << "\n";
|
||||
for (int j=0; j<N; j++)
|
||||
{
|
||||
s << A[j] << "\n";
|
||||
}
|
||||
s << "\n";
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
std::istream& operator>>(std::istream &s, Array1D<T> &A)
|
||||
{
|
||||
int N;
|
||||
s >> N;
|
||||
|
||||
Array1D<T> B(N);
|
||||
for (int i=0; i<N; i++)
|
||||
s >> B[i];
|
||||
A = B;
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <class T>
|
||||
Array1D<T> operator+(const Array1D<T> &A, const Array1D<T> &B)
|
||||
{
|
||||
int n = A.dim1();
|
||||
|
||||
if (B.dim1() != n )
|
||||
return Array1D<T>();
|
||||
|
||||
else
|
||||
{
|
||||
Array1D<T> C(n);
|
||||
|
||||
for (int i=0; i<n; i++)
|
||||
{
|
||||
C[i] = A[i] + B[i];
|
||||
}
|
||||
return C;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <class T>
|
||||
Array1D<T> operator-(const Array1D<T> &A, const Array1D<T> &B)
|
||||
{
|
||||
int n = A.dim1();
|
||||
|
||||
if (B.dim1() != n )
|
||||
return Array1D<T>();
|
||||
|
||||
else
|
||||
{
|
||||
Array1D<T> C(n);
|
||||
|
||||
for (int i=0; i<n; i++)
|
||||
{
|
||||
C[i] = A[i] - B[i];
|
||||
}
|
||||
return C;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
Array1D<T> operator*(const Array1D<T> &A, const Array1D<T> &B)
|
||||
{
|
||||
int n = A.dim1();
|
||||
|
||||
if (B.dim1() != n )
|
||||
return Array1D<T>();
|
||||
|
||||
else
|
||||
{
|
||||
Array1D<T> C(n);
|
||||
|
||||
for (int i=0; i<n; i++)
|
||||
{
|
||||
C[i] = A[i] * B[i];
|
||||
}
|
||||
return C;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
Array1D<T> operator/(const Array1D<T> &A, const Array1D<T> &B)
|
||||
{
|
||||
int n = A.dim1();
|
||||
|
||||
if (B.dim1() != n )
|
||||
return Array1D<T>();
|
||||
|
||||
else
|
||||
{
|
||||
Array1D<T> C(n);
|
||||
|
||||
for (int i=0; i<n; i++)
|
||||
{
|
||||
C[i] = A[i] / B[i];
|
||||
}
|
||||
return C;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
template <class T>
|
||||
Array1D<T>& operator+=(Array1D<T> &A, const Array1D<T> &B)
|
||||
{
|
||||
int n = A.dim1();
|
||||
|
||||
if (B.dim1() == n)
|
||||
{
|
||||
for (int i=0; i<n; i++)
|
||||
{
|
||||
A[i] += B[i];
|
||||
}
|
||||
}
|
||||
return A;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template <class T>
|
||||
Array1D<T>& operator-=(Array1D<T> &A, const Array1D<T> &B)
|
||||
{
|
||||
int n = A.dim1();
|
||||
|
||||
if (B.dim1() == n)
|
||||
{
|
||||
for (int i=0; i<n; i++)
|
||||
{
|
||||
A[i] -= B[i];
|
||||
}
|
||||
}
|
||||
return A;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <class T>
|
||||
Array1D<T>& operator*=(Array1D<T> &A, const Array1D<T> &B)
|
||||
{
|
||||
int n = A.dim1();
|
||||
|
||||
if (B.dim1() == n)
|
||||
{
|
||||
for (int i=0; i<n; i++)
|
||||
{
|
||||
A[i] *= B[i];
|
||||
}
|
||||
}
|
||||
return A;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template <class T>
|
||||
Array1D<T>& operator/=(Array1D<T> &A, const Array1D<T> &B)
|
||||
{
|
||||
int n = A.dim1();
|
||||
|
||||
if (B.dim1() == n)
|
||||
{
|
||||
for (int i=0; i<n; i++)
|
||||
{
|
||||
A[i] /= B[i];
|
||||
}
|
||||
}
|
||||
return A;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
CGAL_TNT_END_NAMESPACE
|
||||
#endif
|
||||
|
|
@ -1,309 +0,0 @@
|
|||
/*
|
||||
*
|
||||
* Template Numerical Toolkit (TNT)
|
||||
*
|
||||
* Mathematical and Computational Sciences Division
|
||||
* National Institute of Technology,
|
||||
* Gaithersburg, MD USA
|
||||
*
|
||||
*
|
||||
* This software was developed at the National Institute of Standards and
|
||||
* Technology (NIST) by employees of the Federal Government in the course
|
||||
* of their official duties. Pursuant to title 17 Section 105 of the
|
||||
* United States Code, this software is not subject to copyright protection
|
||||
* and is in the public domain. NIST assumes no responsibility whatsoever for
|
||||
* its use by other parties, and makes no guarantees, expressed or implied,
|
||||
* about its quality, reliability, or any other characteristic.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef CGAL_TNT_ARRAY2D_H
|
||||
#define CGAL_TNT_ARRAY2D_H
|
||||
#include <CGAL/PDB/basic.h>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
#include "tnt_array1d.h"
|
||||
CGAL_TNT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
template <class T>
|
||||
class Array2D
|
||||
{
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
Array1D<T> data_;
|
||||
Array1D<T*> v_;
|
||||
int m_;
|
||||
int n_;
|
||||
|
||||
public:
|
||||
|
||||
typedef T value_type;
|
||||
Array2D();
|
||||
Array2D(int m, int n);
|
||||
Array2D(int m, int n, T *a);
|
||||
Array2D(int m, int n, const T &a);
|
||||
inline Array2D(const Array2D &A);
|
||||
inline T** raw();
|
||||
inline const T** raw() const;
|
||||
inline Array2D & operator=(const T &a);
|
||||
inline Array2D & operator=(const Array2D &A);
|
||||
inline Array2D & ref(const Array2D &A);
|
||||
Array2D copy() const;
|
||||
Array2D & inject(const Array2D & A);
|
||||
inline T* operator[](int i);
|
||||
inline const T* operator[](int i) const;
|
||||
inline int dim1() const;
|
||||
inline int dim2() const;
|
||||
~Array2D();
|
||||
|
||||
/* extended interface (not part of the standard) */
|
||||
|
||||
|
||||
inline int ref_count();
|
||||
inline int ref_count_data();
|
||||
inline int ref_count_dim1();
|
||||
Array2D subarray(int i0, int i1, int j0, int j1);
|
||||
|
||||
};
|
||||
|
||||
|
||||
template <class T>
|
||||
Array2D<T>::Array2D() : data_(), v_(), m_(0), n_(0) {}
|
||||
|
||||
template <class T>
|
||||
Array2D<T>::Array2D(const Array2D<T> &A) : data_(A.data_), v_(A.v_),
|
||||
m_(A.m_), n_(A.n_) {}
|
||||
|
||||
|
||||
|
||||
|
||||
template <class T>
|
||||
Array2D<T>::Array2D(int m, int n) : data_(m*n), v_(m), m_(m), n_(n)
|
||||
{
|
||||
if (m>0 && n>0)
|
||||
{
|
||||
T* p = &(data_[0]);
|
||||
for (int i=0; i<m; i++)
|
||||
{
|
||||
v_[i] = p;
|
||||
p += n;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <class T>
|
||||
Array2D<T>::Array2D(int m, int n, const T &val) : data_(m*n), v_(m),
|
||||
m_(m), n_(n)
|
||||
{
|
||||
if (m>0 && n>0)
|
||||
{
|
||||
data_ = val;
|
||||
T* p = &(data_[0]);
|
||||
for (int i=0; i<m; i++)
|
||||
{
|
||||
v_[i] = p;
|
||||
p += n;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Array2D<T>::Array2D(int m, int n, T *a) : data_(m*n, a), v_(m), m_(m), n_(n)
|
||||
{
|
||||
if (m>0 && n>0)
|
||||
{
|
||||
T* p = &(data_[0]);
|
||||
|
||||
for (int i=0; i<m; i++)
|
||||
{
|
||||
v_[i] = p;
|
||||
p += n;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline T* Array2D<T>::operator[](int i)
|
||||
{
|
||||
#ifdef CGAL_TNT_BOUNDS_CHECK
|
||||
assert(i >= 0);
|
||||
assert(i < m_);
|
||||
#endif
|
||||
|
||||
return v_[i];
|
||||
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline const T* Array2D<T>::operator[](int i) const
|
||||
{
|
||||
#ifdef CGAL_TNT_BOUNDS_CHECK
|
||||
assert(i >= 0);
|
||||
assert(i < m_);
|
||||
#endif
|
||||
|
||||
return v_[i];
|
||||
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Array2D<T> & Array2D<T>::operator=(const T &a)
|
||||
{
|
||||
/* non-optimzied, but will work with subarrays in future verions */
|
||||
|
||||
for (int i=0; i<m_; i++)
|
||||
for (int j=0; j<n_; j++)
|
||||
v_[i][j] = a;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template <class T>
|
||||
Array2D<T> Array2D<T>::copy() const
|
||||
{
|
||||
Array2D A(m_, n_);
|
||||
|
||||
for (int i=0; i<m_; i++)
|
||||
for (int j=0; j<n_; j++)
|
||||
A[i][j] = v_[i][j];
|
||||
|
||||
|
||||
return A;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
Array2D<T> & Array2D<T>::inject(const Array2D &A)
|
||||
{
|
||||
if (A.m_ == m_ && A.n_ == n_)
|
||||
{
|
||||
for (int i=0; i<m_; i++)
|
||||
for (int j=0; j<n_; j++)
|
||||
v_[i][j] = A[i][j];
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template <class T>
|
||||
Array2D<T> & Array2D<T>::ref(const Array2D<T> &A)
|
||||
{
|
||||
if (this != &A)
|
||||
{
|
||||
v_ = A.v_;
|
||||
data_ = A.data_;
|
||||
m_ = A.m_;
|
||||
n_ = A.n_;
|
||||
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <class T>
|
||||
Array2D<T> & Array2D<T>::operator=(const Array2D<T> &A)
|
||||
{
|
||||
return ref(A);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline int Array2D<T>::dim1() const { return m_; }
|
||||
|
||||
template <class T>
|
||||
inline int Array2D<T>::dim2() const { return n_; }
|
||||
|
||||
|
||||
template <class T>
|
||||
Array2D<T>::~Array2D() {}
|
||||
|
||||
|
||||
|
||||
|
||||
template <class T>
|
||||
inline T** Array2D<T>::raw()
|
||||
{
|
||||
return &(v_[0]);
|
||||
}
|
||||
template <class T>
|
||||
inline const T** Array2D<T>::raw() const
|
||||
{
|
||||
return &(v_[0]);
|
||||
}
|
||||
|
||||
/* ............... extended interface ............... */
|
||||
/**
|
||||
Create a new view to a subarray defined by the boundaries
|
||||
[i0][i0] and [i1][j1]. The size of the subarray is
|
||||
(i1-i0) by (j1-j0). If either of these lengths are zero
|
||||
or negative, the subarray view is null.
|
||||
|
||||
*/
|
||||
template <class T>
|
||||
Array2D<T> Array2D<T>::subarray(int i0, int i1, int j0, int j1)
|
||||
{
|
||||
Array2D<T> A;
|
||||
int m = i1-i0+1;
|
||||
int n = j1-j0+1;
|
||||
|
||||
/* if either length is zero or negative, this is an invalide
|
||||
subarray. return a null view.
|
||||
*/
|
||||
if (m<1 || n<1)
|
||||
return A;
|
||||
|
||||
A.data_ = data_;
|
||||
A.m_ = m;
|
||||
A.n_ = n;
|
||||
A.v_ = Array1D<T*>(m);
|
||||
T* p = &(data_[0]) + i0 * n_ + j0;
|
||||
for (int i=0; i<m; i++)
|
||||
{
|
||||
A.v_[i] = p + i*n;
|
||||
}
|
||||
return A;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline int Array2D<T>::ref_count()
|
||||
{
|
||||
return ref_count_data();
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <class T>
|
||||
inline int Array2D<T>::ref_count_data()
|
||||
{
|
||||
return data_.ref_count();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline int Array2D<T>::ref_count_dim1()
|
||||
{
|
||||
return v_.ref_count();
|
||||
}
|
||||
|
||||
|
||||
|
||||
CGAL_TNT_END_NAMESPACE
|
||||
#endif
|
||||
/* TNT_ARRAY2D_H */
|
||||
|
||||
|
|
@ -1,286 +0,0 @@
|
|||
/*
|
||||
*
|
||||
* Template Numerical Toolkit (TNT)
|
||||
*
|
||||
* Mathematical and Computational Sciences Division
|
||||
* National Institute of Technology,
|
||||
* Gaithersburg, MD USA
|
||||
*
|
||||
*
|
||||
* This software was developed at the National Institute of Standards and
|
||||
* Technology (NIST) by employees of the Federal Government in the course
|
||||
* of their official duties. Pursuant to title 17 Section 105 of the
|
||||
* United States Code, this software is not subject to copyright protection
|
||||
* and is in the public domain. NIST assumes no responsibility whatsoever for
|
||||
* its use by other parties, and makes no guarantees, expressed or implied,
|
||||
* about its quality, reliability, or any other characteristic.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CGAL_TNT_ARRAY2D_UTILS_H
|
||||
#define CGAL_TNT_ARRAY2D_UTILS_H
|
||||
#include <CGAL/PDB/basic.h>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
CGAL_TNT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
|
||||
template <class T>
|
||||
std::ostream& operator<<(std::ostream &s, const Array2D<T> &A)
|
||||
{
|
||||
int M=A.dim1();
|
||||
int N=A.dim2();
|
||||
|
||||
s << M << " " << N << "\n";
|
||||
|
||||
for (int i=0; i<M; i++)
|
||||
{
|
||||
for (int j=0; j<N; j++)
|
||||
{
|
||||
s << A[i][j] << " ";
|
||||
}
|
||||
s << "\n";
|
||||
}
|
||||
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
std::istream& operator>>(std::istream &s, Array2D<T> &A)
|
||||
{
|
||||
|
||||
int M, N;
|
||||
|
||||
s >> M >> N;
|
||||
|
||||
Array2D<T> B(M,N);
|
||||
|
||||
for (int i=0; i<M; i++)
|
||||
for (int j=0; j<N; j++)
|
||||
{
|
||||
s >> B[i][j];
|
||||
}
|
||||
|
||||
A = B;
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
Array2D<T> operator+(const Array2D<T> &A, const Array2D<T> &B)
|
||||
{
|
||||
int m = A.dim1();
|
||||
int n = A.dim2();
|
||||
|
||||
if (B.dim1() != m || B.dim2() != n )
|
||||
return Array2D<T>();
|
||||
|
||||
else
|
||||
{
|
||||
Array2D<T> C(m,n);
|
||||
|
||||
for (int i=0; i<m; i++)
|
||||
{
|
||||
for (int j=0; j<n; j++)
|
||||
C[i][j] = A[i][j] + B[i][j];
|
||||
}
|
||||
return C;
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Array2D<T> operator-(const Array2D<T> &A, const Array2D<T> &B)
|
||||
{
|
||||
int m = A.dim1();
|
||||
int n = A.dim2();
|
||||
|
||||
if (B.dim1() != m || B.dim2() != n )
|
||||
return Array2D<T>();
|
||||
|
||||
else
|
||||
{
|
||||
Array2D<T> C(m,n);
|
||||
|
||||
for (int i=0; i<m; i++)
|
||||
{
|
||||
for (int j=0; j<n; j++)
|
||||
C[i][j] = A[i][j] - B[i][j];
|
||||
}
|
||||
return C;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
Array2D<T> operator*(const Array2D<T> &A, const Array2D<T> &B)
|
||||
{
|
||||
int m = A.dim1();
|
||||
int n = A.dim2();
|
||||
|
||||
if (B.dim1() != m || B.dim2() != n )
|
||||
return Array2D<T>();
|
||||
|
||||
else
|
||||
{
|
||||
Array2D<T> C(m,n);
|
||||
|
||||
for (int i=0; i<m; i++)
|
||||
{
|
||||
for (int j=0; j<n; j++)
|
||||
C[i][j] = A[i][j] * B[i][j];
|
||||
}
|
||||
return C;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template <class T>
|
||||
Array2D<T> operator/(const Array2D<T> &A, const Array2D<T> &B)
|
||||
{
|
||||
int m = A.dim1();
|
||||
int n = A.dim2();
|
||||
|
||||
if (B.dim1() != m || B.dim2() != n )
|
||||
return Array2D<T>();
|
||||
|
||||
else
|
||||
{
|
||||
Array2D<T> C(m,n);
|
||||
|
||||
for (int i=0; i<m; i++)
|
||||
{
|
||||
for (int j=0; j<n; j++)
|
||||
C[i][j] = A[i][j] / B[i][j];
|
||||
}
|
||||
return C;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
template <class T>
|
||||
Array2D<T>& operator+=(Array2D<T> &A, const Array2D<T> &B)
|
||||
{
|
||||
int m = A.dim1();
|
||||
int n = A.dim2();
|
||||
|
||||
if (B.dim1() == m || B.dim2() == n )
|
||||
{
|
||||
for (int i=0; i<m; i++)
|
||||
{
|
||||
for (int j=0; j<n; j++)
|
||||
A[i][j] += B[i][j];
|
||||
}
|
||||
}
|
||||
return A;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <class T>
|
||||
Array2D<T>& operator-=(Array2D<T> &A, const Array2D<T> &B)
|
||||
{
|
||||
int m = A.dim1();
|
||||
int n = A.dim2();
|
||||
|
||||
if (B.dim1() == m || B.dim2() == n )
|
||||
{
|
||||
for (int i=0; i<m; i++)
|
||||
{
|
||||
for (int j=0; j<n; j++)
|
||||
A[i][j] -= B[i][j];
|
||||
}
|
||||
}
|
||||
return A;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <class T>
|
||||
Array2D<T>& operator*=(Array2D<T> &A, const Array2D<T> &B)
|
||||
{
|
||||
int m = A.dim1();
|
||||
int n = A.dim2();
|
||||
|
||||
if (B.dim1() == m || B.dim2() == n )
|
||||
{
|
||||
for (int i=0; i<m; i++)
|
||||
{
|
||||
for (int j=0; j<n; j++)
|
||||
A[i][j] *= B[i][j];
|
||||
}
|
||||
}
|
||||
return A;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
template <class T>
|
||||
Array2D<T>& operator/=(Array2D<T> &A, const Array2D<T> &B)
|
||||
{
|
||||
int m = A.dim1();
|
||||
int n = A.dim2();
|
||||
|
||||
if (B.dim1() == m || B.dim2() == n )
|
||||
{
|
||||
for (int i=0; i<m; i++)
|
||||
{
|
||||
for (int j=0; j<n; j++)
|
||||
A[i][j] /= B[i][j];
|
||||
}
|
||||
}
|
||||
return A;
|
||||
}
|
||||
|
||||
/**
|
||||
Matrix Multiply: compute C = A*B, where C[i][j]
|
||||
is the dot-product of row i of A and column j of B.
|
||||
|
||||
|
||||
@param A an (m x n) array
|
||||
@param B an (n x k) array
|
||||
@return the (m x k) array A*B, or a null array (0x0)
|
||||
if the matrices are non-conformant (i.e. the number
|
||||
of columns of A are different than the number of rows of B.)
|
||||
|
||||
|
||||
*/
|
||||
template <class T>
|
||||
Array2D<T> matmult(const Array2D<T> &A, const Array2D<T> &B)
|
||||
{
|
||||
if (A.dim2() != B.dim1())
|
||||
return Array2D<T>();
|
||||
|
||||
int M = A.dim1();
|
||||
int N = A.dim2();
|
||||
int K = B.dim2();
|
||||
|
||||
Array2D<T> C(M,K);
|
||||
|
||||
for (int i=0; i<M; i++)
|
||||
for (int j=0; j<K; j++)
|
||||
{
|
||||
T sum = 0;
|
||||
|
||||
for (int k=0; k<N; k++)
|
||||
sum += A[i][k] * B [k][j];
|
||||
|
||||
C[i][j] = sum;
|
||||
}
|
||||
|
||||
return C;
|
||||
|
||||
}
|
||||
|
||||
CGAL_TNT_END_NAMESPACE
|
||||
#endif
|
||||
|
|
@ -1,580 +0,0 @@
|
|||
/*
|
||||
*
|
||||
* Template Numerical Toolkit (TNT)
|
||||
*
|
||||
* Mathematical and Computational Sciences Division
|
||||
* National Institute of Technology,
|
||||
* Gaithersburg, MD USA
|
||||
*
|
||||
*
|
||||
* This software was developed at the National Institute of Standards and
|
||||
* Technology (NIST) by employees of the Federal Government in the course
|
||||
* of their official duties. Pursuant to title 17 Section 105 of the
|
||||
* United States Code, this software is not subject to copyright protection
|
||||
* and is in the public domain. NIST assumes no responsibility whatsoever for
|
||||
* its use by other parties, and makes no guarantees, expressed or implied,
|
||||
* about its quality, reliability, or any other characteristic.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// C compatible matrix: row-oriented, 0-based [i][j] and 1-based (i,j) indexing
|
||||
//
|
||||
|
||||
#ifndef CGAL_TNT_CMAT_H
|
||||
#define CGAL_TNT_CMAT_H
|
||||
#include <CGAL/PDB/basic.h>
|
||||
#include "tnt_subscript.h"
|
||||
#include "tnt_vec.h"
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
|
||||
CGAL_TNT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
|
||||
template <class T>
|
||||
class Matrix
|
||||
{
|
||||
|
||||
|
||||
public:
|
||||
|
||||
typedef Subscript size_type;
|
||||
typedef T value_type;
|
||||
typedef T element_type;
|
||||
typedef T* pointer;
|
||||
typedef T* iterator;
|
||||
typedef T& reference;
|
||||
typedef const T* const_iterator;
|
||||
typedef const T& const_reference;
|
||||
|
||||
Subscript lbound() const { return 1;}
|
||||
|
||||
protected:
|
||||
Subscript m_;
|
||||
Subscript n_;
|
||||
Subscript mn_; // total size
|
||||
T* v_;
|
||||
T** row_;
|
||||
T* vm1_ ; // these point to the same data, but are 1-based
|
||||
T** rowm1_;
|
||||
|
||||
// internal helper function to create the array
|
||||
// of row pointers
|
||||
|
||||
void initialize(Subscript M, Subscript N)
|
||||
{
|
||||
mn_ = M*N;
|
||||
m_ = M;
|
||||
n_ = N;
|
||||
|
||||
v_ = new T[mn_];
|
||||
row_ = new T*[M];
|
||||
rowm1_ = new T*[M];
|
||||
|
||||
assert(v_ != NULL);
|
||||
assert(row_ != NULL);
|
||||
assert(rowm1_ != NULL);
|
||||
|
||||
T* p = v_;
|
||||
vm1_ = v_ - 1;
|
||||
for (Subscript i=0; i<M; i++)
|
||||
{
|
||||
row_[i] = p;
|
||||
rowm1_[i] = p-1;
|
||||
p += N ;
|
||||
|
||||
}
|
||||
|
||||
rowm1_ -- ; // compensate for 1-based offset
|
||||
}
|
||||
|
||||
void copy(const T* v)
|
||||
{
|
||||
Subscript N = m_ * n_;
|
||||
Subscript i;
|
||||
|
||||
#ifdef CGAL_TNT_UNROLL_LOOPS
|
||||
Subscript Nmod4 = N & 3;
|
||||
Subscript N4 = N - Nmod4;
|
||||
|
||||
for (i=0; i<N4; i+=4)
|
||||
{
|
||||
v_[i] = v[i];
|
||||
v_[i+1] = v[i+1];
|
||||
v_[i+2] = v[i+2];
|
||||
v_[i+3] = v[i+3];
|
||||
}
|
||||
|
||||
for (i=N4; i< N; i++)
|
||||
v_[i] = v[i];
|
||||
#else
|
||||
|
||||
for (i=0; i< N; i++)
|
||||
v_[i] = v[i];
|
||||
#endif
|
||||
}
|
||||
|
||||
void set(const T& val)
|
||||
{
|
||||
Subscript N = m_ * n_;
|
||||
Subscript i;
|
||||
|
||||
#ifdef CGAL_TNT_UNROLL_LOOPS
|
||||
Subscript Nmod4 = N & 3;
|
||||
Subscript N4 = N - Nmod4;
|
||||
|
||||
for (i=0; i<N4; i+=4)
|
||||
{
|
||||
v_[i] = val;
|
||||
v_[i+1] = val;
|
||||
v_[i+2] = val;
|
||||
v_[i+3] = val;
|
||||
}
|
||||
|
||||
for (i=N4; i< N; i++)
|
||||
v_[i] = val;
|
||||
#else
|
||||
|
||||
for (i=0; i< N; i++)
|
||||
v_[i] = val;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
void destroy()
|
||||
{
|
||||
/* do nothing, if no memory has been previously allocated */
|
||||
if (v_ == NULL) return ;
|
||||
|
||||
/* if we are here, then matrix was previously allocated */
|
||||
if (v_ != NULL) delete [] (v_);
|
||||
if (row_ != NULL) delete [] (row_);
|
||||
|
||||
/* return rowm1_ back to original value */
|
||||
rowm1_ ++;
|
||||
if (rowm1_ != NULL ) delete [] (rowm1_);
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
|
||||
operator T**(){ return row_; }
|
||||
operator T**() const { return row_; }
|
||||
|
||||
|
||||
Subscript size() const { return mn_; }
|
||||
|
||||
// constructors
|
||||
|
||||
Matrix() : m_(0), n_(0), mn_(0), v_(0), row_(0), vm1_(0), rowm1_(0) {};
|
||||
|
||||
Matrix(const Matrix<T> &A)
|
||||
{
|
||||
initialize(A.m_, A.n_);
|
||||
copy(A.v_);
|
||||
}
|
||||
|
||||
Matrix(Subscript M, Subscript N, const T& value = T())
|
||||
{
|
||||
initialize(M,N);
|
||||
set(value);
|
||||
}
|
||||
|
||||
Matrix(Subscript M, Subscript N, const T* v)
|
||||
{
|
||||
initialize(M,N);
|
||||
copy(v);
|
||||
}
|
||||
|
||||
Matrix(Subscript M, Subscript N, const char *s)
|
||||
{
|
||||
initialize(M,N);
|
||||
//std::istrstream ins(s);
|
||||
std::istringstream ins(s);
|
||||
|
||||
Subscript i, j;
|
||||
|
||||
for (i=0; i<M; i++)
|
||||
for (j=0; j<N; j++)
|
||||
ins >> row_[i][j];
|
||||
}
|
||||
|
||||
// destructor
|
||||
//
|
||||
~Matrix()
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
|
||||
|
||||
// reallocating
|
||||
//
|
||||
Matrix<T>& newsize(Subscript M, Subscript N)
|
||||
{
|
||||
if (num_rows() == M && num_cols() == N)
|
||||
return *this;
|
||||
|
||||
destroy();
|
||||
initialize(M,N);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// assignments
|
||||
//
|
||||
Matrix<T>& operator=(const Matrix<T> &A)
|
||||
{
|
||||
if (v_ == A.v_)
|
||||
return *this;
|
||||
|
||||
if (m_ == A.m_ && n_ == A.n_) // no need to re-alloc
|
||||
copy(A.v_);
|
||||
|
||||
else
|
||||
{
|
||||
destroy();
|
||||
initialize(A.m_, A.n_);
|
||||
copy(A.v_);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Matrix<T>& operator=(const T& scalar)
|
||||
{
|
||||
set(scalar);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Subscript dim(Subscript d) const
|
||||
{
|
||||
#ifdef CGAL_TNT_BOUNDS_CHECK
|
||||
assert( d >= 1);
|
||||
assert( d <= 2);
|
||||
#endif
|
||||
return (d==1) ? m_ : ((d==2) ? n_ : 0);
|
||||
}
|
||||
|
||||
Subscript num_rows() const { return m_; }
|
||||
Subscript num_cols() const { return n_; }
|
||||
|
||||
|
||||
|
||||
|
||||
inline T* operator[](Subscript i)
|
||||
{
|
||||
#ifdef CGAL_TNT_BOUNDS_CHECK
|
||||
assert(0<=i);
|
||||
assert(i < m_) ;
|
||||
#endif
|
||||
return row_[i];
|
||||
}
|
||||
|
||||
inline const T* operator[](Subscript i) const
|
||||
{
|
||||
#ifdef CGAL_TNT_BOUNDS_CHECK
|
||||
assert(0<=i);
|
||||
assert(i < m_) ;
|
||||
#endif
|
||||
return row_[i];
|
||||
}
|
||||
|
||||
inline reference operator()(Subscript i)
|
||||
{
|
||||
#ifdef CGAL_TNT_BOUNDS_CHECK
|
||||
assert(1<=i);
|
||||
assert(i <= mn_) ;
|
||||
#endif
|
||||
return vm1_[i];
|
||||
}
|
||||
|
||||
inline const_reference operator()(Subscript i) const
|
||||
{
|
||||
#ifdef CGAL_TNT_BOUNDS_CHECK
|
||||
assert(1<=i);
|
||||
assert(i <= mn_) ;
|
||||
#endif
|
||||
return vm1_[i];
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline reference operator()(Subscript i, Subscript j)
|
||||
{
|
||||
#ifdef CGAL_TNT_BOUNDS_CHECK
|
||||
assert(1<=i);
|
||||
assert(i <= m_) ;
|
||||
assert(1<=j);
|
||||
assert(j <= n_);
|
||||
#endif
|
||||
return rowm1_[i][j];
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline const_reference operator() (Subscript i, Subscript j) const
|
||||
{
|
||||
#ifdef CGAL_TNT_BOUNDS_CHECK
|
||||
assert(1<=i);
|
||||
assert(i <= m_) ;
|
||||
assert(1<=j);
|
||||
assert(j <= n_);
|
||||
#endif
|
||||
return rowm1_[i][j];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
/* *************************** I/O ********************************/
|
||||
|
||||
template <class T>
|
||||
std::ostream& operator<<(std::ostream &s, const Matrix<T> &A)
|
||||
{
|
||||
Subscript M=A.num_rows();
|
||||
Subscript N=A.num_cols();
|
||||
|
||||
s << M << " " << N << "\n";
|
||||
|
||||
for (Subscript i=0; i<M; i++)
|
||||
{
|
||||
for (Subscript j=0; j<N; j++)
|
||||
{
|
||||
s << A[i][j] << " ";
|
||||
}
|
||||
s << "\n";
|
||||
}
|
||||
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
std::istream& operator>>(std::istream &s, Matrix<T> &A)
|
||||
{
|
||||
|
||||
Subscript M, N;
|
||||
|
||||
s >> M >> N;
|
||||
|
||||
if ( !(M == A.num_rows() && N == A.num_cols() ))
|
||||
{
|
||||
A.newsize(M,N);
|
||||
}
|
||||
|
||||
|
||||
for (Subscript i=0; i<M; i++)
|
||||
for (Subscript j=0; j<N; j++)
|
||||
{
|
||||
s >> A[i][j];
|
||||
}
|
||||
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
// *******************[ basic matrix algorithms ]***************************
|
||||
|
||||
|
||||
template <class T>
|
||||
Matrix<T> operator+(const Matrix<T> &A,
|
||||
const Matrix<T> &B)
|
||||
{
|
||||
Subscript M = A.num_rows();
|
||||
Subscript N = A.num_cols();
|
||||
|
||||
assert(M==B.num_rows());
|
||||
assert(N==B.num_cols());
|
||||
|
||||
Matrix<T> tmp(M,N);
|
||||
Subscript i,j;
|
||||
|
||||
for (i=0; i<M; i++)
|
||||
for (j=0; j<N; j++)
|
||||
tmp[i][j] = A[i][j] + B[i][j];
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Matrix<T> operator-(const Matrix<T> &A,
|
||||
const Matrix<T> &B)
|
||||
{
|
||||
Subscript M = A.num_rows();
|
||||
Subscript N = A.num_cols();
|
||||
|
||||
assert(M==B.num_rows());
|
||||
assert(N==B.num_cols());
|
||||
|
||||
Matrix<T> tmp(M,N);
|
||||
Subscript i,j;
|
||||
|
||||
for (i=0; i<M; i++)
|
||||
for (j=0; j<N; j++)
|
||||
tmp[i][j] = A[i][j] - B[i][j];
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Matrix<T> mult_element(const Matrix<T> &A,
|
||||
const Matrix<T> &B)
|
||||
{
|
||||
Subscript M = A.num_rows();
|
||||
Subscript N = A.num_cols();
|
||||
|
||||
assert(M==B.num_rows());
|
||||
assert(N==B.num_cols());
|
||||
|
||||
Matrix<T> tmp(M,N);
|
||||
Subscript i,j;
|
||||
|
||||
for (i=0; i<M; i++)
|
||||
for (j=0; j<N; j++)
|
||||
tmp[i][j] = A[i][j] * B[i][j];
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
Matrix<T> transpose(const Matrix<T> &A)
|
||||
{
|
||||
Subscript M = A.num_rows();
|
||||
Subscript N = A.num_cols();
|
||||
|
||||
Matrix<T> S(N,M);
|
||||
Subscript i, j;
|
||||
|
||||
for (i=0; i<M; i++)
|
||||
for (j=0; j<N; j++)
|
||||
S[j][i] = A[i][j];
|
||||
|
||||
return S;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <class T>
|
||||
inline Matrix<T> matmult(const Matrix<T> &A,
|
||||
const Matrix<T> &B)
|
||||
{
|
||||
|
||||
#ifdef TNT_BOUNDS_CHECK
|
||||
assert(A.num_cols() == B.num_rows());
|
||||
#endif
|
||||
|
||||
Subscript M = A.num_rows();
|
||||
Subscript N = A.num_cols();
|
||||
Subscript K = B.num_cols();
|
||||
|
||||
Matrix<T> tmp(M,K);
|
||||
T sum;
|
||||
|
||||
for (Subscript i=0; i<M; i++)
|
||||
for (Subscript k=0; k<K; k++)
|
||||
{
|
||||
sum = 0;
|
||||
for (Subscript j=0; j<N; j++)
|
||||
sum = sum + A[i][j] * B[j][k];
|
||||
|
||||
tmp[i][k] = sum;
|
||||
}
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Matrix<T> operator*(const Matrix<T> &A,
|
||||
const Matrix<T> &B)
|
||||
{
|
||||
return matmult(A,B);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline int matmult(Matrix<T>& C, const Matrix<T> &A,
|
||||
const Matrix<T> &B)
|
||||
{
|
||||
|
||||
assert(A.num_cols() == B.num_rows());
|
||||
|
||||
Subscript M = A.num_rows();
|
||||
Subscript N = A.num_cols();
|
||||
Subscript K = B.num_cols();
|
||||
|
||||
C.newsize(M,K);
|
||||
|
||||
T sum;
|
||||
|
||||
const T* row_i;
|
||||
const T* col_k;
|
||||
|
||||
for (Subscript i=0; i<M; i++)
|
||||
for (Subscript k=0; k<K; k++)
|
||||
{
|
||||
row_i = &(A[i][0]);
|
||||
col_k = &(B[0][k]);
|
||||
sum = 0;
|
||||
for (Subscript j=0; j<N; j++)
|
||||
{
|
||||
sum += *row_i * *col_k;
|
||||
row_i++;
|
||||
col_k += K;
|
||||
}
|
||||
C[i][k] = sum;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
Vector<T> matmult(const Matrix<T> &A, const Vector<T> &x)
|
||||
{
|
||||
|
||||
#ifdef TNT_BOUNDS_CHECK
|
||||
assert(A.num_cols() == x.dim());
|
||||
#endif
|
||||
|
||||
Subscript M = A.num_rows();
|
||||
Subscript N = A.num_cols();
|
||||
|
||||
Vector<T> tmp(M);
|
||||
T sum;
|
||||
|
||||
for (Subscript i=0; i<M; i++)
|
||||
{
|
||||
sum = 0;
|
||||
const T* rowi = A[i];
|
||||
for (Subscript j=0; j<N; j++)
|
||||
sum = sum + rowi[j] * x[j];
|
||||
|
||||
tmp[i] = sum;
|
||||
}
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Vector<T> operator*(const Matrix<T> &A, const Vector<T> &x)
|
||||
{
|
||||
return matmult(A,x);
|
||||
}
|
||||
|
||||
CGAL_TNT_END_NAMESPACE
|
||||
#endif
|
||||
// CMAT_H
|
||||
|
|
@ -1,233 +0,0 @@
|
|||
/*
|
||||
*
|
||||
* Template Numerical Toolkit (TNT)
|
||||
*
|
||||
* Mathematical and Computational Sciences Division
|
||||
* National Institute of Technology,
|
||||
* Gaithersburg, MD USA
|
||||
*
|
||||
*
|
||||
* This software was developed at the National Institute of Standards and
|
||||
* Technology (NIST) by employees of the Federal Government in the course
|
||||
* of their official duties. Pursuant to title 17 Section 105 of the
|
||||
* United States Code, this software is not subject to copyright protection
|
||||
* and is in the public domain. NIST assumes no responsibility whatsoever for
|
||||
* its use by other parties, and makes no guarantees, expressed or implied,
|
||||
* about its quality, reliability, or any other characteristic.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef CGAL_TNT_I_REFVEC_H
|
||||
#define CGAL_TNT_I_REFVEC_H
|
||||
#include <CGAL/PDB/basic.h>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
CGAL_TNT_BEGIN_NAMESPACE
|
||||
|
||||
/*
|
||||
Internal representation of ref-counted array. The TNT
|
||||
arrays all use this building block.
|
||||
|
||||
<p>
|
||||
If an array block is created by TNT, then every time
|
||||
an assignment is made, the left-hand-side reference
|
||||
is decreased by one, and the right-hand-side refernce
|
||||
count is increased by one. If the array block was
|
||||
external to TNT, the refernce count is a NULL pointer
|
||||
regardless of how many references are made, since the
|
||||
memory is not freed by TNT.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
template <class T>
|
||||
class i_refvec
|
||||
{
|
||||
|
||||
|
||||
private:
|
||||
T* data_;
|
||||
int *ref_count_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
i_refvec();
|
||||
explicit i_refvec(int n);
|
||||
inline i_refvec(T* data);
|
||||
inline i_refvec(const i_refvec &v);
|
||||
inline T* begin();
|
||||
inline const T* begin() const;
|
||||
inline T& operator[](int i);
|
||||
inline const T& operator[](int i) const;
|
||||
inline i_refvec<T> & operator=(const i_refvec<T> &V);
|
||||
void copy_(T* p, const T* q, const T* e);
|
||||
void set_(T* p, const T* b, const T* e);
|
||||
inline int ref_count() const;
|
||||
inline int is_null() const;
|
||||
inline void destroy();
|
||||
~i_refvec();
|
||||
|
||||
};
|
||||
|
||||
template <class T>
|
||||
void i_refvec<T>::copy_(T* p, const T* q, const T* e)
|
||||
{
|
||||
for (T* t=p; q<e; t++, q++)
|
||||
*t= *q;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
i_refvec<T>::i_refvec() : data_(NULL), ref_count_(NULL) {}
|
||||
|
||||
/**
|
||||
In case n is 0 or negative, it does NOT call new.
|
||||
*/
|
||||
template <class T>
|
||||
i_refvec<T>::i_refvec(int n) : data_(NULL), ref_count_(NULL)
|
||||
{
|
||||
if (n >= 1)
|
||||
{
|
||||
#ifdef CGAL_TNT_DEBUG
|
||||
std::cout << "new data storage.\n";
|
||||
#endif
|
||||
data_ = new T[n];
|
||||
ref_count_ = new int;
|
||||
*ref_count_ = 1;
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline i_refvec<T>::i_refvec(const i_refvec<T> &V): data_(V.data_),
|
||||
ref_count_(V.ref_count_)
|
||||
{
|
||||
if (V.ref_count_ != NULL)
|
||||
(*(V.ref_count_))++;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
i_refvec<T>::i_refvec(T* data) : data_(data), ref_count_(NULL) {}
|
||||
|
||||
template <class T>
|
||||
inline T* i_refvec<T>::begin()
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline const T& i_refvec<T>::operator[](int i) const
|
||||
{
|
||||
return data_[i];
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T& i_refvec<T>::operator[](int i)
|
||||
{
|
||||
return data_[i];
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline const T* i_refvec<T>::begin() const
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <class T>
|
||||
i_refvec<T> & i_refvec<T>::operator=(const i_refvec<T> &V)
|
||||
{
|
||||
if (this == &V)
|
||||
return *this;
|
||||
|
||||
|
||||
if (ref_count_ != NULL)
|
||||
{
|
||||
(*ref_count_) --;
|
||||
if ((*ref_count_) == 0)
|
||||
destroy();
|
||||
}
|
||||
|
||||
data_ = V.data_;
|
||||
ref_count_ = V.ref_count_;
|
||||
|
||||
if (V.ref_count_ != NULL)
|
||||
(*(V.ref_count_))++;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void i_refvec<T>::destroy()
|
||||
{
|
||||
if (ref_count_ != NULL)
|
||||
{
|
||||
#ifdef CGAL_TNT_DEBUG
|
||||
std::cout << "destorying data... \n";
|
||||
#endif
|
||||
delete ref_count_;
|
||||
|
||||
#ifdef CGAL_TNT_DEBUG
|
||||
std::cout << "deleted ref_count_ ...\n";
|
||||
#endif
|
||||
if (data_ != NULL)
|
||||
delete []data_;
|
||||
#ifdef CGAL_TNT_DEBUG
|
||||
std::cout << "deleted data_[] ...\n";
|
||||
#endif
|
||||
data_ = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* return 1 is vector is empty, 0 otherwise
|
||||
*
|
||||
* if is_null() is false and ref_count() is 0, then
|
||||
*
|
||||
*/
|
||||
template<class T>
|
||||
int i_refvec<T>::is_null() const
|
||||
{
|
||||
return (data_ == NULL ? 1 : 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* returns -1 if data is external,
|
||||
* returns 0 if a is NULL array,
|
||||
* otherwise returns the positive number of vectors sharing
|
||||
* this data space.
|
||||
*/
|
||||
template <class T>
|
||||
int i_refvec<T>::ref_count() const
|
||||
{
|
||||
if (data_ == NULL)
|
||||
return 0;
|
||||
else
|
||||
return (ref_count_ != NULL ? *ref_count_ : -1) ;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
i_refvec<T>::~i_refvec()
|
||||
{
|
||||
if (ref_count_ != NULL)
|
||||
{
|
||||
(*ref_count_)--;
|
||||
|
||||
if (*ref_count_ == 0)
|
||||
destroy();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
CGAL_TNT_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
/* TNT_I_REFVEC_H */
|
||||
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
#ifndef CGAL_TNT_MATH_UTILS_H
|
||||
#define CGAL_TNT_MATH_UTILS_H
|
||||
#include <CGAL/PDB/basic.h>
|
||||
/* needed for fabs, sqrt() below */
|
||||
#include <cmath>
|
||||
|
||||
|
||||
CGAL_TNT_BEGIN_NAMESPACE
|
||||
|
||||
/**
|
||||
@returns hypotenuse of real (non-complex) scalars a and b by
|
||||
avoiding underflow/overflow
|
||||
using (a * sqrt( 1 + (b/a) * (b/a))), rather than
|
||||
sqrt(a*a + b*b).
|
||||
*/
|
||||
template <class Real>
|
||||
Real hypot(const Real &a, const Real &b)
|
||||
{
|
||||
|
||||
if (a== 0)
|
||||
return abs(b);
|
||||
else
|
||||
{
|
||||
Real c = b/a;
|
||||
//return fabs(a) * sqrt(1 + c*c);
|
||||
return abs(a) * sqrt(1 + c*c);
|
||||
}
|
||||
}
|
||||
|
||||
CGAL_TNT_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
/* MATH_UTILS_H */
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
/*
|
||||
*
|
||||
* Template Numerical Toolkit (TNT)
|
||||
*
|
||||
* Mathematical and Computational Sciences Division
|
||||
* National Institute of Technology,
|
||||
* Gaithersburg, MD USA
|
||||
*
|
||||
*
|
||||
* This software was developed at the National Institute of Standards and
|
||||
* Technology (NIST) by employees of the Federal Government in the course
|
||||
* of their official duties. Pursuant to title 17 Section 105 of the
|
||||
* United States Code, this software is not subject to copyright protection
|
||||
* and is in the public domain. NIST assumes no responsibility whatsoever for
|
||||
* its use by other parties, and makes no guarantees, expressed or implied,
|
||||
* about its quality, reliability, or any other characteristic.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CGAL_TNT_SUBSCRPT_H
|
||||
#define CGAL_TNT_SUBSCRPT_H
|
||||
#include <CGAL/PDB/basic.h>
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// This definition describes the default TNT data type used for
|
||||
// indexing into TNT matrices and vectors. The data type should
|
||||
// be wide enough to index into large arrays. It defaults to an
|
||||
// "int", but can be overriden at compile time redefining TNT_SUBSCRIPT_TYPE,
|
||||
// e.g.
|
||||
//
|
||||
// c++ -DTNT_SUBSCRIPT_TYPE='unsigned int' ...
|
||||
//
|
||||
//---------------------------------------------------------------------
|
||||
//
|
||||
|
||||
/*#ifndef CGAL_TNT_SUBSCRIPT_TYPE
|
||||
#define CGAL_TNT_SUBSCRIPT_TYPE int
|
||||
#endif*/
|
||||
|
||||
CGAL_TNT_BEGIN_NAMESPACE
|
||||
|
||||
typedef int Subscript;
|
||||
|
||||
CGAL_TNT_END_NAMESPACE
|
||||
// () indexing in TNT means 1-offset, i.e. x(1) and A(1,1) are the
|
||||
// first elements. This offset is left as a macro for future
|
||||
// purposes, but should not be changed in the current release.
|
||||
//
|
||||
//
|
||||
#define CGAL_TNT_BASE_OFFSET (1)
|
||||
|
||||
#endif
|
||||
|
|
@ -1,403 +0,0 @@
|
|||
/*
|
||||
*
|
||||
* Template Numerical Toolkit (TNT)
|
||||
*
|
||||
* Mathematical and Computational Sciences Division
|
||||
* National Institute of Technology,
|
||||
* Gaithersburg, MD USA
|
||||
*
|
||||
*
|
||||
* This software was developed at the National Institute of Standards and
|
||||
* Technology (NIST) by employees of the Federal Government in the course
|
||||
* of their official duties. Pursuant to title 17 Section 105 of the
|
||||
* United States Code, this software is not subject to copyright protection
|
||||
* and is in the public domain. NIST assumes no responsibility whatsoever for
|
||||
* its use by other parties, and makes no guarantees, expressed or implied,
|
||||
* about its quality, reliability, or any other characteristic.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef CGAL_TNT_VEC_H
|
||||
#define CGAL_TNT_VEC_H
|
||||
#include <CGAL/PDB/basic.h>
|
||||
#include "tnt_subscript.h"
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
CGAL_TNT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
/**
|
||||
<b>[Deprecatred]</b> Value-based vector class from pre-1.0
|
||||
TNT version. Kept here for backward compatiblity, but should
|
||||
use the newer TNT::Array1D classes instead.
|
||||
|
||||
*/
|
||||
|
||||
template <class T>
|
||||
class Vector
|
||||
{
|
||||
|
||||
|
||||
public:
|
||||
|
||||
typedef Subscript size_type;
|
||||
typedef T value_type;
|
||||
typedef T element_type;
|
||||
typedef T* pointer;
|
||||
typedef T* iterator;
|
||||
typedef T& reference;
|
||||
typedef const T* const_iterator;
|
||||
typedef const T& const_reference;
|
||||
|
||||
Subscript lbound() const { return 1;}
|
||||
|
||||
protected:
|
||||
T* v_;
|
||||
T* vm1_; // pointer adjustment for optimzied 1-offset indexing
|
||||
Subscript n_;
|
||||
|
||||
// internal helper function to create the array
|
||||
// of row pointers
|
||||
|
||||
void initialize(Subscript N)
|
||||
{
|
||||
// adjust pointers so that they are 1-offset:
|
||||
// v_[] is the internal contiguous array, it is still 0-offset
|
||||
//
|
||||
assert(v_ == NULL);
|
||||
v_ = new T[N];
|
||||
assert(v_ != NULL);
|
||||
vm1_ = v_-1;
|
||||
n_ = N;
|
||||
}
|
||||
|
||||
void copy(const T* v)
|
||||
{
|
||||
Subscript N = n_;
|
||||
Subscript i;
|
||||
|
||||
#ifdef TNT_UNROLL_LOOPS
|
||||
Subscript Nmod4 = N & 3;
|
||||
Subscript N4 = N - Nmod4;
|
||||
|
||||
for (i=0; i<N4; i+=4)
|
||||
{
|
||||
v_[i] = v[i];
|
||||
v_[i+1] = v[i+1];
|
||||
v_[i+2] = v[i+2];
|
||||
v_[i+3] = v[i+3];
|
||||
}
|
||||
|
||||
for (i=N4; i< N; i++)
|
||||
v_[i] = v[i];
|
||||
#else
|
||||
|
||||
for (i=0; i< N; i++)
|
||||
v_[i] = v[i];
|
||||
#endif
|
||||
}
|
||||
|
||||
void set(const T& val)
|
||||
{
|
||||
Subscript N = n_;
|
||||
Subscript i;
|
||||
|
||||
#ifdef TNT_UNROLL_LOOPS
|
||||
Subscript Nmod4 = N & 3;
|
||||
Subscript N4 = N - Nmod4;
|
||||
|
||||
for (i=0; i<N4; i+=4)
|
||||
{
|
||||
v_[i] = val;
|
||||
v_[i+1] = val;
|
||||
v_[i+2] = val;
|
||||
v_[i+3] = val;
|
||||
}
|
||||
|
||||
for (i=N4; i< N; i++)
|
||||
v_[i] = val;
|
||||
#else
|
||||
|
||||
for (i=0; i< N; i++)
|
||||
v_[i] = val;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
void destroy()
|
||||
{
|
||||
/* do nothing, if no memory has been previously allocated */
|
||||
if (v_ == NULL) return ;
|
||||
|
||||
/* if we are here, then matrix was previously allocated */
|
||||
delete [] (v_);
|
||||
|
||||
v_ = NULL;
|
||||
vm1_ = NULL;
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// access
|
||||
|
||||
iterator begin() { return v_;}
|
||||
iterator end() { return v_ + n_; }
|
||||
iterator begin() const { return v_;}
|
||||
iterator end() const { return v_ + n_; }
|
||||
|
||||
// destructor
|
||||
|
||||
~Vector()
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
|
||||
// constructors
|
||||
|
||||
Vector() : v_(0), vm1_(0), n_(0) {};
|
||||
|
||||
Vector(const Vector<T> &A) : v_(0), vm1_(0), n_(0)
|
||||
{
|
||||
initialize(A.n_);
|
||||
copy(A.v_);
|
||||
}
|
||||
|
||||
Vector(Subscript N, const T& value = T()) : v_(0), vm1_(0), n_(0)
|
||||
{
|
||||
initialize(N);
|
||||
set(value);
|
||||
}
|
||||
|
||||
Vector(Subscript N, const T* v) : v_(0), vm1_(0), n_(0)
|
||||
{
|
||||
initialize(N);
|
||||
copy(v);
|
||||
}
|
||||
|
||||
Vector(Subscript N, char *s) : v_(0), vm1_(0), n_(0)
|
||||
{
|
||||
initialize(N);
|
||||
std::istringstream ins(s);
|
||||
|
||||
Subscript i;
|
||||
|
||||
for (i=0; i<N; i++)
|
||||
ins >> v_[i];
|
||||
}
|
||||
|
||||
|
||||
// methods
|
||||
//
|
||||
Vector<T>& newsize(Subscript N)
|
||||
{
|
||||
if (n_ == N) return *this;
|
||||
|
||||
destroy();
|
||||
initialize(N);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// assignments
|
||||
//
|
||||
Vector<T>& operator=(const Vector<T> &A)
|
||||
{
|
||||
if (v_ == A.v_)
|
||||
return *this;
|
||||
|
||||
if (n_ == A.n_) // no need to re-alloc
|
||||
copy(A.v_);
|
||||
|
||||
else
|
||||
{
|
||||
destroy();
|
||||
initialize(A.n_);
|
||||
copy(A.v_);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vector<T>& operator=(const T& scalar)
|
||||
{
|
||||
set(scalar);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Subscript dim() const
|
||||
{
|
||||
return n_;
|
||||
}
|
||||
|
||||
inline Subscript size() const
|
||||
{
|
||||
return n_;
|
||||
}
|
||||
|
||||
|
||||
inline reference operator()(Subscript i)
|
||||
{
|
||||
#ifdef TNT_BOUNDS_CHECK
|
||||
assert(1<=i);
|
||||
assert(i <= n_) ;
|
||||
#endif
|
||||
return vm1_[i];
|
||||
}
|
||||
|
||||
inline const_reference operator() (Subscript i) const
|
||||
{
|
||||
#ifdef TNT_BOUNDS_CHECK
|
||||
assert(1<=i);
|
||||
assert(i <= n_) ;
|
||||
#endif
|
||||
return vm1_[i];
|
||||
}
|
||||
|
||||
inline reference operator[](Subscript i)
|
||||
{
|
||||
#ifdef TNT_BOUNDS_CHECK
|
||||
assert(0<=i);
|
||||
assert(i < n_) ;
|
||||
#endif
|
||||
return v_[i];
|
||||
}
|
||||
|
||||
inline const_reference operator[](Subscript i) const
|
||||
{
|
||||
#ifdef TNT_BOUNDS_CHECK
|
||||
assert(0<=i);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
assert(i < n_) ;
|
||||
#endif
|
||||
return v_[i];
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
/* *************************** I/O ********************************/
|
||||
|
||||
template <class T>
|
||||
std::ostream& operator<<(std::ostream &s, const Vector<T> &A)
|
||||
{
|
||||
Subscript N=A.dim();
|
||||
|
||||
s << N << "\n";
|
||||
|
||||
for (Subscript i=0; i<N; i++)
|
||||
s << A[i] << " " << "\n";
|
||||
s << "\n";
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
std::istream & operator>>(std::istream &s, Vector<T> &A)
|
||||
{
|
||||
|
||||
Subscript N;
|
||||
|
||||
s >> N;
|
||||
|
||||
if ( !(N == A.size() ))
|
||||
{
|
||||
A.newsize(N);
|
||||
}
|
||||
|
||||
|
||||
for (Subscript i=0; i<N; i++)
|
||||
s >> A[i];
|
||||
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
// *******************[ basic matrix algorithms ]***************************
|
||||
|
||||
|
||||
template <class T>
|
||||
Vector<T> operator+(const Vector<T> &A,
|
||||
const Vector<T> &B)
|
||||
{
|
||||
Subscript N = A.dim();
|
||||
|
||||
assert(N==B.dim());
|
||||
|
||||
Vector<T> tmp(N);
|
||||
Subscript i;
|
||||
|
||||
for (i=0; i<N; i++)
|
||||
tmp[i] = A[i] + B[i];
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Vector<T> operator-(const Vector<T> &A,
|
||||
const Vector<T> &B)
|
||||
{
|
||||
Subscript N = A.dim();
|
||||
|
||||
assert(N==B.dim());
|
||||
|
||||
Vector<T> tmp(N);
|
||||
Subscript i;
|
||||
|
||||
for (i=0; i<N; i++)
|
||||
tmp[i] = A[i] - B[i];
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Vector<T> operator*(const Vector<T> &A,
|
||||
const Vector<T> &B)
|
||||
{
|
||||
Subscript N = A.dim();
|
||||
|
||||
assert(N==B.dim());
|
||||
|
||||
Vector<T> tmp(N);
|
||||
Subscript i;
|
||||
|
||||
for (i=0; i<N; i++)
|
||||
tmp[i] = A[i] * B[i];
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
T dot_prod(const Vector<T> &A, const Vector<T> &B)
|
||||
{
|
||||
Subscript N = A.dim();
|
||||
assert(N == B.dim());
|
||||
|
||||
Subscript i;
|
||||
T sum = 0;
|
||||
|
||||
for (i=0; i<N; i++)
|
||||
sum += A[i] * B[i];
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
CGAL_TNT_END_NAMESPACE
|
||||
#endif
|
||||
// TNT_VEC_H
|
||||
|
|
@ -1,247 +0,0 @@
|
|||
/* Copyright 2004
|
||||
Stanford University
|
||||
|
||||
This file is part of the DSR PDB Library.
|
||||
|
||||
The DSR PDB Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The DSR PDB Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the DSR PDB Library; see the file LICENSE.LGPL. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#ifndef CGAL_DSR_PDB_ITERATOR_H
|
||||
#define CGAL_DSR_PDB_ITERATOR_H
|
||||
#include <CGAL/PDB/basic.h>
|
||||
#include <CGAL/PDB/Point.h>
|
||||
#include <CGAL/PDB/Protein.h>
|
||||
|
||||
CGAL_PDB_BEGIN_NAMESPACE
|
||||
|
||||
//! Take an atom label, atom pair and return the coordinates
|
||||
struct Atom_coordinates {
|
||||
typedef Point result_type;
|
||||
typedef const std::pair<Residue::Atom_label, Atom>& argument_type;
|
||||
const result_type& operator()(argument_type a) const {
|
||||
return a.second.cartesian_coords();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
struct Atom_index {
|
||||
typedef Atom::Index result_type;
|
||||
typedef const std::pair<Residue::Atom_label, Atom>& argument_type;
|
||||
const result_type& operator()(argument_type a) const {
|
||||
static result_type rt;
|
||||
rt= a.second.index();
|
||||
return rt;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
//! Take an iterator which returns atoms and return their coordinates instead
|
||||
template <class It, class Projector>
|
||||
class Projection_iterator {
|
||||
typedef Projection_iterator<It, Projector> This;
|
||||
public:
|
||||
typedef typename Projector::result_type value_type;
|
||||
typedef typename It::iterator_category iterator_category;
|
||||
typedef typename It::difference_type difference_type;
|
||||
typedef const typename Projector::result_type& reference;
|
||||
typedef const typename Projector::result_type* pointer;
|
||||
|
||||
reference operator*() {
|
||||
//std::cout << ait_->second.index() << std::endl;
|
||||
return p_(*cur_);
|
||||
}
|
||||
pointer operator->() {
|
||||
//std::cout << ait_->second.index() << std::endl;
|
||||
return &p_(*cur_);
|
||||
}
|
||||
This operator++(int) {
|
||||
This t=*this;
|
||||
++cur_;
|
||||
return t;
|
||||
}
|
||||
This operator++() {
|
||||
++cur_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator==(const This& o) const {
|
||||
return cur_ == o.cur_;
|
||||
}
|
||||
bool operator!=(const This& o) const {
|
||||
return cur_!= o.cur_;
|
||||
}
|
||||
|
||||
Projection_iterator(){}
|
||||
Projection_iterator(It c, Projector p): cur_(c), p_(p){}
|
||||
|
||||
protected:
|
||||
It cur_;
|
||||
Projector p_;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//! Create an atom coordinates iterator
|
||||
template <class It, class Proj>
|
||||
Projection_iterator<It, Proj> projection_iterator(It a, Proj proj) {
|
||||
return Projection_iterator<It, Proj>(a, proj);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Filters the iterator output
|
||||
template <class It, class Filter>
|
||||
class Filter_iterator {
|
||||
typedef Filter_iterator<It, Filter> This;
|
||||
public:
|
||||
typedef typename It::value_type value_type;
|
||||
typedef typename It::iterator_category iterator_category;
|
||||
typedef typename It::difference_type difference_type;
|
||||
typedef typename It::reference reference;
|
||||
typedef typename It::pointer pointer;
|
||||
|
||||
reference operator*() {
|
||||
return cur_.operator*();
|
||||
}
|
||||
|
||||
pointer operator->() {
|
||||
return cur_.operator->();
|
||||
}
|
||||
|
||||
This operator++(int) {
|
||||
This t=*this;
|
||||
++cur_;
|
||||
fix();
|
||||
return t;
|
||||
}
|
||||
This operator++() {
|
||||
++cur_;
|
||||
fix();
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator==(const This& o) const {
|
||||
return cur_ == o.cur_;
|
||||
}
|
||||
bool operator!=(const This& o) const {
|
||||
return cur_!= o.cur_;
|
||||
}
|
||||
|
||||
Filter_iterator(){}
|
||||
Filter_iterator(It c, It e, Filter f): cur_(c), end_(e), f_(f){fix();}
|
||||
|
||||
protected:
|
||||
void fix(){
|
||||
while (cur_ != end_ && !f_(*cur_)) ++cur_;
|
||||
}
|
||||
It cur_, end_;
|
||||
Filter f_;
|
||||
};
|
||||
|
||||
//! Create a filter iterator by passing the functor and the iterator.
|
||||
/*!
|
||||
See Yes, Is_backbone and Is_CA for example filters.
|
||||
*/
|
||||
template <class It, class F>
|
||||
Filter_iterator<It, F> filter_iterator(It b, It e, F f){
|
||||
return Filter_iterator<It, F>(b,e,f);
|
||||
}
|
||||
|
||||
//! Functor that returns true.
|
||||
struct Yes {
|
||||
template <class A>
|
||||
bool operator()(A) {return true;}
|
||||
};
|
||||
|
||||
//! Return true if an atom is a backbone atoms.
|
||||
struct Is_backbone {
|
||||
template <class A>
|
||||
bool operator()(const A &a) {
|
||||
return a.first == Residue::AL_C || a.first == Residue::AL_CA
|
||||
|| a.first == Residue::AL_N;
|
||||
}
|
||||
};
|
||||
|
||||
//! Returns true if an atom is a CA atom.
|
||||
struct Is_CA {
|
||||
template <class A>
|
||||
bool operator()(const A &a) {
|
||||
return a.first == Residue::AL_CA;
|
||||
}
|
||||
};
|
||||
|
||||
//! An iterator for iterating through the coordinates of backbone atoms of a protein
|
||||
typedef Projection_iterator<Filter_iterator<Protein::Const_atoms_iterator, Is_backbone>, Atom_coordinates> Protein_backbone_coordinates_iterator;
|
||||
|
||||
//! a begin iterator for iterating through the coordinates of backbone atoms of a protein
|
||||
/*!
|
||||
This is a good example of how to use the various iterator classes.
|
||||
*/
|
||||
inline Protein_backbone_coordinates_iterator backbone_coordinates_begin(const Protein &p) {
|
||||
return projection_iterator(filter_iterator(p.atoms_begin(), p.atoms_end(), Is_backbone()), Atom_coordinates());
|
||||
}
|
||||
|
||||
//! an end iterator for iterating through the coordinates of backbone atoms of a protein
|
||||
inline Protein_backbone_coordinates_iterator backbone_coordinates_end(const Protein &p) {
|
||||
return projection_iterator(filter_iterator(p.atoms_end(), p.atoms_end(), Is_backbone()), Atom_coordinates());
|
||||
}
|
||||
|
||||
|
||||
//! An iterator for iterating through the coordinates of C_alpha atoms of a protein
|
||||
typedef Projection_iterator<Filter_iterator<Protein::Const_atoms_iterator, Is_CA>, Atom_coordinates > Ca_backbone_coordinates_iterator;
|
||||
|
||||
//! a begin iterator for iterating through the coordinates of C_alpha atoms of a protein
|
||||
inline Ca_backbone_coordinates_iterator ca_coordinates_begin(const Protein &p) {
|
||||
return projection_iterator(filter_iterator(p.atoms_begin(), p.atoms_end(), Is_CA()), Atom_coordinates());
|
||||
}
|
||||
|
||||
//! an end iterator for iterating through the coordinates of C_alpha atoms of a protein
|
||||
inline Ca_backbone_coordinates_iterator ca_coordinates_end(const Protein &p) {
|
||||
return projection_iterator(filter_iterator(p.atoms_end(), p.atoms_end(), Is_CA()), Atom_coordinates());
|
||||
}
|
||||
|
||||
|
||||
//! An iterator for iterating through the coordinates of all atoms of a protein
|
||||
typedef Projection_iterator<Filter_iterator<Protein::Const_atoms_iterator, Yes>, Atom_coordinates> All_coordinates_iterator;
|
||||
|
||||
//! a begin iterator for iterating through the coordinates of all the atoms of a protein
|
||||
inline All_coordinates_iterator all_coordinates_begin(const Protein &p) {
|
||||
return projection_iterator(filter_iterator(p.atoms_begin(), p.atoms_end(), Yes()), Atom_coordinates());
|
||||
}
|
||||
|
||||
//! an end iterator for iterating through the coordinates of all the atoms of a protein
|
||||
inline All_coordinates_iterator all_coordinates_end(const Protein &p) {
|
||||
return projection_iterator(filter_iterator(p.atoms_end(), p.atoms_end(), Yes()), Atom_coordinates());
|
||||
}
|
||||
|
||||
|
||||
//! An iterator through the indices of the backbone atoms
|
||||
typedef Projection_iterator<Filter_iterator<Protein::Const_atoms_iterator, Is_backbone>, Atom_index> Protein_backbone_indices_iterator;
|
||||
|
||||
//! Begin iterating through the indices of backbone atoms
|
||||
inline Protein_backbone_indices_iterator protein_backbone_indices_begin(const Protein &p) {
|
||||
return projection_iterator(filter_iterator(p.atoms_begin(), p.atoms_end(), Is_backbone()), Atom_index());
|
||||
}
|
||||
|
||||
//! an end iterator for iterating through the indices of all the backbone atoms of a protein
|
||||
inline Protein_backbone_indices_iterator protein_backbone_indices_end(const Protein &p) {
|
||||
return projection_iterator(filter_iterator(p.atoms_end(), p.atoms_end(), Is_backbone()), Atom_index());
|
||||
}
|
||||
|
||||
CGAL_PDB_END_NAMESPACE
|
||||
#endif
|
||||
|
|
@ -1,99 +0,0 @@
|
|||
/* Copyright 2004
|
||||
Stanford University
|
||||
|
||||
This file is part of the DSR PDB Library.
|
||||
|
||||
The DSR PDB Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The DSR PDB Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the DSR PDB Library; see the file LICENSE.LGPL. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
|
||||
#ifndef CGAL_DSR_PDB_SMALL_MAP_H
|
||||
#define CGAL_DSR_PDB_SMALL_MAP_H
|
||||
#include <CGAL/PDB/basic.h>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
CGAL_PDB_BEGIN_NAMESPACE
|
||||
|
||||
template <class Key, class Data>
|
||||
class small_map {
|
||||
public:
|
||||
typedef std::pair<Key, Data> value_type;
|
||||
typedef Key key_type;
|
||||
typedef Data data_type;
|
||||
typedef std::vector<value_type> container;
|
||||
typedef typename container::iterator iterator;
|
||||
typedef typename container::const_iterator const_iterator;
|
||||
|
||||
|
||||
small_map(std::size_t sz=0){c_.reserve(sz);}
|
||||
|
||||
iterator find(key_type k) {
|
||||
for (iterator it= c_.begin(); it != c_.end(); ++it){
|
||||
if (it->first==k) return it;
|
||||
}
|
||||
return end();
|
||||
}
|
||||
const_iterator find(key_type k) const {
|
||||
for (const_iterator it= c_.begin(); it != c_.end(); ++it){
|
||||
if (it->first==k) return it;
|
||||
}
|
||||
return end();
|
||||
}
|
||||
|
||||
iterator begin() {
|
||||
return c_.begin();
|
||||
}
|
||||
|
||||
iterator end() {
|
||||
return c_.end();
|
||||
}
|
||||
|
||||
const_iterator begin() const {
|
||||
return c_.begin();
|
||||
}
|
||||
|
||||
const_iterator end() const {
|
||||
return c_.end();
|
||||
}
|
||||
|
||||
data_type& operator[](key_type k){
|
||||
iterator it= find(k);
|
||||
if (it != end()) return it->second;
|
||||
else {
|
||||
c_.push_back(value_type(k,data_type()));
|
||||
return c_.back().second;
|
||||
}
|
||||
}
|
||||
|
||||
void insert(const value_type &v) {
|
||||
c_.push_back(v);
|
||||
}
|
||||
|
||||
void erase(const key_type &k) {
|
||||
iterator it = find(k);
|
||||
if (it != end()) c_.erase(it);
|
||||
}
|
||||
|
||||
std::size_t size() const {
|
||||
return c_.size();
|
||||
}
|
||||
|
||||
protected:
|
||||
container c_;
|
||||
};
|
||||
|
||||
CGAL_PDB_END_NAMESPACE
|
||||
#endif
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
/* Copyright 2004
|
||||
Stanford University
|
||||
|
||||
This file is part of the DSR PDB Library.
|
||||
|
||||
The DSR PDB Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The DSR PDB Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the DSR PDB Library; see the file LICENSE.LGPL. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#ifndef CGAL_DSR_PDB_TRANSFORMS_H
|
||||
#define CGAL_DSR_PDB_TRANSFORMS_H
|
||||
#include <CGAL/PDB/basic.h>
|
||||
CGAL_PDB_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
class Protein;
|
||||
class Transform;
|
||||
class PDB;
|
||||
|
||||
//! Apply a Transform to all atoms of a Protein file
|
||||
void transform_protein(const Transform &t, Protein &p);
|
||||
|
||||
|
||||
//! Apply a Transform to all atoms of a PDB file
|
||||
void transform_pdb(const Transform &t, PDB &pdb);
|
||||
|
||||
CGAL_PDB_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
@ -1 +0,0 @@
|
|||
Daniel Russel <drussel@alumni.princeton.edu>
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
/* Copyright 2004
|
||||
Stanford University
|
||||
|
||||
This file is part of the DSR PDB Library.
|
||||
|
||||
The DSR PDB Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The DSR PDB Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the DSR PDB Library; see the file LICENSE.LGPL. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include <CGAL/PDB/Atom.h>
|
||||
#include <CGAL/PDB/internal/Error_logger.h>
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
#include <limits>
|
||||
CGAL_PDB_BEGIN_NAMESPACE
|
||||
|
||||
static double nan__=std::numeric_limits<double>::signaling_NaN();
|
||||
|
||||
//enum Type {INVALID=0, C,N,H,O, S, FE, PT};
|
||||
// Taken from the wikipedia, so don't trust them too much.
|
||||
double Atom::radii_[]={0, 1.70, 1.55, 1.20, 1.52, 1.85, 1.10, 1.75, nan__, nan__, nan__, nan__};
|
||||
|
||||
Atom::Type Atom::string_to_type(const char *cp) {
|
||||
if (std::strchr(cp, 'C') != NULL) return C;
|
||||
else if (std::strchr(cp,'N') != NULL) return N;
|
||||
else if (std::strchr(cp,'S') != NULL) return S;
|
||||
else if (std::strchr(cp,'O') != NULL) return O;
|
||||
else if (std::strchr(cp,'H') != NULL) return H;
|
||||
else if (std::strstr(cp,"FE") != NULL) return FE;
|
||||
else if (std::strstr(cp,"PT") != NULL) return PT;
|
||||
else {
|
||||
std::ostringstream em;
|
||||
em << "Couldn't parse atom type of " << cp;
|
||||
CGAL_PDB_INTERNAL_NS::error_logger.new_warning(em.str().c_str());
|
||||
return INVALID;
|
||||
}
|
||||
}
|
||||
CGAL_PDB_END_NAMESPACE
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
#include <CGAL/PDB/internal/Error_logger.h>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
CGAL_PDB_BEGIN_INTERNAL_NAMESPACE
|
||||
|
||||
Error_logger error_logger;
|
||||
|
||||
void Error_logger::new_warning(const char *str) {
|
||||
if (enabled_) {
|
||||
if (warnings_.find(str) == warnings_.end()) {
|
||||
for (std::map<std::string, int>::const_iterator it =warnings_.begin();
|
||||
it != warnings_.end(); ++it){
|
||||
assert(it->first != str);
|
||||
}
|
||||
warnings_[str]=0;
|
||||
}
|
||||
++warnings_[str];
|
||||
}
|
||||
}
|
||||
|
||||
void Error_logger::new_fatal_error(const char *err) {
|
||||
std::cerr << "DSRPDB fatal error: " << err << std::endl;
|
||||
assert(0);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
void Error_logger::new_internal_error(const char* err) {
|
||||
std::cerr << "DSRPDB internal error: " << err << std::endl;
|
||||
std::cerr << "Please report this to the author (and provide a PDB)." << std::endl;
|
||||
assert(0);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
void Error_logger::dump() {
|
||||
if (enabled_) {
|
||||
if (!context_.empty()) {
|
||||
std::cerr << "In PDB file " << context_ << ":\n";
|
||||
}
|
||||
for (std::map<std::string, int>::const_iterator it =warnings_.begin();
|
||||
it != warnings_.end(); ++it){
|
||||
if (it->second==1) {
|
||||
std::cerr << "DSRPDB Warning: " << it->first << std::endl;
|
||||
} else {
|
||||
std::cerr << "DSRPDB " << it->second << " occurences of Warning: " << it->first << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
warnings_.clear();
|
||||
}
|
||||
CGAL_PDB_END_INTERNAL_NAMESPACE
|
||||
|
|
@ -1,138 +0,0 @@
|
|||
/* Copyright 2004
|
||||
Stanford University
|
||||
|
||||
This file is part of the DSR PDB Library.
|
||||
|
||||
The DSR PDB Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The DSR PDB Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the DSR PDB Library; see the file LICENSE.LGPL. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include <CGAL/PDB/Model.h>
|
||||
#include <cassert>
|
||||
#include <CGAL/PDB/internal/pdb_utils.h>
|
||||
CGAL_PDB_BEGIN_NAMESPACE
|
||||
|
||||
Model::Model():index_(-1){}
|
||||
Model::Model(unsigned int i): index_(i){}
|
||||
size_t Model::number_of_chains() const {
|
||||
return chains_.size();
|
||||
}
|
||||
Protein &Model::chain(unsigned int i) {
|
||||
assert(i < chains_.size());
|
||||
return chains_[i];
|
||||
}
|
||||
const Protein &Model::chain(unsigned int i) const {
|
||||
assert(i < chains_.size());
|
||||
return chains_[i];
|
||||
}
|
||||
void Model::new_chain(const Protein &p){
|
||||
chains_.push_back(p);
|
||||
}
|
||||
|
||||
|
||||
void Model::process_line(const char *line) {
|
||||
CGAL_PDB_INTERNAL_NS::Line_type lt= CGAL_PDB_INTERNAL_NS::line_type(line);
|
||||
if (lt== CGAL_PDB_INTERNAL_NS::ATOM) {
|
||||
char chain=line[21];
|
||||
/*int numscan= sscanf(line, CGAL_PDB_INTERNAL_NS::atom_line_iformat_,
|
||||
&snum, name, &alt, resname, &chain, &resnum, &insertion_residue_code,
|
||||
&x,&y,&z, &occupancy, &tempFactor, segID, element, charge);
|
||||
assert(numscan >5);*/
|
||||
if (chains_.empty() || chains_.back().chain() != chain){
|
||||
chains_.push_back(Protein());
|
||||
//std::cout << "New chain " << chain << std::endl;
|
||||
}
|
||||
chains_.back().process_line(line);
|
||||
} else if (lt == CGAL_PDB_INTERNAL_NS::TER) {
|
||||
assert(!chains_.empty());
|
||||
chains_.back().process_line(line);
|
||||
} else if (lt== CGAL_PDB_INTERNAL_NS::HETATM){
|
||||
int snum=-1;
|
||||
char name[5]={'\0','\0','\0','\0','\0',};
|
||||
char alt='\0';
|
||||
char resname[4]={'\0','\0','\0','\0'};
|
||||
char chain;
|
||||
int resnum=-1;
|
||||
char insertion_residue_code;
|
||||
float x,y,z;
|
||||
float occupancy, tempFactor;
|
||||
char segID[5]={'\0','\0','\0','\0','\0'};
|
||||
char element[3]={'\0','\0','\0'};
|
||||
char charge[3]={'\0','\0','\0'};
|
||||
// What is a field is missing?
|
||||
int numscan= sscanf(line, CGAL_PDB_INTERNAL_NS::hetatom_line_iformat_,
|
||||
//"ATOM %5d%4s%1c%3s%1c%4d%1c%8f%8f%8f%6f%6f%4s%2s%2s",
|
||||
&snum, name, &alt, resname, &chain, &resnum, &insertion_residue_code,
|
||||
&x,&y,&z, &occupancy, &tempFactor, segID, element, charge);
|
||||
|
||||
Atom::Index sindex(snum);
|
||||
Atom a;
|
||||
//a.set_label(Residue::atom_label(al));
|
||||
a.set_cartesian_coords(Point(x,y,z));
|
||||
a.set_index(sindex);
|
||||
if (numscan >10) {
|
||||
a.set_occupancy(occupancy);
|
||||
}
|
||||
if (numscan >11) {
|
||||
a.set_temperature_factor(tempFactor);
|
||||
}
|
||||
a.set_segment_id(segID);
|
||||
a.set_element(element);
|
||||
a.set_charge(charge);
|
||||
a.set_type(Atom::string_to_type(name));
|
||||
|
||||
hetatoms_.push_back(std::pair<Hetatom_data, Atom>(Hetatom_data(resname, name, resnum, chain), a));
|
||||
|
||||
//residue(resnum-1)->set_coords (al, Point(x,y,z));
|
||||
//residue(resnum-1)->set_index(al, snum);
|
||||
//++cur_atom_index;
|
||||
|
||||
} else if (lt== CGAL_PDB_INTERNAL_NS::ENDMDL){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void Model::write(std::ostream &out) const {
|
||||
char line[81];
|
||||
|
||||
sprintf(line, "MODEL %8d ", index_);
|
||||
out << line << std::endl;
|
||||
for (unsigned int i=0; i< chains_.size(); ++i){
|
||||
chains_[i].write(out);
|
||||
}
|
||||
for (unsigned int i=0; i< hetatoms_.size(); ++i){
|
||||
//Point pt= res->cartesian_coords(al);
|
||||
const Atom &a= hetatoms_[i].second;
|
||||
Point pt = a.cartesian_coords();
|
||||
char alt=' ';
|
||||
char insertion_residue_code=' ';
|
||||
sprintf(line, CGAL_PDB_INTERNAL_NS::hetatom_line_oformat_,
|
||||
a.index().to_index(),
|
||||
hetatoms_[i].first.atom_name(), alt,
|
||||
hetatoms_[i].first.molecule_name(),
|
||||
hetatoms_[i].first.chain(),
|
||||
static_cast<unsigned int>(hetatoms_[i].first.molecule_number()),
|
||||
insertion_residue_code,
|
||||
pt.x(), pt.y(), pt.z(),
|
||||
a.occupancy(), a.temperature_factor(), a.segment_id(),
|
||||
a.element(), a.charge());
|
||||
out << line << std::endl;
|
||||
}
|
||||
for (unsigned int i=0; i< extra_.size(); ++i){
|
||||
out << extra_[i] << std::endl;
|
||||
}
|
||||
out << "ENDMDL " << std::endl;
|
||||
}
|
||||
|
||||
CGAL_PDB_END_NAMESPACE
|
||||
|
|
@ -1,106 +0,0 @@
|
|||
/* Copyright 2004
|
||||
Stanford University
|
||||
|
||||
This file is part of the DSR PDB Library.
|
||||
|
||||
The DSR PDB Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The DSR PDB Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the DSR PDB Library; see the file LICENSE.LGPL. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include <CGAL/PDB/PDB.h>
|
||||
#include <CGAL/PDB/internal/pdb_utils.h>
|
||||
#include <cassert>
|
||||
#include <CGAL/PDB/internal/Error_logger.h>
|
||||
CGAL_PDB_BEGIN_NAMESPACE
|
||||
|
||||
PDB::PDB(std::istream &in, bool print_errors) {
|
||||
load(in, print_errors);
|
||||
}
|
||||
PDB::PDB(){}
|
||||
PDB::~PDB(){}
|
||||
|
||||
void PDB::load(std::istream &in, bool print_errors){
|
||||
char line[600];
|
||||
|
||||
CGAL_PDB_INTERNAL_NS::error_logger.set_is_output(print_errors);
|
||||
|
||||
while (in.getline (line, 600)) {
|
||||
|
||||
CGAL_PDB_INTERNAL_NS::Line_type lt= CGAL_PDB_INTERNAL_NS::line_type(line);
|
||||
if (lt== CGAL_PDB_INTERNAL_NS::HEADER) {
|
||||
header_.push_back(std::string(line));
|
||||
} else if (lt== CGAL_PDB_INTERNAL_NS::DBREF){
|
||||
header_.push_back(std::string(line));
|
||||
} else if (lt== CGAL_PDB_INTERNAL_NS::SEQRES){
|
||||
header_.push_back(std::string(line));
|
||||
} else if (lt== CGAL_PDB_INTERNAL_NS::MODEL) {
|
||||
int mnum=0;
|
||||
char buf[81];
|
||||
sscanf(line, "%s %d", buf, &mnum);
|
||||
new_model(Model(mnum));
|
||||
} else if ( lt== CGAL_PDB_INTERNAL_NS::HETATM || lt== CGAL_PDB_INTERNAL_NS::ATOM
|
||||
|| lt== CGAL_PDB_INTERNAL_NS::TER || lt== CGAL_PDB_INTERNAL_NS::ENDMDL){
|
||||
if (models_.empty()){
|
||||
new_model(Model(0));
|
||||
}
|
||||
models_.back().process_line(line);
|
||||
} else if (lt== CGAL_PDB_INTERNAL_NS::MASTER){
|
||||
} else if (lt == CGAL_PDB_INTERNAL_NS::END){
|
||||
}
|
||||
}
|
||||
for (unsigned int i=0; i< models_.size(); ++i){
|
||||
for (unsigned int j=0; j< models_[i].number_of_chains(); ++j){
|
||||
models_[i].chain(j).set_has_bonds(true);
|
||||
}
|
||||
}
|
||||
|
||||
CGAL_PDB_INTERNAL_NS::error_logger.dump();
|
||||
}
|
||||
|
||||
|
||||
void PDB::new_model(const Model &m){
|
||||
models_.push_back(m);
|
||||
}
|
||||
Model &PDB::model(unsigned int i) {
|
||||
assert(i < models_.size());
|
||||
return models_[i];
|
||||
};
|
||||
|
||||
const Model &PDB::model(unsigned int i) const {
|
||||
assert(i < models_.size());
|
||||
return models_[i];
|
||||
};
|
||||
size_t PDB::number_of_models() const {
|
||||
return models_.size();
|
||||
}
|
||||
|
||||
void PDB::write(std::ostream &out) const {
|
||||
for (unsigned int i=0; i< header_.size(); ++i){
|
||||
out << header_[i] << std::endl;
|
||||
}
|
||||
for (unsigned int i=0; i< models_.size(); ++i){
|
||||
models_[i].write(out);
|
||||
}
|
||||
out << "END \n";
|
||||
}
|
||||
|
||||
|
||||
PDB::Header_iterator PDB::header_begin() const {
|
||||
return header_.begin();
|
||||
}
|
||||
PDB::Header_iterator PDB::header_end() const {
|
||||
return header_.end();
|
||||
}
|
||||
|
||||
CGAL_PDB_END_NAMESPACE
|
||||
|
|
@ -1,350 +0,0 @@
|
|||
/* Copyright 2004
|
||||
Stanford University
|
||||
|
||||
This file is part of the DSR PDB Library.
|
||||
|
||||
The DSR PDB Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The DSR PDB Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the DSR PDB Library; see the file LICENSE.LGPL. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include <CGAL/PDB/Protein.h>
|
||||
#include <CGAL/PDB/Residue.h>
|
||||
#include <CGAL/PDB/internal/Error_logger.h>
|
||||
#include <sstream>
|
||||
|
||||
CGAL_PDB_BEGIN_NAMESPACE
|
||||
|
||||
namespace {
|
||||
Residue dummy_residue_;
|
||||
Atom dummy_atom_;
|
||||
}
|
||||
|
||||
Protein::Protein(): chain_(' '){}
|
||||
|
||||
char Protein::chain() const {return chain_;}
|
||||
|
||||
void Protein::set_chain(char c) {chain_=c;}
|
||||
|
||||
/*bProtein::Protein(const dsr::vector<Residue_label> &seq) {
|
||||
for (unsigned int i=0; i< seq.size(); ++i){
|
||||
residues_.push_back(Residue::new_residue(seq[i]));
|
||||
}
|
||||
model_=1;
|
||||
};*/
|
||||
|
||||
|
||||
std::vector<Residue::Type> Protein::sequence() const{
|
||||
std::vector<Residue::Type> ret(residues_.size());
|
||||
for (unsigned int i=0; i< residues_.size(); ++i){
|
||||
ret[i]= residues_[i].type();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
unsigned int Protein::number_of_atoms() const {
|
||||
unsigned int ret=0;
|
||||
for (unsigned int i=0; i< residues_.size(); ++i){
|
||||
ret += residues_[i].number_of_atoms();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
unsigned int Protein::number_of_bonds() const {
|
||||
unsigned int ret=0;
|
||||
for (unsigned int i=0; i< residues_.size(); ++i){
|
||||
ret += residues_[i].number_of_bonds();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Protein::dump(std::ostream &out) const {
|
||||
for (unsigned int i=0; i< residues_.size(); ++i){
|
||||
out << "Residue " << residues_[i].index() << std::endl;
|
||||
residues_[i].dump(out);
|
||||
}
|
||||
}
|
||||
|
||||
void Protein::new_residue(const Residue &res){
|
||||
if (!residues_.empty() && res.index() <= residues_.back().index()){
|
||||
std::ostringstream eout;
|
||||
eout << "Warning, newly added residue has index "<< res.index()
|
||||
<< " while previous residue has index " << residues_.back().index();
|
||||
CGAL_PDB_INTERNAL_NS::error_logger.new_warning(eout.str().c_str());
|
||||
}
|
||||
if (!residues_.empty() && !residues_.back().has_atom(Residue::AL_C)) {
|
||||
std::ostringstream eout;
|
||||
eout << "Warning, newly added residue " << residues_.back().index()
|
||||
<< " either missing atom C or atoms out of order in pdb.";
|
||||
CGAL_PDB_INTERNAL_NS::error_logger.new_warning(eout.str().c_str());
|
||||
}
|
||||
if (!residues_.empty() && !residues_.back().has_atom(Residue::AL_N)) {
|
||||
std::ostringstream eout;
|
||||
eout << "Warning, newly added residue " << residues_.back().index()
|
||||
<< " either missing atom N or atoms out of order in pdb.";
|
||||
CGAL_PDB_INTERNAL_NS::error_logger.new_warning(eout.str().c_str());
|
||||
}
|
||||
if (!residues_.empty() && !residues_.back().has_atom(Residue::AL_CA)) {
|
||||
std::ostringstream eout;
|
||||
eout << "Warning, newly added residue " << residues_.back().index()
|
||||
<< " either missing atom CA or atoms out of order in pdb. ";
|
||||
CGAL_PDB_INTERNAL_NS::error_logger.new_warning(eout.str().c_str());
|
||||
}
|
||||
residues_.push_back(res);
|
||||
//residues_.back().write('t', std::cout);
|
||||
}
|
||||
|
||||
#if 0
|
||||
Protein::Graph Protein::graph() const {
|
||||
std::vector<Point> points;
|
||||
std::vector<std::pair<int,int> > edges;
|
||||
//std::map<int,int> index_index_map;
|
||||
int max_index=-1;
|
||||
for (unsigned int i=0; i< residues_.size(); ++i){
|
||||
const Residue &r= residues_[i];
|
||||
//dsr::vector<Residue::Atom_label> als= r->atoms();
|
||||
//dsr::vector<Residue::Bond> bls= r->bonds();
|
||||
|
||||
/*for (Residue::Atoms_iterator it= r->atoms_begin(); it != r->atoms_end(); ++it){
|
||||
index_index_map[it->index()]= index_index_map.size();
|
||||
}*/
|
||||
for (Residue::Bonds_iterator bit= r.bonds_begin(); bit != r.bonds_end(); ++bit){
|
||||
edges.push_back(std::pair<int,int>(bit->first,
|
||||
bit->second));
|
||||
max_index= (std::max)(max_index, bit->first);
|
||||
max_index= (std::max)(max_index, bit->second);
|
||||
}
|
||||
if (i!= 0){
|
||||
edges.push_back(std::pair<int,int>(r.atom(Residue::AL_N).index(),
|
||||
residues_[i-1].atom(Residue::AL_C).index()));
|
||||
}
|
||||
}
|
||||
|
||||
points.resize(max_index);
|
||||
for (unsigned int i=0; i< residues_.size(); ++i){
|
||||
const Residue &r= residues_[i];
|
||||
for (Residue::Atoms_iterator it= r.atoms_begin(); it != r.atoms_end(); ++it){
|
||||
points[it->second.index()]= it->second.cartesian_coords();
|
||||
}
|
||||
}
|
||||
return Graph(points,edges);
|
||||
}
|
||||
|
||||
std::vector<Point> Protein::backbone() const {
|
||||
// skip ACE, probably should do something more clever
|
||||
std::vector<Point> pts;
|
||||
for (Const_residues_iterator it= residues_begin(); it != residues_.end(); ++it) {
|
||||
const Residue &aa= *it;
|
||||
|
||||
for (Residue::Atoms_iterator it= aa.atoms_begin(); it != aa.atoms_end(); ++it){
|
||||
if (it->first == Residue::AL_C || it->first== Residue::AL_CA || it->first== Residue::AL_N) {
|
||||
Point pt=it->second.cartesian_coords();
|
||||
pts.push_back(pt);
|
||||
}
|
||||
}
|
||||
}
|
||||
return pts;
|
||||
}
|
||||
#endif
|
||||
|
||||
Protein::Atoms_iterator Protein::atoms_begin() {
|
||||
return Atoms_iterator(residues_.begin(), residues_.end());
|
||||
}
|
||||
Protein::Atoms_iterator Protein::atoms_end() {
|
||||
return Atoms_iterator(residues_.end(), residues_.end());
|
||||
}
|
||||
|
||||
Protein::Const_atoms_iterator Protein::atoms_begin() const{
|
||||
return Const_atoms_iterator(residues_.begin(), residues_.end());
|
||||
}
|
||||
Protein::Const_atoms_iterator Protein::atoms_end() const{
|
||||
return Const_atoms_iterator(residues_.end(), residues_.end());
|
||||
}
|
||||
Protein::Bonds_iterator Protein::bonds_begin() const{
|
||||
CGAL_PDB_INTERNAL_NS::error_logger.new_warning("bonds_begin() called without has_bonds() being true.\n");
|
||||
return Bonds_iterator(residues_.begin(), residues_.end());
|
||||
}
|
||||
Protein::Bonds_iterator Protein::bonds_end() const{
|
||||
return Bonds_iterator(residues_.end(), residues_.end());
|
||||
}
|
||||
|
||||
const Residue& Protein::residue(Residue::Index i) const{
|
||||
unsigned int cur= residue_offset(i);
|
||||
if (cur == residues_.size()){
|
||||
std::ostringstream oss;
|
||||
oss << "residue(int) called with index that does not correspond to a valid residue: " << i;
|
||||
CGAL_PDB_INTERNAL_NS::error_logger.new_warning(oss.str().c_str());
|
||||
return dummy_residue_;
|
||||
} else {
|
||||
return residues_[cur];
|
||||
}
|
||||
}
|
||||
|
||||
bool Protein::has_residue(Residue::Index i) const {
|
||||
return residue_offset(i) != residues_.size();
|
||||
}
|
||||
|
||||
unsigned int Protein::residue_offset(Residue::Index i) const {
|
||||
unsigned int cur= residues_.size();
|
||||
if (!residues_.empty()){
|
||||
cur = std::min BOOST_PREVENT_MACRO_SUBSTITUTION(i.to_index(), cur-1);
|
||||
if (residues_[cur].index() > i) {
|
||||
do {
|
||||
--cur;
|
||||
} while (cur > 0 && residues_[cur].index() > i);
|
||||
} else if (residues_[cur].index() < i) {
|
||||
do {
|
||||
--cur;
|
||||
} while (cur < residues_.size() && residues_[cur].index() < i);
|
||||
}
|
||||
if (residues_[cur].index() != i) cur= residues_.size();
|
||||
}
|
||||
return cur;
|
||||
}
|
||||
|
||||
unsigned int Protein::residue_offset_of_atom_index(Atom::Index index) const {
|
||||
for (int i= residues_.size()-1; i >=0; --i) {
|
||||
if (residues_[i].min_atom_index() <= index) return i;
|
||||
}
|
||||
return residues_.size();
|
||||
}
|
||||
|
||||
void Protein::set_atom(Atom::Index index, const Atom &a) {
|
||||
unsigned int ind= residue_offset_of_atom_index(index);
|
||||
if (ind == residues_.size()) {
|
||||
std::ostringstream oss;
|
||||
oss << "set_atom called with index " << index << " which does not corresponding to an existing atom.";
|
||||
CGAL_PDB_INTERNAL_NS::error_logger.new_warning(oss.str().c_str());
|
||||
} else {
|
||||
residues_[ind].atoms_iterator_from_index(index)->second=a;
|
||||
}
|
||||
//if (!min_atom_index_ || a.index() < min_atom_index_) min_atom_index_=a.index();
|
||||
}
|
||||
|
||||
const Atom& Protein::atom(Atom::Index index) const {
|
||||
unsigned int ind= residue_offset_of_atom_index(index);
|
||||
if (ind == residues_.size()) {
|
||||
std::ostringstream oss;
|
||||
oss << "set_atom called with index " << index << " which does not corresponding to an existing atom.";
|
||||
CGAL_PDB_INTERNAL_NS::error_logger.new_warning(oss.str().c_str());
|
||||
return dummy_atom_;
|
||||
} else {
|
||||
return residues_[ind].atoms_iterator_from_index(index)->second;
|
||||
}
|
||||
}
|
||||
|
||||
void Protein::erase_atom(Atom::Index index) {
|
||||
unsigned int ind= residue_offset_of_atom_index(index);
|
||||
if (ind == residues_.size()) {
|
||||
} else {
|
||||
residues_[ind].erase_atom(residues_[ind].atom_label(index));
|
||||
}
|
||||
}
|
||||
|
||||
Atom::Index Protein::parent_atom(Atom::Index index) const {
|
||||
unsigned int ind= residue_offset_of_atom_index(index);
|
||||
if (ind == residues_.size()) {
|
||||
std::ostringstream oss;
|
||||
oss << "parent_atom called with index " << index << " which does not corresponding to an existing atom.";
|
||||
CGAL_PDB_INTERNAL_NS::error_logger.new_warning(oss.str().c_str());
|
||||
return Atom::Index();
|
||||
} else {
|
||||
Residue::Atom_label al= residues_[ind].atoms_iterator_from_index(index)->first;
|
||||
if (al != Residue::AL_CA && al != Residue::AL_C && al != Residue::AL_N) {
|
||||
std::ostringstream oss;
|
||||
oss << "parent_atom called with an atom which was not an N, CA or C.";
|
||||
CGAL_PDB_INTERNAL_NS::error_logger.new_warning(oss.str().c_str());
|
||||
return Atom::Index();
|
||||
}
|
||||
if (al == Residue::AL_C) {
|
||||
return residues_[ind].atom(Residue::AL_CA).index();
|
||||
} else if (al == Residue::AL_CA) {
|
||||
return residues_[ind].atom(Residue::AL_N).index();
|
||||
} else {
|
||||
if (ind==0) return Atom::Index();
|
||||
else return residues_[ind-1].atom(Residue::AL_C).index();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Spherical_point Protein::spherical_coordinates(Atom::Index index) const {
|
||||
Atom::Index p= parent_atom(index);
|
||||
Point pc(100000, 100000, 100000);
|
||||
Point popc(100000, -100000, 100000);
|
||||
Point popopc(100000, -100000, -100000);
|
||||
if (p != Atom::Index()) {
|
||||
pc= atom(p).cartesian_coords();
|
||||
Atom::Index pop= parent_atom(p);
|
||||
if (pop != Atom::Index()) {
|
||||
popc= atom(pop).cartesian_coords();
|
||||
Atom::Index popop= parent_atom(pop);
|
||||
if (popop != Atom::Index()){
|
||||
popopc= atom(popop).cartesian_coords();
|
||||
}
|
||||
}
|
||||
}
|
||||
Construct_spherical_point csp(pc, popc, popopc);
|
||||
return csp(atom(index).cartesian_coords());
|
||||
}
|
||||
|
||||
|
||||
const Residue& Protein::residue_containing_atom(Atom::Index atom_index) const{
|
||||
unsigned int rindex= residue_offset_of_atom_index(atom_index);
|
||||
if (rindex == residues_.size() || residues_[rindex].atom_label(atom_index) == Residue::AL_INVALID) {
|
||||
std::ostringstream oss;
|
||||
oss << "Protein::atom_label_of_atom() called with uninitialized atom " << atom_index;
|
||||
CGAL_PDB_INTERNAL_NS::error_logger.new_warning(oss.str().c_str());
|
||||
return dummy_residue_;
|
||||
}
|
||||
return residues_[rindex];
|
||||
}
|
||||
|
||||
Residue& Protein::residue_containing_atom(Atom::Index atom_index) {
|
||||
unsigned int rindex= residue_offset_of_atom_index(atom_index);
|
||||
if (rindex == residues_.size() || residues_[rindex].atom_label(atom_index) == Residue::AL_INVALID) {
|
||||
std::ostringstream oss;
|
||||
oss << "Protein::atom_label_of_atom() called with uninitialized atom " << atom_index;
|
||||
CGAL_PDB_INTERNAL_NS::error_logger.new_warning(oss.str().c_str());
|
||||
return dummy_residue_;
|
||||
}
|
||||
return residues_[rindex];
|
||||
}
|
||||
|
||||
/*Residue::Atom_label Protein::atom_label_of_atom(int atom_index) const {
|
||||
int rindex= residue_index_of_atom_index(atom_index);
|
||||
Residue::Const_atoms_iterator it= residues_[rindex].atoms_iterator_from_index(atom_index);
|
||||
if (it == residues_[rindex].atoms_end()) {
|
||||
std::ostringstream oss;
|
||||
oss << "Protein::atom_label_of_atom() called with uninitialized atom " << atom_index;
|
||||
CGAL_PDB_INTERNAL_NS::error_logger.new_warning(oss.str().c_str());
|
||||
return Residue::AL_INVALID;
|
||||
} else {
|
||||
return it->first;
|
||||
}
|
||||
}*/
|
||||
|
||||
#if 0
|
||||
Protein::Backbone_coordinates_iterator Protein::backbone_coordinates_begin() const{
|
||||
if (residues_.empty()){
|
||||
Backbone_coordinates_iterator b(residues_.begin(), residues_.end());
|
||||
Backbone_coordinates_iterator e(residues_.begin(), residues_.end());
|
||||
assert(b==e);
|
||||
}
|
||||
return Backbone_coordinates_iterator(residues_.begin(), residues_.end());
|
||||
}
|
||||
Protein::Backbone_coordinates_iterator Protein::backbone_coordinates_end() const{
|
||||
return Backbone_coordinates_iterator(residues_.end(), residues_.end());
|
||||
}
|
||||
#endif
|
||||
CGAL_PDB_END_NAMESPACE
|
||||
|
|
@ -1,252 +0,0 @@
|
|||
/* Copyright 2004
|
||||
Stanford University
|
||||
|
||||
This file is part of the DSR PDB Library.
|
||||
|
||||
The DSR PDB Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The DSR PDB Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the DSR PDB Library; see the file LICENSE.LGPL. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include <CGAL/PDB/Protein.h>
|
||||
#include <CGAL/PDB/Residue.h>
|
||||
#include <CGAL/PDB/internal/pdb_utils.h>
|
||||
#include <CGAL/PDB/internal/Error_logger.h>
|
||||
#include <sstream>
|
||||
CGAL_PDB_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
|
||||
/*static unsigned int getSequenceBeginning (const char* line)
|
||||
{
|
||||
|
||||
char s[5];
|
||||
|
||||
strncpy (s, line + 14, 4); s[4] = '\0';
|
||||
return atoi (s);
|
||||
}*/
|
||||
|
||||
|
||||
/*static unsigned int getLineSerialNumber (const char* line) {
|
||||
char s[3];
|
||||
strncpy (s, line + 8, 2); s[2] = '\0';
|
||||
return atoi (s);
|
||||
}*/
|
||||
|
||||
/*static unsigned int getNumberOfResidues (const char* line)
|
||||
{
|
||||
|
||||
char s[5];
|
||||
|
||||
strncpy (s, line + 13, 4); s[4] = '\0';
|
||||
return atoi (s);
|
||||
|
||||
}*/
|
||||
|
||||
unsigned int getSequenceNumber (const char* line)
|
||||
{
|
||||
|
||||
char s[5];
|
||||
|
||||
strncpy (s, line + 22, 4); s[4] = '\0';
|
||||
return atoi (s);
|
||||
|
||||
}
|
||||
|
||||
void Protein::process_line(const char *line) {
|
||||
CGAL_PDB_INTERNAL_NS::Line_type lt= CGAL_PDB_INTERNAL_NS::line_type(line);
|
||||
if (lt== CGAL_PDB_INTERNAL_NS::TER) {
|
||||
|
||||
} else if (lt == CGAL_PDB_INTERNAL_NS::ATOM) {
|
||||
// the read values are not zero padded so we must fill the buffers for strings with 0s.
|
||||
int snum=-1;
|
||||
char name[5]={'\0','\0','\0','\0','\0',};
|
||||
char alt='\0';
|
||||
char resname[4]={'\0','\0','\0','\0'};
|
||||
char chain;
|
||||
int resnum=-1;
|
||||
char insertion_residue_code;
|
||||
float x,y,z;
|
||||
float occupancy, tempFactor;
|
||||
char segID[5]={'\0','\0','\0','\0','\0'};
|
||||
char element[3]={'\0','\0','\0'};
|
||||
char charge[3]={'\0','\0','\0'};
|
||||
int numscan= sscanf(line, CGAL_PDB_INTERNAL_NS::atom_line_iformat_,
|
||||
//"ATOM %5d%4s%1c%3s%1c%4d%1c%8f%8f%8f%6f%6f%4s%2s%2s",
|
||||
&snum, name, &alt, resname, &chain, &resnum,
|
||||
&insertion_residue_code,
|
||||
&x,&y,&z, &occupancy, &tempFactor, segID, element, charge);
|
||||
if (chain_==' ') chain_=chain;
|
||||
if (!(chain_==' ' || chain== chain_)){
|
||||
std::ostringstream oss;
|
||||
oss << "Confusion over chain numbers. Expected " << chain_ << " got " << chain
|
||||
<< " on line:\n" << line;
|
||||
CGAL_PDB_INTERNAL_NS::error_logger.new_warning(oss.str().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
if (resnum < 0) {
|
||||
std::ostringstream oss;
|
||||
oss << "Got negative residue index on line " << line;
|
||||
CGAL_PDB_INTERNAL_NS::error_logger.new_warning(oss.str().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
Residue::Index resindex(resnum);
|
||||
|
||||
Residue::Atom_label al= Residue::atom_label(name);
|
||||
|
||||
if (al != Residue::AL_OTHER) {
|
||||
Residue *cur_residue=NULL;
|
||||
|
||||
if (insertion_residue_code != ' '){
|
||||
if (insert_residues_[resindex].empty()
|
||||
|| insert_residues_[resindex].back().first != insertion_residue_code) {
|
||||
Residue::Type rl= Residue::type(resname);
|
||||
insert_residues_[resindex].push_back(std::make_pair(insertion_residue_code,
|
||||
Residue(rl)));
|
||||
insert_residues_[resindex].back().second.set_index(resindex);
|
||||
}
|
||||
cur_residue= &insert_residues_[resindex].back().second;
|
||||
} else {
|
||||
if (residues_.empty() || residues_.back().index() != resindex) {
|
||||
std::string nm(line, 17, 3);
|
||||
Residue::Type rl= Residue::type(resname);
|
||||
residues_.push_back(Residue(rl));
|
||||
residues_.back().set_index(resindex);
|
||||
}
|
||||
cur_residue =&residues_.back();
|
||||
}
|
||||
|
||||
Atom::Index sindex(snum);
|
||||
|
||||
Atom a;
|
||||
//a.set_label(Residue::atom_label(al));
|
||||
a.set_cartesian_coords(Point(x,y,z));
|
||||
a.set_index(sindex);
|
||||
if (numscan >10) {
|
||||
a.set_occupancy(occupancy);
|
||||
}
|
||||
if (numscan >11) {
|
||||
a.set_temperature_factor(tempFactor);
|
||||
}
|
||||
a.set_segment_id(segID);
|
||||
a.set_element(element);
|
||||
a.set_charge(charge);
|
||||
|
||||
if (cur_residue->index().to_index()
|
||||
!= static_cast<unsigned int>(resnum)){
|
||||
std::ostringstream oss;
|
||||
oss << "Confusion over residue numbers. Expected" << cur_residue->index()
|
||||
<< " got " << resnum
|
||||
<< " on line:\n" << line << std::endl;
|
||||
CGAL_PDB_INTERNAL_NS::error_logger.new_fatal_error(oss.str().c_str());
|
||||
return;
|
||||
}
|
||||
if (cur_residue->type() != Residue::type(resname)){
|
||||
std::ostringstream oss;
|
||||
oss << "Confusion over residue types. Expected"
|
||||
<< Residue::type_string(cur_residue->type())
|
||||
<< " got " << Residue::type_string(Residue::type(resname))
|
||||
<< " on line:\n" << line << std::endl;
|
||||
CGAL_PDB_INTERNAL_NS::error_logger.new_fatal_error(oss.str().c_str());
|
||||
}
|
||||
//assert(cur_residue->type() == Residue::type(resname));
|
||||
|
||||
cur_residue->set_atom(al, a);
|
||||
|
||||
//residue(resnum-1)->set_coords (al, Point(x,y,z));
|
||||
//residue(resnum-1)->set_index(al, snum);
|
||||
//++cur_atom_index;
|
||||
} else {
|
||||
/*std::ostringstream out;
|
||||
out << "Unhandled atom type: " << name;
|
||||
CGAL_PDB_INTERNAL_NS::error_logger.new_warning(out.str().c_str());*/
|
||||
}
|
||||
} else {
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Protein::Protein(std::istream &in, bool print_errors) {
|
||||
char line[1000];
|
||||
chain_=' ';
|
||||
|
||||
CGAL_PDB_INTERNAL_NS::error_logger.set_is_output(print_errors);
|
||||
|
||||
do {
|
||||
in.getline (line, 1000);
|
||||
if (!in) break;
|
||||
|
||||
CGAL_PDB_INTERNAL_NS::Line_type lt= CGAL_PDB_INTERNAL_NS::line_type(line);
|
||||
if (lt== CGAL_PDB_INTERNAL_NS::HEADER) {
|
||||
header_.push_back(std::string(line));
|
||||
} else if (lt== CGAL_PDB_INTERNAL_NS::DBREF){
|
||||
header_.push_back(std::string(line));
|
||||
//seqBegin = getSequenceBeginning (line);
|
||||
} else if (lt== CGAL_PDB_INTERNAL_NS::SEQRES){
|
||||
header_.push_back(std::string(line));
|
||||
} else if (lt== CGAL_PDB_INTERNAL_NS::ATOM){
|
||||
process_line(line);
|
||||
} else if (lt== CGAL_PDB_INTERNAL_NS::TER || lt == CGAL_PDB_INTERNAL_NS::END){
|
||||
break;
|
||||
}
|
||||
} while (true);
|
||||
set_has_bonds(true);
|
||||
CGAL_PDB_INTERNAL_NS::error_logger.dump();
|
||||
}
|
||||
|
||||
void Protein::write_pdb(std::ostream &out) const {
|
||||
assert(!residues_.empty());
|
||||
for (unsigned int i=0; i< header_.size(); ++i){
|
||||
out << header_[i] << std::endl;
|
||||
}
|
||||
|
||||
char line[81];
|
||||
|
||||
sprintf(line, "MODEL %8d ", 1);
|
||||
out << line << std::endl;
|
||||
|
||||
// int anum=1;
|
||||
write(out);
|
||||
|
||||
out << "ENDMDL " << std::endl;
|
||||
}
|
||||
|
||||
void Protein::write(std::ostream &out) const {
|
||||
char line[81];
|
||||
// int anum=1;
|
||||
|
||||
for (unsigned int i = 0; i < residues_.size(); i++) {
|
||||
const Residue &res= residues_[i];
|
||||
//Residue::Label rl = res.label();
|
||||
//residues_[i]->atoms();
|
||||
res.write(chain_, ' ', out);
|
||||
Residue::Index index = res.index();
|
||||
if (insert_residues_.find(index) != insert_residues_.end()) {
|
||||
for (unsigned int i=0; i< insert_residues_.find(index)->second.size(); ++i){
|
||||
insert_residues_.find(index)->second.at(i).second.write(chain_,
|
||||
insert_residues_.find(index)->second.at(i).first, out);
|
||||
}
|
||||
}
|
||||
}
|
||||
const char *terformat="TER %5d %3s %c%3d%c";
|
||||
if (!residues_.empty()) {
|
||||
sprintf(line, terformat, residues_.back().last_atom_index().to_index()+1,
|
||||
Residue::type_string(residues_.back().type()).c_str(), chain(), residues_.back().index().to_index(),' ');
|
||||
out << line << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
CGAL_PDB_END_NAMESPACE
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
#include <CGAL/PDB/Quaternion.h>
|
||||
CGAL_PDB_BEGIN_NAMESPACE
|
||||
|
||||
Quaternion::Quaternion(const double m[3][3]){
|
||||
int i;
|
||||
NT qs2, qx2, qy2, qz2, tmp;
|
||||
NT norm;
|
||||
|
||||
for (i=0; i<4; ++i){
|
||||
q_[i] = 0;
|
||||
}
|
||||
|
||||
//first compute squared magnitudes of q components - at least one
|
||||
//will be greater than 0 since q is unit magnitude
|
||||
|
||||
qs2 = 0.25 * (m[0][0] + m[1][1]
|
||||
+ m[2][2] + 1);
|
||||
qx2 = qs2 - 0.5 * (m[1][1] + m[2][2]);
|
||||
qy2 = qs2 - 0.5 * (m[2][2] + m[0][0]);
|
||||
qz2 = qs2 - 0.5 * (m[0][0] + m[1][1]);
|
||||
|
||||
//compute signed q components using numerically stable method
|
||||
if ((qs2 >= qx2) & (qs2 >= qy2) & (qs2 >= qz2)){
|
||||
q_[0] = sqrt(qs2);
|
||||
tmp = 0.25 / q_[0];
|
||||
q_[1] = (m[2][1] - m[1][2]) * tmp;
|
||||
q_[2] = (m[0][2] - m[2][0]) * tmp;
|
||||
q_[3] = (m[1][0] - m[0][1]) * tmp;
|
||||
} else if ((qx2 >= qs2) & (qx2 >= qy2) & (qx2 >= qz2)){
|
||||
q_[1] = sqrt(qx2);
|
||||
tmp = 0.25 / q_[1];
|
||||
q_[0] = (m[2][1] - m[1][2]) * tmp;
|
||||
q_[2] = (m[0][1] + m[1][0]) * tmp;
|
||||
q_[3] = (m[0][2] + m[2][0]) * tmp;
|
||||
} else if ((qy2 >= qs2) & (qy2 >= qx2) & (qy2 >= qz2)){
|
||||
q_[2] = sqrt(qy2);
|
||||
tmp = 0.25 / q_[2];
|
||||
q_[0] = (m[0][2] - m[2][0]) * tmp;
|
||||
q_[3] = (m[1][2] + m[2][1]) * tmp;
|
||||
q_[1] = (m[1][0] + m[0][1]) * tmp;
|
||||
} else if ((qz2 >= qs2) & (qz2 >= qx2) & (qz2 >= qy2)){
|
||||
q_[3] = sqrt(qz2);
|
||||
tmp = 0.25 / q_[3];
|
||||
q_[0] = (m[1][0] - m[0][1]) * tmp;
|
||||
q_[1] = (m[2][0] + m[0][2]) * tmp;
|
||||
q_[2] = (m[2][1] + m[1][2]) * tmp;
|
||||
}
|
||||
|
||||
// for consistency, force positive scalar component [ (s; v) = (-s; -v) ]
|
||||
if (q_[0] < 0){
|
||||
for (i=0; i<4; ++i){
|
||||
q_[i] = -q_[i];
|
||||
}
|
||||
}
|
||||
|
||||
norm = sqrt(q_[0]*q_[0] + q_[1]*q_[1]
|
||||
+ q_[2]*q_[2] + q_[3]*q_[3]);
|
||||
for (i=0; i<4; ++i){
|
||||
q_[i] /= norm;
|
||||
}
|
||||
|
||||
//the first element we can uniquely derive from others
|
||||
// part_quarternion = Vector3D(quaternion[1], quaternion[2], quaternion[3]);
|
||||
//for (i=0; i<3; ++i){
|
||||
//part_quarternion[i] =
|
||||
}
|
||||
CGAL_PDB_END_NAMESPACE
|
||||
|
|
@ -1,409 +0,0 @@
|
|||
/* Copyright 2004
|
||||
Stanford University
|
||||
|
||||
This file is part of the DSR PDB Library.
|
||||
|
||||
The DSR PDB Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The DSR PDB Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the DSR PDB Library; see the file LICENSE.LGPL. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include <CGAL/PDB/Residue.h>
|
||||
#include <CGAL/PDB/internal/Residue_data.h>
|
||||
#include <CGAL/PDB/internal/pdb_utils.h>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
#include <CGAL/PDB/internal/Error_logger.h>
|
||||
#include <limits>
|
||||
#include <sstream>
|
||||
|
||||
CGAL_PDB_BEGIN_NAMESPACE
|
||||
|
||||
namespace {
|
||||
Atom dummy_atom_2;
|
||||
}
|
||||
|
||||
void Residue::set_has_bonds(bool tf) {
|
||||
typedef Residue_data::Possible_bond Possible_bond;
|
||||
|
||||
if (!tf) {
|
||||
bonds_.clear();
|
||||
} else {
|
||||
const std::vector<Possible_bond >& bonds= Residue_data::amino_acid_data_[type()].bonds;
|
||||
for (unsigned int i=0; i< bonds.size(); ++i){
|
||||
Const_atoms_iterator itf= atoms_.find(bonds[i].first);
|
||||
Const_atoms_iterator its= atoms_.find(bonds[i].second);
|
||||
if ( itf != atoms_.end() && its != atoms_.end()){
|
||||
bonds_.push_back(Bond(itf->second.index(), its->second.index()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool Residue::has_atom(Residue::Atom_label ial) const {
|
||||
Residue::Atom_label al= Residue_data::fix_atom_label(label_, ial);
|
||||
assert(can_have_atom(al));
|
||||
return atoms_.find(al) != atoms_.end();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool Residue::can_have_atom(Residue::Atom_label ial) const {
|
||||
if (ial== AL_INVALID) return false; // hack to avoid some circularity
|
||||
Residue::Atom_label al= Residue_data::fix_atom_label(label_, ial);
|
||||
//assert(Residue_data::amino_acid_data_.find(label_)!= Residue_data::amino_acid_data_.end());
|
||||
for (unsigned int i=0; i< Residue_data::amino_acid_data_[label_].atoms.size(); ++i){
|
||||
if (Residue_data::amino_acid_data_[label_].atoms[i] == al) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const Atom &Residue::atom(Residue::Atom_label al) const {
|
||||
Residue::Atom_label fal= Residue_data::fix_atom_label(label_, al);
|
||||
//int fa= find_atom(al);
|
||||
if (atoms_.find(fal) != atoms_.end()) return atoms_.find(fal)->second;
|
||||
else {
|
||||
return dummy_atom_2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Residue::erase_atom(Residue::Atom_label al) {
|
||||
Residue::Atom_label fal= Residue_data::fix_atom_label(label_, al);
|
||||
//int fa= find_atom(al);
|
||||
atoms_.erase(fal);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Residue::set_atom(Residue::Atom_label ial, const Atom &a) {
|
||||
Residue::Atom_label al= Residue_data::fix_atom_label(label_, ial);
|
||||
if (!can_have_atom(al)){
|
||||
CGAL_PDB_INTERNAL_NS::error_logger.new_warning((std::string("Trying to set invalid atom ") + atom_label_string(ial)
|
||||
+ " on a residue of type " + type_string(label_)).c_str());
|
||||
}
|
||||
if (al == AL_INVALID) {
|
||||
return;
|
||||
}
|
||||
//assert(atoms_.find(al)== atoms_.end());
|
||||
//bonds_.clear();
|
||||
atoms_[al]=a;
|
||||
// This is a bit evil, I haven't figured out a better way though.
|
||||
atoms_[al].set_type(element(al));
|
||||
if (min_atom_index_ != Atom::Index()) {
|
||||
min_atom_index_= std::min BOOST_PREVENT_MACRO_SUBSTITUTION(min_atom_index_, a.index());
|
||||
} else {
|
||||
min_atom_index_= a.index();
|
||||
}
|
||||
if (has_bonds()){
|
||||
set_has_bonds(false);
|
||||
set_has_bonds(true);
|
||||
}
|
||||
//atoms_.push_back(a);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Residue::Type Residue::type() const {
|
||||
return label_;
|
||||
}
|
||||
|
||||
void Residue::dump(std::ostream &out) const {
|
||||
out << "Type: " << type_string(type()) << std::endl;
|
||||
const std::vector<Residue::Atom_label> &valid_atoms= Residue_data::amino_acid_data_[type()].atoms;
|
||||
for (unsigned int i=0; i< valid_atoms.size(); ++i){
|
||||
Residue::Atom_label al= valid_atoms[i];
|
||||
out << Residue::atom_label_string(al); //Residue::write_atom_label(al, out);
|
||||
if (has_atom(al)){
|
||||
out << " (" << atom(al).cartesian_coords().x() << ", "
|
||||
<< atom(al).cartesian_coords().y() << ", "
|
||||
<< atom(al).cartesian_coords().z() << ") "
|
||||
<< atom(al).index() << std::endl;
|
||||
} else {
|
||||
out << " X" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct Compare_index{
|
||||
bool operator()(const std::pair<Residue::Atom_label, Atom> &a,
|
||||
const std::pair<Residue::Atom_label, Atom>&b) const {
|
||||
return a.second.index() < b.second.index();
|
||||
}
|
||||
};
|
||||
|
||||
void Residue::write(char chain, char insertion_residue_code, std::ostream &out) const {
|
||||
char line[81];
|
||||
std::vector<std::pair<Atom_label, Atom> > atoms(atoms_.begin(), atoms_.end());
|
||||
std::sort(atoms.begin(), atoms.end(), Compare_index());
|
||||
|
||||
for (unsigned int i=0; i< atoms.size(); ++i) {
|
||||
Atom_label al= atoms[i].first;
|
||||
//Point pt= res->cartesian_coords(al);
|
||||
const Atom &a= atoms[i].second;
|
||||
Point pt = a.cartesian_coords();
|
||||
char alt=' ';
|
||||
//char chain=' ';
|
||||
sprintf(line, CGAL_PDB_INTERNAL_NS::atom_line_oformat_,
|
||||
a.index().to_index(), Residue::atom_label_string(al).c_str(), alt,
|
||||
Residue::type_string(type()).c_str(), chain,index().to_index(), insertion_residue_code,
|
||||
pt.x(), pt.y(), pt.z(), a.occupancy(), a.temperature_factor(), a.segment_id(),
|
||||
a.element(), a.charge());
|
||||
out << line << std::endl;
|
||||
//++anum;
|
||||
}
|
||||
}
|
||||
|
||||
Atom::Index Residue::last_atom_index() const {
|
||||
Atom::Index max= atoms_.begin()->second.index();
|
||||
for ( Const_atoms_iterator it= atoms_.begin(); it != atoms_.end();
|
||||
++it) {
|
||||
max= (std::max)(max, it->second.index());
|
||||
}
|
||||
|
||||
return max;
|
||||
}
|
||||
|
||||
unsigned int Residue::number_of_atoms() const {
|
||||
return atoms_.size();
|
||||
}
|
||||
|
||||
unsigned int Residue::number_of_bonds() const {
|
||||
bonds_begin();
|
||||
return bonds_.size();
|
||||
}
|
||||
|
||||
void Residue::set_index(Residue::Index i) {
|
||||
index_=i;
|
||||
}
|
||||
|
||||
|
||||
Residue::Atom_label Residue::atom_label(Atom::Index model_index) const{
|
||||
Const_atoms_iterator it= atoms_iterator_from_index(model_index);
|
||||
if (it != atoms_end()) {
|
||||
return it->first;
|
||||
} else {
|
||||
return AL_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// protected
|
||||
Atom::Index Residue::index(Residue::Atom_label al) const {
|
||||
return atom(al).index();
|
||||
}
|
||||
|
||||
Residue::Atoms_iterator Residue::atoms_iterator_from_index(Atom::Index ind) {
|
||||
for (Atoms_iterator it= atoms_begin(); it != atoms_end(); ++it){
|
||||
if (it->second.index()==ind) return it;
|
||||
}
|
||||
CGAL_PDB_INTERNAL_NS::error_logger.new_warning("Invalid atom index used to request atom from residue.");
|
||||
|
||||
return atoms_end();
|
||||
}
|
||||
Residue::Const_atoms_iterator Residue::atoms_iterator_from_index(Atom::Index ind) const {
|
||||
for (Const_atoms_iterator it= atoms_begin(); it != atoms_end(); ++it){
|
||||
if (it->second.index()==ind) return it;
|
||||
}
|
||||
CGAL_PDB_INTERNAL_NS::error_logger.new_warning("Invalid atom index used to request atom from residue.");
|
||||
|
||||
return atoms_end();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Residue::Residue(Type al): atoms_(20), label_(al){
|
||||
Residue_data::initialize();
|
||||
assert(al!= INV);
|
||||
}
|
||||
|
||||
|
||||
Point Residue::sidechain_point() const {
|
||||
double x=0;
|
||||
double y=0;
|
||||
double z=0;
|
||||
int count=std::distance(Residue_data::amino_acid_data_[type()].extremes.begin(),
|
||||
Residue_data::amino_acid_data_[type()].extremes.end());
|
||||
for (std::vector<Atom_label>::const_iterator it = Residue_data::amino_acid_data_[type()].extremes.begin();
|
||||
it != Residue_data::amino_acid_data_[type()].extremes.end(); ++it){
|
||||
x+= atom(*it).cartesian_coords().x();
|
||||
y+= atom(*it).cartesian_coords().y();
|
||||
z+= atom(*it).cartesian_coords().z();
|
||||
}
|
||||
if (count == 0) {
|
||||
return atom(AL_CA).cartesian_coords();
|
||||
} else {
|
||||
return Point(x/count, y/count, z/count);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*Residue::Simplified_atoms_iterator Residue::simplified_atoms_begin() const {
|
||||
return Residue_data::amino_acid_data_[type()].extremes.begin();
|
||||
}
|
||||
|
||||
Residue::Simplified_atoms_iterator Residue::simplified_atoms_end() const{
|
||||
return Residue_data::amino_acid_data_[type()].extremes.end();
|
||||
}*/
|
||||
|
||||
|
||||
Residue::Atom_label Residue::atom_label(const char *nm) {
|
||||
Residue_data::initialize();
|
||||
char nn[5];
|
||||
sscanf(nm, "%4s", nn);
|
||||
std::string s(nn);
|
||||
for (unsigned int i=0; Residue_data::clean_atom_name_data_[i].l != AL_INVALID; ++i){
|
||||
if (s==Residue_data::clean_atom_name_data_[i].s){
|
||||
return Residue_data::clean_atom_name_data_[i].l;
|
||||
}
|
||||
}
|
||||
CGAL_PDB_INTERNAL_NS::error_logger.new_warning(std::string(s + " is not a known atom type.").c_str());;
|
||||
return Residue::AL_OTHER;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Atom::Type Residue::element(Atom_label al){
|
||||
Residue_data::initialize();
|
||||
for (unsigned int i=0; Residue_data::atom_name_data_[i].l != Residue::AL_INVALID; ++i){
|
||||
if (al==Residue_data::atom_name_data_[i].l){
|
||||
return Residue_data::atom_name_data_[i].t;
|
||||
}
|
||||
}
|
||||
CGAL_PDB_INTERNAL_NS::error_logger.new_internal_error("Unknown element label ");
|
||||
return Atom::INVALID;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
std::string Residue::atom_label_string(Atom_label al) {
|
||||
Residue_data::initialize();
|
||||
for (unsigned int i=0; Residue_data::atom_name_data_[i].l != Residue::AL_INVALID; ++i){
|
||||
if (al==Residue_data::atom_name_data_[i].l){
|
||||
return Residue_data::atom_name_data_[i].s;
|
||||
}
|
||||
}
|
||||
|
||||
std::ostringstream oss;
|
||||
oss << "Unknown atom label: " << al << " returning UNKN";
|
||||
CGAL_PDB_INTERNAL_NS::error_logger.new_warning(oss.str().c_str());
|
||||
|
||||
return "UNKN";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Residue::Type Residue::type(const std::string &s){
|
||||
/*switch(s[0]) {
|
||||
case 'A':
|
||||
switch(s[1]) {
|
||||
case 'C':
|
||||
return ACE;
|
||||
case 'L':
|
||||
return
|
||||
default:
|
||||
return INV;
|
||||
};
|
||||
default:
|
||||
return INV;
|
||||
}*/
|
||||
if (s =="ACE") return ACE;
|
||||
if (s =="ALA") return ALA;
|
||||
if (s =="ARG") return ARG;
|
||||
if (s =="ASN") return ASN;
|
||||
if (s =="ASP") return ASP;
|
||||
if (s =="CYS") return CYS;
|
||||
if (s =="GLN") return GLN;
|
||||
if (s =="GLU") return GLU;
|
||||
if (s =="HIS") return HIS;
|
||||
if (s =="ILE") return ILE;
|
||||
if (s =="LEU") return LEU;
|
||||
if (s =="LYS") return LYS;
|
||||
if (s =="MET") return MET;
|
||||
if (s =="NH2") return NH2;
|
||||
if (s =="PHE") return PHE;
|
||||
if (s =="PRO") return PRO;
|
||||
if (s =="SER") return SER;
|
||||
if (s =="THR") return THR;
|
||||
if (s =="TRP") return TRP;
|
||||
if (s =="TYR") return TYR;
|
||||
if (s =="VAL") return VAL;
|
||||
if (s =="GLY") return GLY;
|
||||
else return INV;
|
||||
}
|
||||
|
||||
std::string Residue::type_string(Residue::Type rl){
|
||||
switch (rl) {
|
||||
case GLY: return std::string("GLY");
|
||||
case ALA: return std::string("ALA");
|
||||
case VAL: return std::string("VAL");
|
||||
case LEU: return std::string("LEU");
|
||||
case ILE: return std::string("ILE");
|
||||
case SER: return std::string("SER");
|
||||
case THR: return std::string("THR");
|
||||
case CYS: return std::string("CYS");
|
||||
case MET: return std::string("MET");
|
||||
case PRO: return std::string("PRO");
|
||||
case ASP: return std::string("ASP");
|
||||
case ASN: return std::string("ASN");
|
||||
case GLU: return std::string("GLU");
|
||||
case GLN: return std::string("GLN");
|
||||
case LYS: return std::string("LYS");
|
||||
case ARG: return std::string("ARG");
|
||||
case HIS: return std::string("HIS");
|
||||
case PHE: return std::string("PHE");
|
||||
case TYR: return std::string("TYR");
|
||||
case TRP: return std::string("TRP");
|
||||
case ACE: return std::string("ACE");
|
||||
case NH2: return std::string("NH2");
|
||||
default: return std::string("UNK");
|
||||
}
|
||||
|
||||
}
|
||||
CGAL_PDB_END_NAMESPACE
|
||||
|
|
@ -1,696 +0,0 @@
|
|||
/* Copyright 2004
|
||||
Stanford University
|
||||
|
||||
This file is part of the DSR PDB Library.
|
||||
|
||||
The DSR PDB Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The DSR PDB Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the DSR PDB Library; see the file LICENSE.LGPL. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include <CGAL/PDB/Residue.h>
|
||||
#include <CGAL/PDB/internal/Residue_data.h>
|
||||
#include <cassert>
|
||||
CGAL_PDB_BEGIN_NAMESPACE
|
||||
|
||||
namespace Residue_data {
|
||||
bool amino_acid_initialized_=false;
|
||||
typedef std::vector<std::vector<Residue::Atom_label> > Clean_atom_fallbacks;
|
||||
std::vector<Amino_acid_data > amino_acid_data_;
|
||||
|
||||
|
||||
|
||||
|
||||
//! The per atom data associating string names with labels and atom types
|
||||
/*! To add a new atom or a different string refering to the same
|
||||
atom add a line to this array.
|
||||
*/
|
||||
Atom_data atom_name_data_[]= {
|
||||
{" N ",Residue::AL_N, Atom::N},
|
||||
{" H ",Residue::AL_H, Atom::H},
|
||||
{"1H ",Residue::AL_1H, Atom::H},{" H1 ",Residue::AL_1H, Atom::H},
|
||||
{"2H ",Residue::AL_2H, Atom::H},{" H2 ",Residue::AL_2H, Atom::H},
|
||||
{"3H ",Residue::AL_3H, Atom::H},{" H3 ",Residue::AL_3H, Atom::H},
|
||||
{" C ",Residue::AL_C, Atom::C},
|
||||
{" O ",Residue::AL_O, Atom::O},
|
||||
{" OXT",Residue::AL_OXT, Atom::O},
|
||||
{" CH3",Residue::AL_CH3, Atom::C},
|
||||
|
||||
{" CA ",Residue::AL_CA, Atom::C},
|
||||
{" HA ",Residue::AL_HA, Atom::H},
|
||||
{"1HA ",Residue::AL_1HA, Atom::H},{" HA1",Residue::AL_1HA, Atom::H},
|
||||
{"2HA ",Residue::AL_2HA, Atom::H},{" HA2",Residue::AL_2HA, Atom::H},
|
||||
|
||||
{" CB ",Residue::AL_CB, Atom::C},
|
||||
{" HB ",Residue::AL_HB, Atom::H},
|
||||
{"1HB ",Residue::AL_1HB, Atom::H}, {" HB1",Residue::AL_1HB, Atom::H},
|
||||
{"2HB ", Residue::AL_2HB, Atom::H}, {" HB2", Residue::AL_2HB, Atom::H},
|
||||
{"3HB ", Residue::AL_3HB, Atom::H}, {" HB3", Residue::AL_3HB, Atom::H},
|
||||
|
||||
{" CG ",Residue::AL_CG, Atom::C},
|
||||
{" CG1",Residue::AL_CG1, Atom::C},
|
||||
{" CG2",Residue::AL_CG2, Atom::C},
|
||||
{" HG ",Residue::AL_HG, Atom::H},
|
||||
{"1HG ", Residue::AL_1HG, Atom::H}, {" HG1", Residue::AL_1HG, Atom::H},
|
||||
{"2HG ", Residue::AL_2HG, Atom::H}, {" HG2", Residue::AL_2HG, Atom::H},
|
||||
//{"HG1",Residue::AL_HG1},
|
||||
{"1HG1",Residue::AL_1HG1, Atom::H},{"HG11",Residue::AL_1HG1, Atom::H},
|
||||
{"2HG1",Residue::AL_2HG1, Atom::H},{"HG12",Residue::AL_2HG1, Atom::H},
|
||||
{"3HG1",Residue::AL_3HG1, Atom::H},{"HG13",Residue::AL_3HG1, Atom::H},
|
||||
{"1HG2",Residue::AL_1HG2, Atom::H},{"HG21",Residue::AL_1HG2, Atom::H},
|
||||
{"2HG2",Residue::AL_2HG2, Atom::H},{"HG22",Residue::AL_2HG2, Atom::H},
|
||||
{"3HG2",Residue::AL_3HG2, Atom::H},{"HG23",Residue::AL_3HG2, Atom::H},
|
||||
{" OG ",Residue::AL_OG, Atom::O},
|
||||
{" OG1",Residue::AL_OG1, Atom::O},
|
||||
{" SG ",Residue::AL_SG, Atom::S},
|
||||
|
||||
{" CD ",Residue::AL_CD, Atom::C},
|
||||
{" CD1",Residue::AL_CD1, Atom::C},
|
||||
{" CD2",Residue::AL_CD2, Atom::C},
|
||||
//{"HD1",Residue::AL_HD1},
|
||||
//{"HD2",Residue::AL_HD2},
|
||||
{" HD ",Residue::AL_HD, Atom::H},
|
||||
{"1HD ",Residue::AL_1HD, Atom::H},{" HD1",Residue::AL_1HD, Atom::H},
|
||||
{"2HD ",Residue::AL_2HD, Atom::H},{" HD2",Residue::AL_2HD, Atom::H},
|
||||
{"3HD ",Residue::AL_3HD, Atom::H},{" HD3",Residue::AL_3HD, Atom::H},
|
||||
{"1HD1",Residue::AL_1HD1, Atom::H}, {"HD11",Residue::AL_1HD1, Atom::H},
|
||||
{"2HD1",Residue::AL_2HD1, Atom::H},{"HD12",Residue::AL_2HD1, Atom::H},
|
||||
{"3HD1",Residue::AL_3HD1, Atom::H},{"HD13",Residue::AL_3HD1, Atom::H},
|
||||
{"1HD2",Residue::AL_1HD2, Atom::H},{"HD21",Residue::AL_1HD2, Atom::H},
|
||||
{"2HD2",Residue::AL_2HD2, Atom::H},{"HD22",Residue::AL_2HD2, Atom::H},
|
||||
{"3HD2",Residue::AL_3HD2, Atom::H},{"HD23",Residue::AL_3HD2, Atom::H},
|
||||
{" SD ",Residue::AL_SD, Atom::S},
|
||||
{" OD1",Residue::AL_OD1, Atom::O},
|
||||
{" OD2",Residue::AL_OD2, Atom::O},
|
||||
{" ND1",Residue::AL_ND1, Atom::N},
|
||||
{" ND2",Residue::AL_ND2, Atom::N},
|
||||
|
||||
{" CE ",Residue::AL_CE, Atom::C},
|
||||
{" CE1",Residue::AL_CE1, Atom::C},
|
||||
{" CE2",Residue::AL_CE2, Atom::C},
|
||||
{" CE3",Residue::AL_CE3, Atom::C},
|
||||
{" HE ",Residue::AL_HE, Atom::H},
|
||||
{"1HE ",Residue::AL_1HE, Atom::H},{" HE1",Residue::AL_1HE, Atom::H},
|
||||
{"2HE ",Residue::AL_2HE, Atom::H},{" HE2",Residue::AL_2HE, Atom::H},
|
||||
{"3HE ",Residue::AL_3HE, Atom::H},{" HE3",Residue::AL_3HE, Atom::H},
|
||||
//{"HE1",Residue::AL_HE1},
|
||||
//{"HE2",Residue::AL_HE2},
|
||||
//{"HE3",Residue::AL_HE3},
|
||||
{"1HE2",Residue::AL_1HE2, Atom::H},{"HE21",Residue::AL_1HE2, Atom::H},
|
||||
{"2HE2",Residue::AL_2HE2, Atom::H},{"HE22",Residue::AL_2HE2, Atom::H},
|
||||
{" OE1",Residue::AL_OE1, Atom::O},
|
||||
{" OE2",Residue::AL_OE2, Atom::O},
|
||||
{" NE ",Residue::AL_NE, Atom::N},
|
||||
{" NE1",Residue::AL_NE1, Atom::N},
|
||||
{" NE2",Residue::AL_NE2, Atom::N},
|
||||
|
||||
{" CZ ",Residue::AL_CZ, Atom::C},
|
||||
{" CZ2",Residue::AL_CZ2, Atom::C},
|
||||
{" CZ3",Residue::AL_CZ3, Atom::C},
|
||||
{" NZ ",Residue::AL_NZ, Atom::N},
|
||||
{" HZ ",Residue::AL_HZ, Atom::H},
|
||||
{"1HZ ",Residue::AL_1HZ, Atom::H},{" HZ1",Residue::AL_1HZ, Atom::H},
|
||||
{"2HZ ",Residue::AL_2HZ, Atom::H},{" HZ2",Residue::AL_2HZ, Atom::H},
|
||||
{"3HZ ",Residue::AL_3HZ, Atom::H},{" HZ3",Residue::AL_3HZ, Atom::H},
|
||||
//{"HZ1",Residue::AL_HZ2},
|
||||
//{"HZ2",Residue::AL_HZ2},
|
||||
//{"HZ3",Residue::AL_HZ3},
|
||||
|
||||
{" CH2",Residue::AL_CH2, Atom::C},
|
||||
{" NH1",Residue::AL_NH1, Atom::N},
|
||||
{" NH2",Residue::AL_NH2, Atom::N},
|
||||
{" OH",Residue::AL_OH, Atom::O},
|
||||
{" HH",Residue::AL_HH, Atom::H},
|
||||
|
||||
{"1HH1", Residue::AL_1HH1, Atom::H}, {"HH11", Residue::AL_1HH1, Atom::H},
|
||||
{"2HH1", Residue::AL_2HH1, Atom::H}, {"HH12", Residue::AL_2HH1, Atom::H},
|
||||
{" HH2",Residue::AL_HH2, Atom::H},
|
||||
{"1HH2", Residue::AL_1HH2, Atom::H}, {"HH21", Residue::AL_1HH2, Atom::H},
|
||||
{"2HH2", Residue::AL_2HH2, Atom::H}, {"HH22", Residue::AL_2HH2, Atom::H},
|
||||
{" HH ", Residue::AL_1HH2, Atom::H},
|
||||
|
||||
{"HH31", Residue::AL_1HH3, Atom::H},
|
||||
{"HH32", Residue::AL_2HH3, Atom::H},
|
||||
{"HH33", Residue::AL_3HH3, Atom::H},
|
||||
{"UNKN", Residue::AL_INVALID, Atom::INVALID}};
|
||||
|
||||
|
||||
Atom_data clean_atom_name_data_[sizeof(atom_name_data_)
|
||||
/sizeof(Atom_data)+1];
|
||||
|
||||
Atom_fallback_data atom_fallback_data_[]=
|
||||
{{Residue::AL_CD1, Residue::AL_CD},
|
||||
{Residue::AL_1HA, Residue::AL_HA},
|
||||
{Residue::AL_1HB, Residue::AL_HB},
|
||||
{Residue::AL_1HD, Residue::AL_HD},
|
||||
{Residue::AL_1HE, Residue::AL_HE},
|
||||
{Residue::AL_1HZ, Residue::AL_HZ},
|
||||
//{Residue::AL_1HH, Residue::AL_HH},
|
||||
{Residue::AL_1HD1, Residue::AL_1HD},
|
||||
{Residue::AL_2HD1, Residue::AL_2HD},
|
||||
{Residue::AL_3HD1, Residue::AL_3HD},
|
||||
{Residue::AL_INVALID, Residue::AL_INVALID}};
|
||||
Clean_atom_fallbacks clean_atom_fallbacks_;
|
||||
|
||||
#define BEGIN_RES(name) case name:{
|
||||
#define BEGIN_ATOMS static Residue::Atom_label cl[]=
|
||||
#define END_ATOMS ; dat.atms_=cl;
|
||||
#define BEGIN_BONDS static Residue::Atom_label cbl[]=
|
||||
#define END_BONDS ; for (int i=0; cbl[i] != Residue::AL_INVALID; ++i) { bool found=false; for (int j=0; cl[j] != Residue::AL_INVALID; ++j) if (cl[j]==cbl[i]) found=true; assert(found || cbl[i]== Residue::AL_CA || cbl[i]== Residue::AL_N);}; dat.bnds_=cbl;
|
||||
#define BEGIN_EXTREMES static Residue::Atom_label ext[]=
|
||||
#define END_EXTREMES ; for (int i=0; ext[i] != Residue::AL_INVALID; ++i) { bool found=false; for (int j=0; cl[j] != Residue::AL_INVALID; ++j) if (cl[j]==ext[i]) found=true; assert(found);} dat.extr_=ext;
|
||||
|
||||
/*#define DEFINE_ATOMS(...) static Residue::Atom_label cl[]={__VA_ARGS__}; dat.atms_=cl;
|
||||
#define DEFINE_BONDS(...) static Residue::Atom_label cbl[]={__VA_ARGS__}; for (int i=0; cbl[i] != Residue::AL_INVALID; ++i) { bool found=false; for (int j=0; cl[j] != Residue::AL_INVALID; ++j) if (cl[j]==cbl[i]) found=true; assert(found || cbl[i]== Residue::AL_CA || cbl[i]== Residue::AL_N);}; dat.bnds_=cbl;
|
||||
#define DEFINE_EXTREMES(...) static Residue::Atom_label ext[]={__VA_ARGS__}; for (int i=0; ext[i] != Residue::AL_INVALID; ++i) { bool found=false; for (int j=0; cl[j] != Residue::AL_INVALID; ++j) if (cl[j]==ext[i]) found=true; assert(found);} dat.extr_=ext; */
|
||||
#define END_RES break;}
|
||||
|
||||
|
||||
//! This function returns the per-residue atom and bond information.
|
||||
/*!
|
||||
To add an atom or bond to a residue add them to the appropriate list below.
|
||||
*/
|
||||
Residue_init_data
|
||||
get_residue_initialization_data(Residue::Type rl){
|
||||
static Residue::Atom_label end=Residue::AL_INVALID;
|
||||
Residue_init_data dat;
|
||||
dat.atms_=&end;
|
||||
dat.bnds_=&end;
|
||||
dat.extr_=&end;
|
||||
switch(rl){
|
||||
|
||||
BEGIN_RES(Residue::VAL);
|
||||
BEGIN_ATOMS{Residue::AL_CB, Residue::AL_HB, Residue::AL_CG1, Residue::AL_CG2,
|
||||
Residue::AL_1HG1, Residue::AL_2HG1, Residue::AL_3HG1, Residue::AL_1HG2,
|
||||
Residue::AL_2HG2, Residue::AL_3HG2, Residue::AL_INVALID }END_ATOMS;
|
||||
BEGIN_BONDS{Residue::AL_CB, Residue::AL_CA,
|
||||
Residue::AL_HB, Residue::AL_CB,
|
||||
Residue::AL_CG1, Residue::AL_CB,
|
||||
Residue::AL_CG2, Residue::AL_CB,
|
||||
Residue::AL_1HG1, Residue::AL_CG1,
|
||||
Residue::AL_2HG1, Residue::AL_CG1,
|
||||
Residue::AL_3HG1, Residue::AL_CG1,
|
||||
Residue::AL_1HG2, Residue::AL_CG2,
|
||||
Residue::AL_2HG2, Residue::AL_CG2,
|
||||
Residue::AL_3HG2, Residue::AL_CG2,
|
||||
Residue::AL_INVALID}END_BONDS;
|
||||
BEGIN_EXTREMES{Residue::AL_CG1, Residue::AL_CG2, Residue::AL_INVALID}END_EXTREMES;
|
||||
END_RES;
|
||||
|
||||
BEGIN_RES(Residue::TYR);// was HD1, HD2, HE1, HE2
|
||||
BEGIN_ATOMS{ Residue::AL_CB, Residue::AL_1HB, Residue::AL_2HB, Residue::AL_CG, Residue::AL_CD1, Residue::AL_CD2, Residue::AL_1HD, Residue::AL_2HD, Residue::AL_CE1,
|
||||
Residue::AL_CE2, Residue::AL_1HE, Residue::AL_2HE, Residue::AL_CZ, Residue::AL_OH, Residue::AL_HH, Residue::AL_INVALID } END_ATOMS;
|
||||
BEGIN_BONDS{Residue::AL_CB, Residue::AL_CA,
|
||||
Residue::AL_1HB, Residue::AL_CB,
|
||||
Residue::AL_2HB, Residue::AL_CB,
|
||||
Residue::AL_CG, Residue::AL_CB,
|
||||
Residue::AL_CD1, Residue::AL_CG,
|
||||
Residue::AL_CD2, Residue::AL_CG,
|
||||
// was HD1, HD2
|
||||
Residue::AL_1HD, Residue::AL_CD1,
|
||||
Residue::AL_2HD, Residue::AL_CD2,
|
||||
Residue::AL_CE1, Residue::AL_CD1,
|
||||
Residue::AL_CE2, Residue::AL_CD2,
|
||||
// HE1,2
|
||||
Residue::AL_1HE, Residue::AL_CE1,
|
||||
Residue::AL_2HE, Residue::AL_CE2,
|
||||
Residue::AL_CZ, Residue::AL_CE1,
|
||||
Residue::AL_CZ, Residue::AL_CE2,
|
||||
Residue::AL_OH, Residue::AL_CZ,
|
||||
Residue::AL_HH, Residue::AL_OH,
|
||||
Residue::AL_INVALID}END_BONDS;
|
||||
BEGIN_EXTREMES{Residue::AL_CZ, Residue::AL_INVALID}END_EXTREMES; // or Residue::AL_OH
|
||||
END_RES;
|
||||
|
||||
BEGIN_RES(Residue::TRP);
|
||||
// was HD1, HE1, HE3, HZ2, HZ3
|
||||
BEGIN_ATOMS{ Residue::AL_CB, Residue::AL_1HB, Residue::AL_2HB, Residue::AL_CG, Residue::AL_CD1, Residue::AL_CD2, Residue::AL_HD, Residue::AL_NE1, Residue::AL_CE2,
|
||||
Residue::AL_CE3, Residue::AL_1HE, Residue::AL_3HE, Residue::AL_CZ2, Residue::AL_CZ3, Residue::AL_2HZ, Residue::AL_3HZ, Residue::AL_CH2,
|
||||
Residue::AL_HH2,Residue::AL_INVALID}END_ATOMS;
|
||||
BEGIN_BONDS{Residue::AL_CB, Residue::AL_CA,
|
||||
Residue::AL_1HB, Residue::AL_CB,
|
||||
Residue::AL_2HB, Residue::AL_CB,
|
||||
Residue::AL_CG, Residue::AL_CB,
|
||||
Residue::AL_CD1, Residue::AL_CG,
|
||||
Residue::AL_CD2, Residue::AL_CG,
|
||||
// was 1HD
|
||||
Residue::AL_HD, Residue::AL_CD1,
|
||||
Residue::AL_NE1, Residue::AL_CD1,
|
||||
Residue::AL_CE2, Residue::AL_CG,
|
||||
Residue::AL_CD2, Residue::AL_CE2,
|
||||
Residue::AL_CE3, Residue::AL_CD2,
|
||||
// was HE1,3
|
||||
Residue::AL_1HE, Residue::AL_NE1,
|
||||
Residue::AL_3HE, Residue::AL_CE3,
|
||||
Residue::AL_CZ2, Residue::AL_CE2,
|
||||
Residue::AL_CZ3, Residue::AL_CE3,
|
||||
Residue::AL_2HZ, Residue::AL_CZ2,
|
||||
Residue::AL_3HZ, Residue::AL_CZ3,
|
||||
Residue::AL_CH2, Residue::AL_CZ2,
|
||||
Residue::AL_CH2, Residue::AL_CZ3,
|
||||
Residue::AL_HH2, Residue::AL_CH2,
|
||||
Residue::AL_INVALID}END_BONDS;
|
||||
BEGIN_EXTREMES{Residue::AL_CH2, Residue::AL_INVALID}END_EXTREMES;
|
||||
END_RES;
|
||||
|
||||
|
||||
BEGIN_RES(Residue::THR);
|
||||
// was HG1
|
||||
BEGIN_ATOMS{Residue::AL_CB, Residue::AL_HB, Residue::AL_CG2, Residue::AL_OG1, Residue::AL_1HG2, Residue::AL_2HG2, Residue::AL_3HG2,
|
||||
Residue::AL_1HG,Residue::AL_INVALID}END_ATOMS;
|
||||
BEGIN_BONDS{Residue::AL_CB, Residue::AL_CA,
|
||||
Residue::AL_HB, Residue::AL_CB,
|
||||
Residue::AL_CG2, Residue::AL_CB,
|
||||
Residue::AL_OG1, Residue::AL_CB,
|
||||
Residue::AL_1HG2, Residue::AL_CG2,
|
||||
Residue::AL_2HG2, Residue::AL_CG2,
|
||||
Residue::AL_3HG2, Residue::AL_CG2,
|
||||
// was HG1
|
||||
Residue::AL_1HG, Residue::AL_OG1,
|
||||
Residue::AL_INVALID}END_BONDS;
|
||||
BEGIN_EXTREMES{Residue::AL_CG2, Residue::AL_OG1, Residue::AL_INVALID}END_EXTREMES;
|
||||
END_RES;
|
||||
|
||||
BEGIN_RES(Residue::SER);
|
||||
BEGIN_ATOMS{ Residue::AL_CB, Residue::AL_1HB, Residue::AL_2HB, Residue::AL_OG, Residue::AL_HG,Residue::AL_INVALID}END_ATOMS;
|
||||
BEGIN_BONDS{Residue::AL_CB, Residue::AL_CA,
|
||||
Residue::AL_1HB, Residue::AL_CB,
|
||||
Residue::AL_2HB, Residue::AL_CB,
|
||||
Residue::AL_OG, Residue::AL_CB,
|
||||
Residue::AL_HG, Residue::AL_OG,
|
||||
Residue::AL_INVALID}END_BONDS;
|
||||
BEGIN_EXTREMES{Residue::AL_OG, Residue::AL_INVALID}END_EXTREMES;
|
||||
END_RES;
|
||||
|
||||
BEGIN_RES(Residue::PRO);
|
||||
BEGIN_ATOMS{ Residue::AL_CB, Residue::AL_1HB, Residue::AL_2HB, Residue::AL_CG, Residue::AL_1HG, Residue::AL_2HG, Residue::AL_CD, Residue::AL_1HD, Residue::AL_2HD,Residue::AL_INVALID}END_ATOMS;
|
||||
BEGIN_BONDS{Residue::AL_CB, Residue::AL_CA,
|
||||
Residue::AL_1HB, Residue::AL_CB,
|
||||
Residue::AL_2HB, Residue::AL_CB,
|
||||
Residue::AL_CG, Residue::AL_CB,
|
||||
Residue::AL_1HG, Residue::AL_CG,
|
||||
Residue::AL_2HG, Residue::AL_CG,
|
||||
Residue::AL_CD, Residue::AL_CG,
|
||||
Residue::AL_1HD, Residue::AL_CD,
|
||||
Residue::AL_2HD, Residue::AL_CD,
|
||||
Residue::AL_CD, Residue::AL_N,
|
||||
Residue::AL_INVALID}END_BONDS;
|
||||
BEGIN_EXTREMES{Residue::AL_CG, Residue::AL_INVALID}END_EXTREMES; // maybe Residue::AL_CG
|
||||
END_RES;
|
||||
|
||||
BEGIN_RES(Residue::PHE);
|
||||
// was HD1, HD2, HE1,2
|
||||
BEGIN_ATOMS{ Residue::AL_CB, Residue::AL_1HB, Residue::AL_2HB, Residue::AL_CG, Residue::AL_CD1, Residue::AL_CD2, Residue::AL_1HD, Residue::AL_2HD, Residue::AL_CE1,
|
||||
Residue::AL_CE2, Residue::AL_1HE, Residue::AL_2HE, Residue::AL_CZ, Residue::AL_HZ,Residue::AL_INVALID}END_ATOMS;
|
||||
BEGIN_BONDS{Residue::AL_CB, Residue::AL_CA,
|
||||
Residue::AL_1HB, Residue::AL_CB,
|
||||
Residue::AL_2HB, Residue::AL_CB,
|
||||
Residue::AL_CG, Residue::AL_CB,
|
||||
Residue::AL_CD1, Residue::AL_CG,
|
||||
Residue::AL_CD2, Residue::AL_CG,
|
||||
// was HD1, HD2
|
||||
Residue::AL_1HD, Residue::AL_CD1,
|
||||
Residue::AL_2HD, Residue::AL_CD2,
|
||||
Residue::AL_CE1, Residue::AL_CD1,
|
||||
Residue::AL_CE2, Residue::AL_CD2,
|
||||
// HE1,2
|
||||
Residue::AL_1HE, Residue::AL_CE1,
|
||||
Residue::AL_2HE, Residue::AL_CE2,
|
||||
Residue::AL_CZ, Residue::AL_CE1,
|
||||
Residue::AL_CZ, Residue::AL_CE2, Residue::AL_HZ,
|
||||
Residue::AL_CZ,Residue::AL_INVALID}END_BONDS;
|
||||
BEGIN_EXTREMES{Residue::AL_CZ, Residue::AL_INVALID}END_EXTREMES; //
|
||||
END_RES;
|
||||
|
||||
BEGIN_RES(Residue::NH2);
|
||||
BEGIN_ATOMS{Residue::AL_N, Residue::AL_1H, Residue::AL_2H,Residue::AL_INVALID}END_ATOMS;
|
||||
BEGIN_BONDS{ Residue::AL_1H, Residue::AL_N,
|
||||
Residue::AL_2H, Residue::AL_N,
|
||||
Residue::AL_INVALID}END_BONDS;
|
||||
END_RES;
|
||||
|
||||
BEGIN_RES(Residue::MET);
|
||||
BEGIN_ATOMS{Residue::AL_CB, Residue::AL_1HB, Residue::AL_2HB, Residue::AL_CG, Residue::AL_1HG, Residue::AL_2HG,
|
||||
Residue::AL_SD, Residue::AL_CE, Residue::AL_1HE,
|
||||
Residue::AL_2HE, Residue::AL_3HE,Residue::AL_INVALID} END_ATOMS;
|
||||
BEGIN_BONDS{Residue::AL_CB, Residue::AL_CA,
|
||||
Residue::AL_1HB, Residue::AL_CB,
|
||||
Residue::AL_2HB, Residue::AL_CB,
|
||||
Residue::AL_CG, Residue::AL_CB,
|
||||
Residue::AL_1HG, Residue::AL_CG,
|
||||
Residue::AL_2HG, Residue::AL_CG,
|
||||
Residue::AL_SD, Residue::AL_CG,
|
||||
Residue::AL_CE, Residue::AL_SD,
|
||||
Residue::AL_1HE, Residue::AL_CE,
|
||||
Residue::AL_2HE, Residue::AL_CE,
|
||||
Residue::AL_3HE, Residue::AL_CE,
|
||||
Residue::AL_INVALID}END_BONDS;
|
||||
BEGIN_EXTREMES{Residue::AL_CE, Residue::AL_INVALID}END_EXTREMES;
|
||||
END_RES;
|
||||
|
||||
BEGIN_RES(Residue::LYS);
|
||||
BEGIN_ATOMS{Residue::AL_CB, Residue::AL_1HB, Residue::AL_2HB, Residue::AL_CG, Residue::AL_1HG, Residue::AL_2HG, Residue::AL_CD, Residue::AL_1HD, Residue::AL_2HD,
|
||||
Residue::AL_CE, Residue::AL_1HE, Residue::AL_2HE, Residue::AL_NZ, Residue::AL_1HZ, Residue::AL_2HZ, Residue::AL_3HZ,Residue::AL_INVALID} END_ATOMS;
|
||||
BEGIN_BONDS{Residue::AL_CB, Residue::AL_CA,
|
||||
Residue::AL_1HB, Residue::AL_CB,
|
||||
Residue::AL_2HB, Residue::AL_CB,
|
||||
Residue::AL_CG, Residue::AL_CB,
|
||||
Residue::AL_1HG, Residue::AL_CG,
|
||||
Residue::AL_2HG, Residue::AL_CG,
|
||||
Residue::AL_CD, Residue::AL_CG,
|
||||
Residue::AL_1HD,Residue::AL_CD,
|
||||
Residue::AL_2HD, Residue::AL_CD,
|
||||
Residue::AL_CE, Residue::AL_CD,
|
||||
Residue::AL_1HE, Residue::AL_CE,
|
||||
Residue::AL_2HE, Residue::AL_CE,
|
||||
Residue::AL_NZ, Residue::AL_CE,
|
||||
Residue::AL_1HZ, Residue::AL_NZ,
|
||||
Residue::AL_2HZ, Residue::AL_NZ,
|
||||
Residue::AL_3HZ, Residue::AL_NZ,
|
||||
Residue::AL_INVALID}END_BONDS;
|
||||
BEGIN_EXTREMES{Residue::AL_NZ, Residue::AL_INVALID}END_EXTREMES;
|
||||
END_RES;
|
||||
|
||||
BEGIN_RES(Residue::LEU);
|
||||
BEGIN_ATOMS{ Residue::AL_CB, Residue::AL_1HB, Residue::AL_2HB, Residue::AL_CG, Residue::AL_HG, Residue::AL_CD1, Residue::AL_CD2, Residue::AL_1HD1, Residue::AL_2HD1,
|
||||
Residue::AL_3HD1, Residue::AL_1HD2, Residue::AL_2HD2, Residue::AL_3HD2,Residue::AL_INVALID} END_ATOMS;
|
||||
BEGIN_BONDS{ Residue::AL_CB, Residue::AL_CA,
|
||||
Residue::AL_1HB, Residue::AL_CB,
|
||||
Residue::AL_2HB, Residue::AL_CB,
|
||||
Residue::AL_CG, Residue::AL_CB,
|
||||
Residue::AL_HG, Residue::AL_CG,
|
||||
Residue::AL_CD1, Residue::AL_CG,
|
||||
Residue::AL_CD2, Residue::AL_CG,
|
||||
Residue::AL_1HD1, Residue::AL_CD1,
|
||||
Residue::AL_2HD1, Residue::AL_CD1,
|
||||
Residue::AL_3HD1, Residue::AL_CD1,
|
||||
Residue::AL_1HD2, Residue::AL_CD2,
|
||||
Residue::AL_2HD2, Residue::AL_CD2,
|
||||
Residue::AL_3HD2, Residue::AL_CD2,
|
||||
Residue::AL_INVALID}END_BONDS;
|
||||
BEGIN_EXTREMES{Residue::AL_CD1, Residue::AL_CD2, Residue::AL_INVALID}END_EXTREMES;
|
||||
END_RES;
|
||||
|
||||
BEGIN_RES(Residue::ILE);
|
||||
// was 1HD
|
||||
BEGIN_ATOMS{Residue::AL_CB, Residue::AL_HB, Residue::AL_CG1, Residue::AL_CG2, Residue::AL_1HG1, Residue::AL_2HG1, Residue::AL_CD, Residue::AL_1HD, Residue::AL_2HD,
|
||||
Residue::AL_3HD, Residue::AL_1HG2, Residue::AL_2HG2, Residue::AL_3HG2,Residue::AL_INVALID} END_ATOMS;
|
||||
BEGIN_BONDS{Residue::AL_CB, Residue::AL_CA,
|
||||
Residue::AL_HB, Residue::AL_CB,
|
||||
Residue::AL_CG1, Residue::AL_CB,
|
||||
Residue::AL_CG2, Residue::AL_CB,
|
||||
Residue::AL_1HG1, Residue::AL_CG1,
|
||||
Residue::AL_2HG1, Residue::AL_CG1,
|
||||
Residue::AL_CD, Residue::AL_CG1,
|
||||
Residue::AL_1HD, Residue::AL_CD,
|
||||
Residue::AL_2HD, Residue::AL_CD,
|
||||
Residue::AL_3HD, Residue::AL_CD,
|
||||
Residue::AL_1HG2, Residue::AL_CG2,
|
||||
Residue::AL_2HG2, Residue::AL_CG2,
|
||||
Residue::AL_3HG2, Residue::AL_CG2,
|
||||
Residue::AL_INVALID}END_BONDS;
|
||||
BEGIN_EXTREMES{Residue::AL_CD, Residue::AL_INVALID}END_EXTREMES; // maybe add CG2
|
||||
END_RES;
|
||||
|
||||
BEGIN_RES(Residue::HIS);
|
||||
// was HD1, HD2 HE1
|
||||
BEGIN_ATOMS{Residue::AL_CB, Residue::AL_1HB, Residue::AL_2HB, Residue::AL_CG, Residue::AL_ND1, Residue::AL_CD2, Residue::AL_1HD, Residue::AL_2HD, Residue::AL_CE1,
|
||||
Residue::AL_NE2, Residue::AL_1HE,Residue::AL_INVALID} END_ATOMS;
|
||||
BEGIN_BONDS{Residue::AL_CB, Residue::AL_CA,
|
||||
Residue::AL_1HB, Residue::AL_CB,
|
||||
Residue::AL_2HB, Residue::AL_CB,
|
||||
Residue::AL_CG, Residue::AL_CB,
|
||||
Residue::AL_ND1, Residue::AL_CG,
|
||||
Residue::AL_CD2, Residue::AL_CG,
|
||||
Residue::AL_1HD, Residue::AL_ND1,
|
||||
Residue::AL_2HD, Residue::AL_CD2,
|
||||
Residue::AL_CE1, Residue::AL_ND1,
|
||||
Residue::AL_CE1, Residue::AL_NE2,
|
||||
Residue::AL_1HE, Residue::AL_CE1,
|
||||
Residue::AL_NE2, Residue::AL_CD2,
|
||||
Residue::AL_INVALID} END_BONDS;
|
||||
BEGIN_EXTREMES{Residue::AL_CE1, Residue::AL_INVALID}END_EXTREMES;
|
||||
END_RES;
|
||||
|
||||
|
||||
BEGIN_RES(Residue::GLY);
|
||||
BEGIN_ATOMS{Residue::AL_2HA,Residue::AL_INVALID} END_ATOMS;
|
||||
BEGIN_BONDS{Residue::AL_2HA, Residue::AL_CA,Residue::AL_INVALID}END_BONDS;
|
||||
BEGIN_EXTREMES{Residue::AL_INVALID}END_EXTREMES;
|
||||
END_RES;
|
||||
|
||||
BEGIN_RES(Residue::GLU);
|
||||
BEGIN_ATOMS{Residue::AL_CB, Residue::AL_1HB, Residue::AL_2HB, Residue::AL_CG, Residue::AL_1HG, Residue::AL_2HG, Residue::AL_CD, Residue::AL_OE1, Residue::AL_OE2,Residue::AL_INVALID}END_ATOMS;
|
||||
BEGIN_BONDS{Residue::AL_CB, Residue::AL_CA,
|
||||
Residue::AL_1HB, Residue::AL_CB,
|
||||
Residue::AL_2HB, Residue::AL_CB,
|
||||
Residue::AL_CG, Residue::AL_CB,
|
||||
Residue::AL_1HG, Residue::AL_CG,
|
||||
Residue::AL_2HG, Residue::AL_CG,
|
||||
Residue::AL_CD, Residue::AL_CG,
|
||||
Residue::AL_OE1, Residue::AL_CD,
|
||||
Residue::AL_OE2, Residue::AL_CD,
|
||||
Residue::AL_INVALID} END_BONDS;
|
||||
BEGIN_EXTREMES{Residue::AL_CD, Residue::AL_INVALID}END_EXTREMES; // maybe should be Residue::AL_OE[12]
|
||||
END_RES;
|
||||
|
||||
BEGIN_RES(Residue::GLN);
|
||||
BEGIN_ATOMS{Residue::AL_CB, Residue::AL_1HB, Residue::AL_2HB, Residue::AL_CG, Residue::AL_1HG, Residue::AL_2HG, Residue::AL_CD, Residue::AL_OE1, Residue::AL_NE2,
|
||||
Residue::AL_1HE2, Residue::AL_2HE2,Residue::AL_INVALID}END_ATOMS;
|
||||
BEGIN_BONDS{Residue::AL_CB, Residue::AL_CA,
|
||||
Residue::AL_1HB, Residue::AL_CB,
|
||||
Residue::AL_2HB, Residue::AL_CB,
|
||||
Residue::AL_CG, Residue::AL_CB,
|
||||
Residue::AL_1HG, Residue::AL_CG,
|
||||
Residue::AL_2HG, Residue::AL_CG,
|
||||
Residue::AL_CD, Residue::AL_CG,
|
||||
Residue::AL_OE1, Residue::AL_CD,
|
||||
Residue::AL_NE2, Residue::AL_CD,
|
||||
Residue::AL_1HE2, Residue::AL_NE2,
|
||||
Residue::AL_2HE2, Residue::AL_NE2,
|
||||
Residue::AL_INVALID} END_BONDS;
|
||||
BEGIN_EXTREMES{Residue::AL_CD, Residue::AL_INVALID}END_EXTREMES; // or Residue::AL_NE2, Residue::AL_OE1
|
||||
END_RES;
|
||||
|
||||
BEGIN_RES(Residue::CYS);
|
||||
BEGIN_ATOMS{Residue::AL_CB, Residue::AL_1HB, Residue::AL_2HB, Residue::AL_SG, Residue::AL_HG,Residue::AL_INVALID}END_ATOMS;
|
||||
BEGIN_BONDS{Residue::AL_CB, Residue::AL_CA,
|
||||
Residue::AL_1HB, Residue::AL_CB,
|
||||
Residue::AL_2HB, Residue::AL_CB,
|
||||
Residue::AL_SG, Residue::AL_CB,
|
||||
Residue::AL_HG, Residue::AL_SG,
|
||||
Residue::AL_INVALID} END_BONDS;
|
||||
BEGIN_EXTREMES{Residue::AL_SG, Residue::AL_INVALID}END_EXTREMES;
|
||||
END_RES;
|
||||
|
||||
BEGIN_RES(Residue::ASP);
|
||||
BEGIN_ATOMS{Residue::AL_CB, Residue::AL_1HB, Residue::AL_2HB, Residue::AL_CG, Residue::AL_OD1, Residue::AL_OD2,Residue::AL_INVALID}END_ATOMS;
|
||||
BEGIN_BONDS{Residue::AL_CB, Residue::AL_CA,
|
||||
Residue::AL_1HB, Residue::AL_CB,
|
||||
Residue::AL_2HB, Residue::AL_CB,
|
||||
Residue::AL_CG, Residue::AL_CB,
|
||||
Residue::AL_OD1, Residue::AL_CG,
|
||||
Residue::AL_OD2, Residue::AL_CG,
|
||||
Residue::AL_INVALID} END_BONDS;
|
||||
BEGIN_EXTREMES{Residue::AL_CG, Residue::AL_INVALID}END_EXTREMES; // or Residue::AL_OD[12]
|
||||
END_RES;
|
||||
|
||||
BEGIN_RES(Residue::ASN);
|
||||
BEGIN_ATOMS{ Residue::AL_CB, Residue::AL_1HB, Residue::AL_2HB, Residue::AL_CG, Residue::AL_OD1, Residue::AL_ND2, Residue::AL_1HD2, Residue::AL_2HD2,Residue::AL_INVALID} END_ATOMS;
|
||||
BEGIN_BONDS{ Residue::AL_CB, Residue::AL_CA,
|
||||
Residue::AL_1HB, Residue::AL_CB,
|
||||
Residue::AL_2HB, Residue::AL_CB,
|
||||
Residue::AL_CG, Residue::AL_CB,
|
||||
Residue::AL_OD1, Residue::AL_CG,
|
||||
Residue::AL_ND2, Residue::AL_CG,
|
||||
Residue::AL_1HD2, Residue::AL_ND2,
|
||||
Residue::AL_2HD2, Residue::AL_ND2 ,
|
||||
Residue::AL_INVALID} END_BONDS;
|
||||
BEGIN_EXTREMES{Residue::AL_CG, Residue::AL_INVALID}END_EXTREMES; // or Residue::AL_OD1, Residue::AL_ND1
|
||||
END_RES;
|
||||
|
||||
BEGIN_RES(Residue::ARG);
|
||||
BEGIN_ATOMS{Residue::AL_CB, Residue::AL_1HB, Residue::AL_2HB, Residue::AL_CG, Residue::AL_1HG, Residue::AL_2HG, Residue::AL_CD, Residue::AL_1HD, Residue::AL_2HD,
|
||||
Residue::AL_NE, Residue::AL_HE, Residue::AL_CZ, Residue::AL_NH1, Residue::AL_NH2, Residue::AL_1HH1, Residue::AL_2HH1, Residue::AL_1HH2,
|
||||
Residue::AL_2HH2,Residue::AL_INVALID}END_ATOMS;
|
||||
BEGIN_BONDS{Residue::AL_CB, Residue::AL_CA,
|
||||
Residue::AL_1HB, Residue::AL_CB,
|
||||
Residue::AL_2HB, Residue::AL_CB,
|
||||
Residue::AL_CG, Residue::AL_CB,
|
||||
Residue::AL_1HG, Residue::AL_CG,
|
||||
Residue::AL_2HG, Residue::AL_CG,
|
||||
Residue::AL_CD, Residue::AL_CG,
|
||||
Residue::AL_1HD, Residue::AL_CD,
|
||||
Residue::AL_2HD, Residue::AL_CD,
|
||||
Residue::AL_NE, Residue::AL_CD,
|
||||
Residue::AL_HE, Residue::AL_NE,
|
||||
Residue::AL_CZ, Residue::AL_NE,
|
||||
Residue::AL_NH1, Residue::AL_CZ,
|
||||
Residue::AL_NH2, Residue::AL_CZ,
|
||||
Residue::AL_1HH1, Residue::AL_NH1,
|
||||
Residue::AL_2HH1, Residue::AL_NH1,
|
||||
Residue::AL_1HH2, Residue::AL_NH2,
|
||||
Residue::AL_2HH2, Residue::AL_NH2,
|
||||
Residue::AL_INVALID} END_BONDS;
|
||||
BEGIN_EXTREMES{Residue::AL_CZ, Residue::AL_INVALID}END_EXTREMES; // maybe Residue::AL_NH2m Residue::AL_NH1
|
||||
END_RES;
|
||||
|
||||
BEGIN_RES(Residue::ALA);
|
||||
BEGIN_ATOMS{Residue::AL_CB, Residue::AL_1HB, Residue::AL_2HB, Residue::AL_3HB,Residue::AL_INVALID} END_ATOMS;
|
||||
BEGIN_BONDS{ Residue::AL_CB, Residue::AL_CA,
|
||||
Residue::AL_1HB, Residue::AL_CB,
|
||||
Residue::AL_2HB, Residue::AL_CB,
|
||||
Residue::AL_3HB, Residue::AL_CB,
|
||||
Residue::AL_INVALID} END_BONDS;
|
||||
BEGIN_EXTREMES{Residue::AL_CB, Residue::AL_INVALID}END_EXTREMES;
|
||||
END_RES;
|
||||
|
||||
BEGIN_RES(Residue::ACE);
|
||||
BEGIN_ATOMS{Residue::AL_CH3, Residue::AL_C, Residue::AL_O, Residue::AL_1HH3, Residue::AL_2HH3, Residue::AL_3HH3,Residue::AL_INVALID}END_ATOMS;
|
||||
BEGIN_BONDS{Residue::AL_CH3, Residue::AL_C,
|
||||
Residue::AL_O, Residue::AL_C,
|
||||
Residue::AL_C, Residue::AL_1HH3,
|
||||
Residue::AL_C, Residue::AL_2HH3,
|
||||
Residue::AL_C, Residue::AL_3HH3,
|
||||
Residue::AL_INVALID} END_BONDS;
|
||||
BEGIN_EXTREMES{Residue::AL_INVALID}END_EXTREMES;
|
||||
END_RES;
|
||||
default:
|
||||
;
|
||||
}
|
||||
|
||||
return dat;
|
||||
//return std::pair<Residue::Atom_label*, Residue::Atom_label*>(als, bls);
|
||||
}
|
||||
|
||||
void do_initialize() {
|
||||
//if (amino_acid_initialized_) return;
|
||||
assert(amino_acid_initialized_==false);
|
||||
amino_acid_initialized_=true;
|
||||
unsigned int i=0;
|
||||
for (; atom_name_data_[i].l != Residue::AL_INVALID; ++i){
|
||||
clean_atom_name_data_[i].l= atom_name_data_[i].l;
|
||||
clean_atom_name_data_[i].t= atom_name_data_[i].t;
|
||||
sscanf(atom_name_data_[i].s, "%4s", clean_atom_name_data_[i].s);
|
||||
}
|
||||
clean_atom_name_data_[i].l= Residue::AL_INVALID;
|
||||
|
||||
unsigned int max_atoms=0;
|
||||
for (unsigned int i=0;atom_fallback_data_[i].l != Residue::AL_INVALID; ++i){
|
||||
max_atoms= (std::max)(max_atoms, static_cast<unsigned int>(atom_fallback_data_[i].l));
|
||||
}
|
||||
clean_atom_fallbacks_.resize(max_atoms+1);
|
||||
|
||||
for (unsigned int i=0;atom_fallback_data_[i].l != Residue::AL_INVALID; ++i){
|
||||
clean_atom_fallbacks_[atom_fallback_data_[i].l].push_back(atom_fallback_data_[i].lr);
|
||||
}
|
||||
|
||||
|
||||
Residue::Type all_res[]={Residue::GLY, Residue::ALA,
|
||||
Residue::VAL, Residue::LEU,
|
||||
Residue::ILE, Residue::SER,
|
||||
Residue::THR, Residue::CYS,
|
||||
Residue::MET, Residue::PRO,
|
||||
Residue::ASP, Residue::ASN,
|
||||
Residue::GLU, Residue::GLN,
|
||||
Residue::LYS, Residue::ARG,
|
||||
Residue::HIS, Residue::PHE,
|
||||
Residue::TYR, Residue::TRP,
|
||||
Residue::ACE, Residue::NH2,
|
||||
Residue::INV};
|
||||
unsigned int num_res= sizeof(all_res)/sizeof(Residue::Type);
|
||||
|
||||
|
||||
amino_acid_data_.resize(num_res);
|
||||
|
||||
|
||||
for (unsigned int i=0; i< num_res; ++i){
|
||||
Residue::Type cur_res=all_res[i];
|
||||
amino_acid_data_[cur_res]= Amino_acid_data();
|
||||
if (cur_res != Residue::ACE && cur_res != Residue::NH2) {
|
||||
// set up shared atoms
|
||||
Residue::Atom_label bl[]={ Residue::AL_N, Residue::AL_H,
|
||||
Residue::AL_1H, Residue::AL_2H,
|
||||
Residue::AL_3H, Residue::AL_CA,
|
||||
Residue::AL_HA, Residue::AL_1HA,
|
||||
Residue::AL_C, Residue::AL_O,
|
||||
Residue::AL_OXT};
|
||||
for (unsigned int j=0; j< sizeof(bl)/sizeof(Residue::Atom_label); ++j){
|
||||
amino_acid_data_[cur_res].atoms.push_back(bl[j]);
|
||||
}
|
||||
// set up basic bonds
|
||||
Residue::Atom_label bd[][2]={ {Residue::AL_N, Residue::AL_H}, {Residue::AL_N, Residue::AL_1H},
|
||||
{Residue::AL_N, Residue::AL_2H}, {Residue::AL_N, Residue::AL_3H},
|
||||
{Residue::AL_N, Residue::AL_CA}, {Residue::AL_CA, Residue::AL_HA},
|
||||
{Residue::AL_CA, Residue::AL_1HA}, {Residue::AL_CA, Residue::AL_C},
|
||||
{Residue::AL_C, Residue::AL_O}, {Residue::AL_O, Residue::AL_OXT} };
|
||||
for (unsigned int j=0; j< sizeof(bd)/sizeof(Possible_bond); ++j){
|
||||
amino_acid_data_[cur_res].bonds.push_back(Possible_bond(bd[j][0], bd[j][1]));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
(Residue::Residue::AL_CB, Residue::Residue::AL_HB, Residue::Residue::AL_CG1, Residue::Residue::AL_CG2,
|
||||
Residue::Residue::AL_1HG1, Residue::Residue::AL_2HG1, Residue::Residue::AL_3HG1, Residue::Residue::AL_1HG2,
|
||||
Residue::Residue::AL_2HG2, Residue::Residue::AL_3HG2, Residue::Residue::AL_INVALID) ,
|
||||
()
|
||||
*/
|
||||
|
||||
Residue_init_data data= get_residue_initialization_data(cur_res);
|
||||
|
||||
|
||||
for (unsigned int j=0; data.atms_[j] != Residue::AL_INVALID; ++j){
|
||||
amino_acid_data_[cur_res].atoms.push_back(data.atms_[j]);
|
||||
}
|
||||
for (unsigned int j=0; data.bnds_[j] != Residue::AL_INVALID; j+=2){
|
||||
amino_acid_data_[cur_res].bonds.push_back(Possible_bond(data.bnds_[j], data.bnds_[j+1]));
|
||||
}
|
||||
for (unsigned int j=0; data.extr_[j] != Residue::AL_INVALID; ++j){
|
||||
amino_acid_data_[cur_res].extremes.push_back(data.extr_[j]);
|
||||
}
|
||||
|
||||
if (false){
|
||||
std::cout << "For residue " << Residue::type_string(cur_res)
|
||||
<< " there are " << amino_acid_data_[cur_res].atoms.size() << " atoms, "
|
||||
<< amino_acid_data_[cur_res].bonds.size() << " bonds, and "
|
||||
<< amino_acid_data_[cur_res].extremes.size() << " extremes." << std::endl;
|
||||
assert(amino_acid_data_[cur_res].extremes.size() < 4);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Residue::Atom_label fix_atom_label(Residue::Type label, Residue::Atom_label al) {
|
||||
for (unsigned int i=0; i< amino_acid_data_[label].atoms.size(); ++i){
|
||||
if (Residue_data::amino_acid_data_[label].atoms[i] == al) return al;
|
||||
}
|
||||
//HERE
|
||||
/*if (clean_atom_fallbacks_.find(al) == clean_atom_fallbacks_.end()){
|
||||
dsrpdb_internal::error_logger.new_warning((std::string("No atom named ")+atom_label_string(al)
|
||||
+" in residue "+ type_string(label_)).c_str());
|
||||
return AL_INVALID;
|
||||
}*/
|
||||
for (unsigned int j=0; j< clean_atom_fallbacks_[al].size(); ++j){
|
||||
for (unsigned int i=0; i< amino_acid_data_[label].atoms.size(); ++i){
|
||||
if (amino_acid_data_[label].atoms[i] == clean_atom_fallbacks_[al][j])
|
||||
return clean_atom_fallbacks_[al][j];
|
||||
}
|
||||
}
|
||||
return Residue::AL_INVALID;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
CGAL_PDB_END_NAMESPACE
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
#include <CGAL/PDB/Transform.h>
|
||||
#include <CGAL/PDB/internal/tnt/tnt_cmat.h>
|
||||
|
||||
CGAL_PDB_BEGIN_NAMESPACE
|
||||
Transform::Transform(const Vector &trans, const Quaternion &q) {
|
||||
NT q00 = q[0]*q[0];
|
||||
NT q11 = q[1]*q[1];
|
||||
NT q22 = q[2]*q[2];
|
||||
NT q33 = q[3]*q[3];
|
||||
NT q03 = q[0]*q[3];
|
||||
NT q13 = q[1]*q[3];
|
||||
NT q23 = q[2]*q[3];
|
||||
NT q02 = q[0]*q[2];
|
||||
NT q12 = q[1]*q[2];
|
||||
NT q01 = q[0]*q[1];
|
||||
|
||||
//TNT::Matrix<NT> m(4,4);
|
||||
rot_[0][0] = q00 + q11 - q22 - q33;
|
||||
rot_[1][1] = q00 - q11 + q22 - q33;
|
||||
rot_[2][2] = q00 - q11 - q22 + q33;
|
||||
rot_[0][1] = 2.0*(q12-q03);
|
||||
rot_[1][0] = 2.0*(q12+q03);
|
||||
rot_[0][2] = 2.0*(q13+q02);
|
||||
rot_[2][0] = 2.0*(q13-q02);
|
||||
rot_[1][2] = 2.0*(q23-q01);
|
||||
rot_[2][1] = 2.0*(q23+q01);
|
||||
|
||||
//TNT::Matrix<NT> mt=TNT::transpose(m);
|
||||
//TNT::Matrix<NT> mm= TNT::matmult(mt, m);
|
||||
//std::cout << mm << std::endl;
|
||||
|
||||
//TNT::Matrix<NT> mat= q.to_matrix();
|
||||
/*for (unsigned int i=0; i< 3; ++i){
|
||||
for (unsigned int j=0; j<3; ++j){
|
||||
rot_[i][j]=m[i][j];
|
||||
}
|
||||
}*/
|
||||
trans_[0]=trans.x();
|
||||
trans_[1]=trans.y();
|
||||
trans_[2]=trans.z();
|
||||
}
|
||||
|
||||
void Transform::write(std::ostream &out) const {
|
||||
for (unsigned int i=0; i< 3; ++i){
|
||||
out << rot_[i][0] << "\t" << rot_[i][1] << "\t" << rot_[i][2] << "\t" << trans_[i] << std::endl;
|
||||
}
|
||||
out << 0 << "\t" << 0 << "\t" << 0 << "\t" << 1 << std::endl;
|
||||
|
||||
}
|
||||
CGAL_PDB_END_NAMESPACE
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
#include <CGAL/PDB/Residue.h>
|
||||
#include <CGAL/PDB/iterator.h>
|
||||
#include <CGAL/PDB/geometry.h>
|
||||
#include <CGAL/PDB/align.h>
|
||||
#include <CGAL/PDB/align_generic.h>
|
||||
#include <cassert>
|
||||
|
||||
|
||||
CGAL_PDB_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
|
||||
Transform transform_taking_first_to_second(const std::vector<Point> &a,
|
||||
const std::vector<Point> &b) {
|
||||
Transform tr
|
||||
= transform_taking_first_to_second(a.begin(),
|
||||
a.end(),
|
||||
b.begin(),
|
||||
b.end());
|
||||
return tr;
|
||||
}
|
||||
|
||||
|
||||
void align_second_protein_to_first(const Protein &base,
|
||||
Protein &o) {
|
||||
assert(base.number_of_residues()==o.number_of_residues());
|
||||
|
||||
//bp= base.backbone();
|
||||
//op= o.backbone();
|
||||
//get_backbone_coordinates(base, std::back_inserter(bp));
|
||||
//get_backbone_coordinates(o, std::back_inserter(op));
|
||||
Transform tr
|
||||
= transform_taking_first_to_second(backbone_coordinates_begin(o),
|
||||
backbone_coordinates_end(o),
|
||||
backbone_coordinates_begin(base),
|
||||
backbone_coordinates_end(base));
|
||||
|
||||
if (true) {
|
||||
std::cout << tr << std::endl;
|
||||
}
|
||||
|
||||
|
||||
for (Protein::Residues_iterator it= o.residues_begin(); it != o.residues_end(); ++it){
|
||||
Residue &aa= *it;
|
||||
//dsr::vector<Residue::Atom_label> als= aa->atoms();
|
||||
|
||||
for (Residue::Atoms_iterator it= aa.atoms_begin(); it != aa.atoms_end(); ++it){
|
||||
Atom a= it->second;
|
||||
Point pt= Point(a.cartesian_coords().x(), a.cartesian_coords().y(), a.cartesian_coords().z());
|
||||
Point tpt(tr(pt));
|
||||
a.set_cartesian_coords(Point(tpt.x(), tpt.y(), tpt.z()));
|
||||
|
||||
it->second=a;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Transform refine_alignment_of_second_protein_to_first(const Protein &base,
|
||||
Protein &o) {
|
||||
std::vector<Point> sheet_points, model_points;
|
||||
ca_coordinates(base.atoms_begin(), base.atoms_end(),
|
||||
std::back_inserter(sheet_points));
|
||||
ca_coordinates(o.atoms_begin(), o.atoms_end(),
|
||||
std::back_inserter(model_points));
|
||||
std::vector<std::vector<Point>::const_iterator> match;
|
||||
Transform t= refine_alignment(model_points.begin(), model_points.end(),
|
||||
sheet_points.begin(), sheet_points.end(),
|
||||
.01,
|
||||
std::back_inserter(match));
|
||||
for (Protein::Residues_iterator rit= o.residues_begin(); rit != o.residues_end(); ++rit){
|
||||
for (Residue::Atoms_iterator ait= rit->atoms_begin(); ait != rit->atoms_end(); ++ait){
|
||||
ait->second.set_cartesian_coords(t(ait->second.cartesian_coords()));
|
||||
}
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
CGAL_PDB_END_NAMESPACE
|
||||
|
|
@ -1,215 +0,0 @@
|
|||
#include <CGAL/PDB/distance.h>
|
||||
#include <iterator>
|
||||
#include <CGAL/PDB/geometry.h>
|
||||
#include <CGAL/PDB/Transform.h>
|
||||
#include <CGAL/PDB/align_generic.h>
|
||||
#include <CGAL/PDB/iterator.h>
|
||||
#include <CGAL/PDB/Model.h>
|
||||
#include <CGAL/PDB/internal/Error_logger.h>
|
||||
|
||||
#ifdef CGAL_CFG_MISSING_TEMPLATE_VECTOR_CONSTRUCTORS_BUG
|
||||
// need std::copy
|
||||
#include <algorithm>
|
||||
#endif
|
||||
|
||||
CGAL_PDB_BEGIN_NAMESPACE
|
||||
|
||||
struct Identity {
|
||||
const Point &operator()(const Point &a) const {
|
||||
return a;
|
||||
}
|
||||
};
|
||||
|
||||
template <class It, class F>
|
||||
double no_align_cRMS(It ab, It ae, It bb, It be, F f){
|
||||
Squared_distance sd;
|
||||
if (std::distance(ab, ae) != std::distance(bb, be)){
|
||||
CGAL_PDB_INTERNAL_NS::error_logger.new_fatal_error("Protein chains used for computing cRMS must have equal lengths.\n");
|
||||
}
|
||||
double ret=0;
|
||||
int num=0;
|
||||
for (It bc= bb, ac= ab; bc != be; ++bc, ++ac){
|
||||
|
||||
Point pt= Point(*bc);
|
||||
Point tpt= f(pt);
|
||||
ret += sd(*ac, tpt);
|
||||
++num;
|
||||
}
|
||||
return std::sqrt(ret)/ num;
|
||||
}
|
||||
|
||||
// base, o
|
||||
template <class It>
|
||||
double cRMS(It ab, It ae, It bb, It be){
|
||||
assert(std::distance(ab, ae) == std::distance(bb, be));
|
||||
|
||||
CGAL::PDB::Transform tr
|
||||
= CGAL::PDB::transform_taking_first_to_second( bb, be, ab, ae);
|
||||
/*{
|
||||
std::cout << "First write\n";
|
||||
std::ofstream outtest("/tmp/foo.pdb");
|
||||
o.write_pdb(outtest);
|
||||
}*/
|
||||
|
||||
if (false) {
|
||||
std::cout << tr << std::endl;
|
||||
}
|
||||
|
||||
return no_align_cRMS(bb, be, ab, ae, tr);
|
||||
|
||||
}
|
||||
|
||||
double no_align_cRMS(const Protein &a, const Protein &b) {
|
||||
return no_align_cRMS(all_coordinates_begin(a), all_coordinates_end(a),
|
||||
all_coordinates_begin(b), all_coordinates_end(b), Identity());
|
||||
/*double err=0;
|
||||
int n=0;
|
||||
assert(a.number_of_atoms() == b.number_of_atoms());
|
||||
for (Protein::Const_atoms_iterator ait= a.atoms_begin(), bit = b.atoms_begin();
|
||||
ait != a.atoms_end(); ++ait, ++bit){
|
||||
++n;
|
||||
Vector v= ait->second.cartesian_coords() - bit->second.cartesian_coords();
|
||||
err += v*v;
|
||||
}
|
||||
|
||||
return std::sqrt(err)/n;*/
|
||||
}
|
||||
|
||||
double no_align_ca_cRMS(const Protein &a, const Protein &b) {
|
||||
return no_align_cRMS(ca_coordinates_begin(a), ca_coordinates_end(a),
|
||||
ca_coordinates_begin(b), ca_coordinates_end(b), Identity());
|
||||
}
|
||||
|
||||
double cRMS(const Protein &a, const Protein &b) {
|
||||
return cRMS(all_coordinates_begin(a), all_coordinates_end(a),
|
||||
all_coordinates_begin(b), all_coordinates_end(b));
|
||||
}
|
||||
|
||||
double ca_cRMS(const Protein &a, const Protein &b) {
|
||||
return cRMS(ca_coordinates_begin(a), ca_coordinates_end(a),
|
||||
ca_coordinates_begin(b), ca_coordinates_end(b));
|
||||
}
|
||||
|
||||
template <class It>
|
||||
double dRMS(It ab, It ae, It bb, It be) {
|
||||
assert(std::distance(ab, ae) == std::distance(bb, be));
|
||||
double ret=0;
|
||||
int count=0;
|
||||
for (It ac= ab, bc= bb; ac != ae; ++ac, ++bc) {
|
||||
for (It ac2= ab, bc2= bb; ac2 != ac; ++ac2, ++bc2) {
|
||||
Vector va= *ac- *ac2;
|
||||
Vector vb= *bc- *bc2;
|
||||
double da= std::sqrt(va*va);
|
||||
double db= std::sqrt(vb*vb);
|
||||
ret+= (da-db)*(da-db);
|
||||
++count;
|
||||
}
|
||||
}
|
||||
return ret/count;
|
||||
}
|
||||
|
||||
double dRMS(const Protein &a, const Protein &b) {
|
||||
std::vector<Point> aa;
|
||||
std::vector<Point> ba;
|
||||
|
||||
coordinates(a.atoms_begin(), a.atoms_end(), std::back_inserter(aa));
|
||||
coordinates(b.atoms_begin(), b.atoms_end(), std::back_inserter(ba));
|
||||
return dRMS(aa.begin(), aa.end(), ba.begin(), ba.end());
|
||||
}
|
||||
|
||||
double ca_dRMS(const Protein &a, const Protein &b){
|
||||
std::vector<Point> aa;
|
||||
std::vector<Point> ba;
|
||||
|
||||
ca_coordinates(a.atoms_begin(), a.atoms_end(), std::back_inserter(aa));
|
||||
ca_coordinates(b.atoms_begin(), b.atoms_end(), std::back_inserter(ba));
|
||||
return dRMS(aa.begin(), aa.end(), ba.begin(), ba.end());
|
||||
}
|
||||
template <class It>
|
||||
Matrix distance_matrix(It ab, It ae){
|
||||
int dist= std::distance(ab, ae);
|
||||
Matrix ret(dist,dist);
|
||||
|
||||
int indi=0;
|
||||
for (It ac= ab; ac != ae; ++ac, ++indi){
|
||||
int indj=0;
|
||||
for (It ac2= ab; ac2 != ac; ++ac2, ++indj){
|
||||
Vector dif= *ac- *ac2;
|
||||
//std::cout << dif << std::endl;
|
||||
double d= std::sqrt(dif*dif);
|
||||
//std::cout << d << std::endl;
|
||||
ret[indi][indj]=d;
|
||||
ret[indj][indi]=d;
|
||||
}
|
||||
ret[indi][indi]=0;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
Matrix distance_matrix(const Protein &a){
|
||||
#ifndef CGAL_CFG_MISSING_TEMPLATE_VECTOR_CONSTRUCTORS_BUG
|
||||
std::vector<Point> aa(all_coordinates_begin(a), all_coordinates_end(a));
|
||||
#else
|
||||
std::vector<Point> aa;
|
||||
std::copy(all_coordinates_begin(a), all_coordinates_end(a), std::back_inserter(aa));
|
||||
#endif
|
||||
return distance_matrix(aa.begin(), aa.end());
|
||||
}
|
||||
|
||||
Matrix ca_distance_matrix(const Protein &a) {
|
||||
#ifndef CGAL_CFG_MISSING_TEMPLATE_VECTOR_CONSTRUCTORS_BUG
|
||||
std::vector<Point> aa(ca_coordinates_begin(a), ca_coordinates_end(a));
|
||||
#else
|
||||
std::vector<Point> aa;
|
||||
std::copy(ca_coordinates_begin(a), ca_coordinates_end(a), std::back_inserter(aa));
|
||||
#endif
|
||||
return distance_matrix(aa.begin(), aa.end());
|
||||
}
|
||||
Matrix backbone_distance_matrix(const Protein &a) {
|
||||
#ifndef CGAL_CFG_MISSING_TEMPLATE_VECTOR_CONSTRUCTORS_BUG
|
||||
std::vector<Point> aa(backbone_coordinates_begin(a), backbone_coordinates_end(a));
|
||||
#else
|
||||
std::vector<Point> aa;
|
||||
std::copy(backbone_coordinates_begin(a), backbone_coordinates_end(a), std::back_inserter(aa));
|
||||
#endif
|
||||
return distance_matrix(aa.begin(), aa.end());
|
||||
}
|
||||
|
||||
Matrix distance_matrix(const Model &a){
|
||||
std::vector<Point> aa;
|
||||
for (unsigned int j=0; j< a.number_of_chains(); ++j){
|
||||
#ifndef CGAL_CFG_MISSING_TEMPLATE_VECTOR_CONSTRUCTORS_BUG
|
||||
aa.insert(aa.end(), all_coordinates_begin(a.chain(j)), all_coordinates_end(a.chain(j)));
|
||||
#else
|
||||
std::copy(all_coordinates_begin(a.chain(j)), all_coordinates_end(a.chain(j)), std::back_inserter(aa));
|
||||
#endif
|
||||
}
|
||||
return distance_matrix(aa.begin(), aa.end());
|
||||
}
|
||||
|
||||
Matrix ca_distance_matrix(const Model &a) {
|
||||
std::vector<Point> aa;
|
||||
for (unsigned int j=0; j< a.number_of_chains(); ++j){
|
||||
#ifndef CGAL_CFG_MISSING_TEMPLATE_VECTOR_CONSTRUCTORS_BUG
|
||||
aa.insert(aa.end(), ca_coordinates_begin(a.chain(j)), ca_coordinates_end(a.chain(j)));
|
||||
#else
|
||||
std::copy(ca_coordinates_begin(a.chain(j)), ca_coordinates_end(a.chain(j)), std::back_inserter(aa));
|
||||
#endif
|
||||
}
|
||||
return distance_matrix(aa.begin(), aa.end());
|
||||
}
|
||||
|
||||
Matrix backbone_distance_matrix(const Model &a) {
|
||||
std::vector<Point> aa;
|
||||
for (unsigned int j=0; j< a.number_of_chains(); ++j){
|
||||
#ifndef CGAL_CFG_MISSING_TEMPLATE_VECTOR_CONSTRUCTORS_BUG
|
||||
aa.insert(aa.end(), backbone_coordinates_begin(a.chain(j)), backbone_coordinates_end(a.chain(j)));
|
||||
#else
|
||||
std::copy(backbone_coordinates_begin(a.chain(j)), backbone_coordinates_end(a.chain(j)), std::back_inserter(aa));
|
||||
#endif
|
||||
}
|
||||
return distance_matrix(aa.begin(), aa.end());
|
||||
}
|
||||
|
||||
|
||||
CGAL_PDB_END_NAMESPACE
|
||||
|
|
@ -1,69 +0,0 @@
|
|||
/* Copyright 2004
|
||||
Stanford University
|
||||
|
||||
This file is part of the DSR PDB Library.
|
||||
|
||||
The DSR PDB Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The DSR PDB Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the DSR PDB Library; see the file LICENSE.LGPL. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include <CGAL/PDB/internal/pdb_utils.h>
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <set>
|
||||
#include <CGAL/PDB/internal/Error_logger.h>
|
||||
CGAL_PDB_BEGIN_INTERNAL_NAMESPACE
|
||||
|
||||
//ATOM 812 OG ASER 106 -.072 22.447 10.384 .50 11.73 1ECD 918
|
||||
//ATOM 60 O SER L 9 -26.231 10.210 -4.537 1.00 26.25 7FAB 160
|
||||
|
||||
const char atom_line_iformat_[]=
|
||||
"ATOM %5d%*1c%4c%1c%3c%*c%1c%4d%1c%*1c%*1c%*1c%8f%8f%8f%6f%6f%*1c%*1c%*1c%*1c%*1c%*1c%4c%2c%2c";
|
||||
const char hetatom_line_iformat_[]=
|
||||
"HETATM%5d%*1c%4c%1c%3c%*c%1c%4d%1c%*1c%*1c%*1c%8f%8f%8f%6f%6f%*1c%*1c%*1c%*1c%*1c%*1c%4c%2c%2c";
|
||||
|
||||
const char atom_line_oformat_[]=
|
||||
"ATOM %5d %4s%1c%3s %1c%4d%1c %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%2s";
|
||||
const char hetatom_line_oformat_[]=
|
||||
"HETATM%5d %4s%1c%3s %1c%4d%1c %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%2s";
|
||||
|
||||
Line_type line_type (const char* line) {
|
||||
if (line[0]=='\0') return OTHER;
|
||||
//char s[7];
|
||||
//strncpy (s, line, 6); s[6] = '\0';
|
||||
std::string word(line,0,6);
|
||||
if (word== "DBREF ") return DBREF;
|
||||
else if (word=="SEQRES") return SEQRES;
|
||||
else if (word== "ATOM ") return ATOM;
|
||||
else if (word== "HETATM") return HETATM;
|
||||
else if (word== "MASTER") return MASTER;
|
||||
else if (word== "ENDMDL") return ENDMDL;
|
||||
else if (word== "END " || word== "END " || word== "END " || word== "END") return END;
|
||||
else if (word == "HEADER" || word == "TITLE " || word == "COMPND" || word == "SOURCE"
|
||||
|| word == "KEYWDS" || word == "EXPDTA" || word == "AUTHOR" || word == "REVDAT"
|
||||
|| word == "JRNL " || word == "REMARK" || word == "HELIX " || word == "SHEET "
|
||||
|| word == "SITE " || word == "CRYST1" || word == "ORIGX1" || word == "ORIGX2"
|
||||
|| word == "ORIGX3" || word == "SCALE1" || word == "SCALE2" || word == "SCALE3"
|
||||
|| word == "SEQADV" || word == "TURN " || word == "FORMUL" || word == "HETNAM"
|
||||
|| word == "SSBOND" || word == "MODRES" || word == "CONECT" || word == "HET "
|
||||
|| word == "CISPEP" || word == "LINK " || word == "HETSYN") return HEADER;
|
||||
else if (word== "TER " || word == "TER") return TER;
|
||||
else if (word== "MODEL ") return MODEL;
|
||||
else {
|
||||
error_logger.new_warning(std::string("\"" + word + "\" is not a known line type.").c_str());
|
||||
return OTHER;
|
||||
}
|
||||
}
|
||||
CGAL_PDB_END_INTERNAL_NAMESPACE
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
#include <CGAL/PDB/transforms.h>
|
||||
#include <CGAL/PDB/PDB.h>
|
||||
#include <CGAL/PDB/Protein.h>
|
||||
#include <CGAL/PDB/Transform.h>
|
||||
CGAL_PDB_BEGIN_NAMESPACE
|
||||
|
||||
void transform_protein(const Transform &t, Protein &p) {
|
||||
for (Protein::Residues_iterator rit= p.residues_begin(); rit != p.residues_end(); ++rit){
|
||||
for (Residue::Atoms_iterator ait= rit->atoms_begin(); ait != rit->atoms_end(); ++ait){
|
||||
ait->second.set_cartesian_coords(t(ait->second.cartesian_coords()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void transform_pdb(const Transform &t, PDB &pdb) {
|
||||
for (unsigned int i=0;i< pdb.number_of_models(); ++i){
|
||||
Model &m= pdb.model(i);
|
||||
std::cout << "Model " << i << " has " << m.number_of_chains() << " chains."<< std::endl;
|
||||
for (unsigned int j=0; j< m.number_of_chains(); ++j){
|
||||
Protein &p= m.chain(j);
|
||||
transform_protein(t, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
CGAL_PDB_END_NAMESPACE
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
#include "PDB_Atom.cpp"
|
||||
#include "PDB_Protein_pdb.cpp"
|
||||
#include "PDB_align.cpp"
|
||||
#include "PDB_Error_logger.cpp"
|
||||
#include "PDB_Quaternion.cpp"
|
||||
#include "PDB_distance.cpp"
|
||||
#include "PDB_Model.cpp"
|
||||
#include "PDB_Residue.cpp"
|
||||
#include "PDB_pdb_utils.cpp"
|
||||
#include "PDB_PDB.cpp"
|
||||
#include "PDB_Residue_data.cpp"
|
||||
#include "PDB_transforms.cpp"
|
||||
#include "PDB_Protein.cpp"
|
||||
#include "PDB_Transform.cpp"
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
# Copyright (c) 2007 INRIA Sophia-Antipolis (France).
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is part of CGAL (www.cgal.org); you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public License as
|
||||
# published by the Free Software Foundation; version 2.1 of the License.
|
||||
# See the file LICENSE.LGPL distributed with CGAL.
|
||||
#
|
||||
# Licensees holding a valid commercial license may use this file in
|
||||
# accordance with the commercial license agreement provided with the software.
|
||||
#
|
||||
# This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
# WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#
|
||||
# $URL: svn+ssh://lrineau@scm.gforge.inria.fr/svn/cgal/trunk/Installation/src/CGAL/makefile $
|
||||
# $Id: makefile 36165 2007-02-09 23:33:22Z lrineau $
|
||||
#
|
||||
# Author(s) : Laurent Rineau
|
||||
|
||||
|
||||
#---------------------------------------------------------------------#
|
||||
# object files
|
||||
#---------------------------------------------------------------------#
|
||||
|
||||
# We now compile all source files at once since it is faster
|
||||
# When adding a new file, please update app_files.cpp
|
||||
OBJECTS = all_files$(OBJ_EXT)
|
||||
|
||||
# Below variable is not used now (but may come back so let's keep it)
|
||||
OBJECTS_OLD = \
|
||||
PDB_Atom$(OBJ_EXT) \
|
||||
PDB_Protein_pdb$(OBJ_EXT) \
|
||||
PDB_align$(OBJ_EXT) \
|
||||
PDB_Error_logger$(OBJ_EXT) \
|
||||
PDB_Quaternion$(OBJ_EXT) \
|
||||
PDB_distance$(OBJ_EXT) \
|
||||
PDB_Model$(OBJ_EXT) \
|
||||
PDB_Residue$(OBJ_EXT) \
|
||||
PDB_pdb_utils$(OBJ_EXT) \
|
||||
PDB_PDB$(OBJ_EXT) \
|
||||
PDB_Residue_data$(OBJ_EXT) \
|
||||
PDB_transforms$(OBJ_EXT) \
|
||||
PDB_Protein$(OBJ_EXT) \
|
||||
PDB_Transform$(OBJ_EXT)
|
||||
|
||||
#---------------------------------------------------------------------#
|
||||
# libCGALPDB settings
|
||||
#---------------------------------------------------------------------#
|
||||
|
||||
SOVERSION=2.0.0
|
||||
SOMAJOR=2
|
||||
|
||||
LIB_NAME_BASE = CGALPDB
|
||||
|
||||
|
||||
SHARED_LIB_ADDITIONAL_LDFLAGS = $(CGAL_LIBPATHFLAGS) $(CGAL_CGAL_LDFLAGS)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------#
|
||||
# common rules for all libraries
|
||||
#---------------------------------------------------------------------#
|
||||
include ../CGAL/common.mk
|
||||
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
#include <CGAL/PDB/Protein.h>
|
||||
#include <CGAL/PDB/geometry.h>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
int main(int, char *[]){
|
||||
std::ifstream input("data/check_bonds.pdb");
|
||||
CGAL_PDB_NS::Protein helix(input);
|
||||
//helix.dump(std::cout);
|
||||
std::vector<CGAL_PDB_NS::Point> points;
|
||||
std::vector<CGAL_PDB_NS::Protein::Bond> bonds;
|
||||
CGAL_PDB_NS::backbone_coordinates_and_bonds(helix, std::back_inserter(points), std::back_inserter(bonds));
|
||||
assert(bonds.size() == points.size()-2);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
/* Copyright 2004
|
||||
Stanford University
|
||||
|
||||
This file is part of the DSR PDB Library.
|
||||
|
||||
The DSR PDB Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The DSR PDB Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the DSR PDB Library; see the file LICENSE.LGPL. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include <CGAL/PDB/PDB.h>
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Regular_triangulation_euclidean_traits_3.h>
|
||||
#include <CGAL/PDB/geometry.h>
|
||||
#include "include/check_equal.h"
|
||||
|
||||
|
||||
int main(int , char *[]){
|
||||
//dsr::Residue res= dsr::Residue(dsr::Residue::VAL);
|
||||
//res.write(std::cout);
|
||||
//assert(argc==3);
|
||||
std::ifstream in("data/check_hetatom.pdb");
|
||||
CGAL_PDB_NS::PDB p(in);
|
||||
//p.write(std::cout);
|
||||
std::ostringstream of;
|
||||
|
||||
std::cout << "There are " << p.number_of_models() << " models." << std::endl;
|
||||
|
||||
for (unsigned int i=0; i< p.number_of_models(); ++i){
|
||||
const CGAL_PDB_NS::Model &m= p.model(i);
|
||||
std::cout << "Model " << i << " has " << m.number_of_chains()
|
||||
<< " chains" << " and " << m.hetatoms_size()
|
||||
<< " HETATMS" << std::endl;
|
||||
for (unsigned int j=0; j< m.number_of_chains(); ++j){
|
||||
std::cout << "Chain " << j << " has "
|
||||
<< m.chain(j).number_of_residues() << " residues" << std::endl;
|
||||
}
|
||||
}
|
||||
p.write(of);
|
||||
|
||||
std::ifstream in2("data/check_hetatom.pdb");
|
||||
std::istringstream iss(of.str().c_str());
|
||||
check_equal(in2, iss);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
/* Copyright 2004
|
||||
Stanford University
|
||||
|
||||
This file is part of the DSR PDB Library.
|
||||
|
||||
The DSR PDB Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The DSR PDB Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the DSR PDB Library; see the file LICENSE.LGPL. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include <CGAL/PDB/PDB.h>
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
#include <sstream>
|
||||
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Regular_triangulation_euclidean_traits_3.h>
|
||||
#include <CGAL/PDB/geometry.h>
|
||||
#include <CGAL/PDB/cgal.h>
|
||||
|
||||
#include "check_equal.h"
|
||||
|
||||
|
||||
int main(int , char *[]){
|
||||
//dsr::Residueres= dsr::Residue(dsr::Residue::VAL);
|
||||
//res.write(std::cout);
|
||||
std::string argv1="data/check_pdb.pdb";
|
||||
std::ifstream in(argv1.c_str());
|
||||
CGAL_PDB_NS::PDB p(in);
|
||||
//p.write(std::cout);
|
||||
std::ostringstream of;
|
||||
|
||||
std::cout << "There are " << p.number_of_models() << " models." << std::endl;
|
||||
|
||||
for (unsigned int i=0; i< p.number_of_models(); ++i){
|
||||
const CGAL_PDB_NS::Model &m= p.model(i);
|
||||
std::cout << "Model " << i << " has " << m.number_of_chains() << " chains" << std::endl;
|
||||
for (unsigned int j=0; j< m.number_of_chains(); ++j){
|
||||
std::cout << "Chain " << j << " has " << m.chain(j).number_of_residues() << " residues" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
p.write(of);
|
||||
//of << std::fflush;
|
||||
|
||||
#ifdef PDB_USE_CGAL
|
||||
if (false){
|
||||
typedef CGAL::Regular_triangulation_euclidean_traits_3<CGAL::Exact_predicates_inexact_constructions_kernel> Tr;
|
||||
|
||||
std::vector<Tr::Weighted_point> wps;
|
||||
CGAL_PDB_NS::all_weighted_points(p.model(0), Tr(),
|
||||
std::back_inserter(wps));
|
||||
std::copy(wps.begin(), wps.end(),
|
||||
std::ostream_iterator<Tr::Weighted_point>(std::cout, "\n"));
|
||||
}
|
||||
#endif
|
||||
std::ifstream nif(argv1.c_str());
|
||||
std::istringstream ofis(of.str().c_str());
|
||||
check_equal(nif, ofis);
|
||||
|
||||
return return_code__;
|
||||
}
|
||||
|
|
@ -1,121 +0,0 @@
|
|||
/* Copyright 2004
|
||||
Stanford University
|
||||
|
||||
This file is part of the DSR PDB Library.
|
||||
|
||||
The DSR PDB Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The DSR PDB Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the DSR PDB Library; see the file LICENSE.LGPL. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include <CGAL/PDB/Protein.h>
|
||||
#include <CGAL/PDB/geometry.h>
|
||||
#include <CGAL/PDB/iterator.h>
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Regular_triangulation_euclidean_traits_3.h>
|
||||
|
||||
#include "check_equal.h"
|
||||
|
||||
int main(int , char *[]){
|
||||
//dsr::Residue res= dsr::Residue(dsr::Residue::VAL);
|
||||
//res.write(std::cout);
|
||||
|
||||
std::ifstream in("data/check_protein.pdb");
|
||||
CGAL_PDB_NS::Protein p(in);
|
||||
//p.write(std::cout);
|
||||
std::ostringstream of;
|
||||
|
||||
std::cout << "There are " << p.number_of_residues() << " residues." << std::endl;
|
||||
|
||||
p.write_pdb(of);
|
||||
|
||||
std::ifstream in2("data/check_protein.pdb");
|
||||
std::istringstream iss(of.str().c_str());
|
||||
check_equal(in2, iss);
|
||||
|
||||
//p.dump(std::cout);
|
||||
|
||||
// Demonstrate the geometry functions
|
||||
std::vector<CGAL_PDB_NS::Point> atms;
|
||||
CGAL_PDB_NS::coordinates(p.atoms_begin(), p.atoms_end(), std::back_inserter(atms));
|
||||
std::cout << "There are " << atms.size() << " atoms." << std::endl;
|
||||
assert(std::distance(p.atoms_begin(), p.atoms_end()) == atms.size());
|
||||
|
||||
std::vector<CGAL_PDB_NS::Protein::Bond> bds(p.bonds_begin(), p.bonds_end());
|
||||
std::cout << "There are " << bds.size() << " bonds." << std::endl;
|
||||
|
||||
|
||||
std::vector<CGAL_PDB_NS::Point> bb;
|
||||
CGAL_PDB_NS::backbone_coordinates(p.atoms_begin(), p.atoms_end(), std::back_inserter(bb));
|
||||
assert(bb.size() < atms.size());
|
||||
{
|
||||
std::vector<std::pair<int,int> > bonds;
|
||||
std::vector<CGAL_PDB_NS::Point> points;
|
||||
CGAL_PDB_NS::coordinates_and_bonds(p, std::back_inserter(points), std::back_inserter(bonds));
|
||||
assert(bonds.size() == bds.size());
|
||||
assert(points.size() == atms.size());
|
||||
}
|
||||
{
|
||||
std::vector<CGAL_PDB_NS::Point> points;
|
||||
CGAL_PDB_NS::coordinates(p.atoms_begin(), p.atoms_end(), std::back_inserter(points));
|
||||
assert(points.size() == atms.size());
|
||||
}
|
||||
{
|
||||
std::vector<CGAL_PDB_NS::Point> points;
|
||||
std::copy(backbone_coordinates_begin(p),
|
||||
backbone_coordinates_end(p),
|
||||
std::back_inserter(points));
|
||||
assert(points.size() == bb.size());
|
||||
}
|
||||
{
|
||||
std::vector<std::pair<int,int> > bonds;
|
||||
std::vector<CGAL_PDB_NS::Point> points;
|
||||
CGAL_PDB_NS::simplified_coordinates_and_bonds(p,
|
||||
std::back_inserter(points),
|
||||
std::back_inserter(bonds));
|
||||
//std::cerr << bonds.size() << " " << atms.size() << " " << points.size() << std::endl;
|
||||
assert(bonds.size() == points.size()-1);
|
||||
assert(points.size() <= 4*p.number_of_residues());
|
||||
}
|
||||
|
||||
{
|
||||
for (CGAL_PDB_NS::Protein::Atoms_iterator it= p.atoms_begin(); it != p.atoms_end(); ++it){
|
||||
CGAL_PDB_NS::Atom::Index ind= it->second.index();
|
||||
CGAL_PDB_NS::Residue::Atom_label al= it->first;
|
||||
CGAL_PDB_NS::Residue& res= p.residue_containing_atom(ind);
|
||||
assert(&res >= &*p.residues_begin()
|
||||
&& &res < &*p.residues_begin() + p.number_of_residues());
|
||||
assert(res.atom_label(ind) != CGAL_PDB_NS::Residue::AL_INVALID);
|
||||
assert(res.atom_label(ind) == al);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
for (CGAL_PDB_NS::Protein::Bonds_iterator it= p.bonds_begin(); it != p.bonds_end(); ++it){
|
||||
CGAL_PDB_NS::Atom::Index ind0= it->first;
|
||||
CGAL_PDB_NS::Atom::Index ind1= it->second;
|
||||
assert(p.atom(ind0) != p.atom(CGAL_PDB_NS::Atom::Index()));
|
||||
assert(p.atom(ind1) != p.atom(CGAL_PDB_NS::Atom::Index()));
|
||||
int ir0= p.residue_containing_atom(ind0).index().to_index();
|
||||
int ir1= p.residue_containing_atom(ind1).index().to_index();
|
||||
int diff = ir1 - ir0;
|
||||
assert(diff==0 || diff ==1);
|
||||
}
|
||||
}
|
||||
|
||||
return return_code__;
|
||||
}
|
||||
|
|
@ -1,190 +0,0 @@
|
|||
#include <CGAL/PDB/align_generic.h>
|
||||
#include <CGAL/PDB/align.h>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <iterator>
|
||||
#include <CGAL/PDB/Protein.h>
|
||||
#include <CGAL/PDB/geometry.h>
|
||||
#include <CGAL/PDB/transforms.h>
|
||||
|
||||
int main(int, char *[]){
|
||||
typedef CGAL_PDB_NS::Point P;
|
||||
std::vector<P> hairpin;
|
||||
typedef std::vector<P>::const_iterator H;
|
||||
hairpin.push_back(P(0, 0,0));
|
||||
hairpin.push_back(P(1, 0,0));
|
||||
hairpin.push_back(P(2, 0,0));
|
||||
hairpin.push_back(P(3, 0,0));
|
||||
hairpin.push_back(P(4, 0,0));
|
||||
hairpin.push_back(P(4,.5,0));
|
||||
hairpin.push_back(P(4, 1,0));
|
||||
hairpin.push_back(P(3, 1,0));
|
||||
hairpin.push_back(P(2, 1,0));
|
||||
hairpin.push_back(P(1, 1,0));
|
||||
hairpin.push_back(P(0, 1,0));
|
||||
|
||||
|
||||
{
|
||||
CGAL_PDB_NS::Transform tr;
|
||||
tr.set_translation(P(0,0,1));
|
||||
|
||||
std::vector<P> trp;
|
||||
for (unsigned int i=0; i< hairpin.size(); ++i){
|
||||
trp.push_back(tr(hairpin[i]));
|
||||
}
|
||||
|
||||
std::vector<H> match;
|
||||
CGAL_PDB_NS::Transform tro= CGAL_PDB_NS::refine_alignment(hairpin.begin(), hairpin.end(),
|
||||
trp.begin(), trp.end(),
|
||||
.01,
|
||||
std::back_inserter(match));
|
||||
/*std::cout << tr << std::endl;
|
||||
std::cout << tro << std::endl;
|
||||
std::copy(match.begin(), match.end(), std::ostream_iterator<int>(std::cout, " "));
|
||||
std::cout << std::endl;*/
|
||||
assert(match.size()==hairpin.size());
|
||||
for (unsigned int i=0; i< match.size(); ++i){
|
||||
//int d= match[i]-trp.begin();
|
||||
assert(match[i]- trp.begin() == static_cast<int>(i));
|
||||
}
|
||||
std::cout << tr << std::endl << tro << std::endl;
|
||||
}
|
||||
|
||||
{
|
||||
CGAL_PDB_NS::Transform tr;
|
||||
tr.set_translation(P(0,.5,1));
|
||||
|
||||
std::vector<P> trp;
|
||||
for (unsigned int i=0; i< hairpin.size(); ++i){
|
||||
trp.push_back(tr(hairpin[i]));
|
||||
}
|
||||
|
||||
std::vector<H> match;
|
||||
CGAL_PDB_NS::Transform tro= CGAL_PDB_NS::refine_alignment(hairpin.begin(), hairpin.end(),
|
||||
trp.begin(), trp.end(),
|
||||
.01,
|
||||
std::back_inserter(match));
|
||||
/*std::cout << tr << std::endl;
|
||||
std::cout << tro << std::endl;
|
||||
std::copy(match.begin(), match.end(), std::ostream_iterator<int>(std::cout, " "));
|
||||
std::cout << std::endl;*/
|
||||
assert(match.size()==hairpin.size());
|
||||
for (unsigned int i=0; i< match.size(); ++i){
|
||||
assert(match[i] - trp.begin() == static_cast<int>(i));
|
||||
}
|
||||
std::cout << tr << std::endl << tro << std::endl;
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
std::vector<P> hairpin_2;
|
||||
hairpin_2.push_back(P(-1,0,0));
|
||||
hairpin_2.push_back(P(0,0,0));
|
||||
for (unsigned int i=0; i< hairpin.size(); ++i){
|
||||
hairpin_2.push_back(P(hairpin[i].x()+1, hairpin[i].y(), hairpin[i].z()));
|
||||
}
|
||||
hairpin_2.push_back(P(0,1,0));
|
||||
hairpin_2.push_back(P(-1,1,0));
|
||||
|
||||
std::vector<H> match;
|
||||
CGAL_PDB_NS::refine_alignment(hairpin.begin(), hairpin.end(),
|
||||
hairpin_2.begin(), hairpin_2.end(),
|
||||
.01,
|
||||
std::back_inserter(match));
|
||||
//std::copy(match.begin(), match.end(), std::ostream_iterator<int>(std::cout, " "));
|
||||
for (unsigned int i=0; i< match.size(); ++i){
|
||||
std::cout << match[i]- hairpin_2.begin() << " ";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
assert(match.size() == hairpin.size());
|
||||
for (unsigned int i=0; i< 5; ++i){
|
||||
//assert(match[i]-hairpin_2.begin()==static_cast<int>(i));
|
||||
}
|
||||
for (unsigned int i=0; i< 6; ++i){
|
||||
//assert(match[i+5]-hairpin_2.begin()== static_cast<int>(i+9));
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
std::ifstream sheetstream("data/check_bonds.pdb");
|
||||
CGAL_PDB_NS::Protein sheet(sheetstream);
|
||||
std::ifstream modelstream("data/check_refine_alignment_0.pdb");
|
||||
CGAL_PDB_NS::Protein model(modelstream);
|
||||
|
||||
std::vector<CGAL_PDB_NS::Point> sheet_points, model_points;
|
||||
CGAL_PDB_NS::backbone_coordinates(sheet.atoms_begin(), sheet.atoms_end(),
|
||||
std::back_inserter(sheet_points));
|
||||
CGAL_PDB_NS::backbone_coordinates(model.atoms_begin(), model.atoms_end(),
|
||||
std::back_inserter(model_points));
|
||||
|
||||
std::vector<H> match;
|
||||
CGAL_PDB_NS::refine_alignment(sheet_points.begin(), sheet_points.end(),
|
||||
model_points.begin(), model_points.end(),
|
||||
.01,
|
||||
std::back_inserter(match));
|
||||
/*std::copy(match.begin(), match.end(), std::ostream_iterator<int>(std::cout, " "));
|
||||
std::cout << std::endl;*/
|
||||
// 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
|
||||
for (unsigned int i=0; i < 15; ++i){
|
||||
assert(match[i]-model_points.begin() == 84+static_cast<int>(i));
|
||||
}
|
||||
for (unsigned int i=0; i< 14; ++i){
|
||||
//int d= match[15+i]-model_points.begin();
|
||||
assert(match[15+i]-model_points.begin() == 138+ static_cast<int>(i));
|
||||
}
|
||||
|
||||
{
|
||||
CGAL_PDB_NS::Transform tr;
|
||||
tr.set_translation(P(1,1,1));
|
||||
for (unsigned int i=0; i< sheet_points.size(); ++i){
|
||||
sheet_points[i] = tr(sheet_points[i]);
|
||||
}
|
||||
std::vector<H> match2;
|
||||
CGAL_PDB_NS::refine_alignment(sheet_points.begin(), sheet_points.end(),
|
||||
model_points.begin(), model_points.end(),
|
||||
.01,
|
||||
std::back_inserter(match2));
|
||||
for (unsigned int i=0; i < match.size(); ++i){
|
||||
assert(match2[i] == match[i]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
std::ifstream t1("data/check_refine_alignment_1.pdb");
|
||||
CGAL_PDB_NS::Protein pt1(t1);
|
||||
std::ifstream t2("data/check_refine_alignment_2.pdb");
|
||||
CGAL_PDB_NS::Protein pt2(t2);
|
||||
|
||||
|
||||
CGAL_PDB_NS::Transform tr;
|
||||
tr.set_translation(P(1,1,1));
|
||||
CGAL_PDB_NS::Protein cpt1(pt1);
|
||||
CGAL_PDB_NS::transform_protein(tr, cpt1);
|
||||
{
|
||||
CGAL_PDB_NS::Protein lpt2(pt2);
|
||||
CGAL_PDB_NS::Transform otr0= CGAL_PDB_NS::refine_alignment_of_second_protein_to_first(pt1, lpt2);
|
||||
std::cout << otr0 << std::endl;
|
||||
}
|
||||
{
|
||||
CGAL_PDB_NS::Protein lpt1(pt1);
|
||||
CGAL_PDB_NS::Transform otr0= CGAL_PDB_NS::refine_alignment_of_second_protein_to_first(pt2, lpt1);
|
||||
std::cout << otr0 << std::endl;
|
||||
}
|
||||
{
|
||||
CGAL_PDB_NS::Protein lcpt1(cpt1);
|
||||
CGAL_PDB_NS::Transform otr1 = CGAL_PDB_NS::refine_alignment_of_second_protein_to_first(pt1, lcpt1);
|
||||
std::cout << otr1 << std::endl;
|
||||
}
|
||||
{
|
||||
CGAL_PDB_NS::Protein lcpt1(cpt1);
|
||||
CGAL_PDB_NS::Transform otr2 = CGAL_PDB_NS::refine_alignment_of_second_protein_to_first(pt2, cpt1);
|
||||
std::cout << otr2 << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -1,82 +0,0 @@
|
|||
/* Copyright 2004
|
||||
Stanford University
|
||||
|
||||
This file is part of the DSR PDB Library.
|
||||
|
||||
The DSR PDB Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The DSR PDB Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the DSR PDB Library; see the file LICENSE.LGPL. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include <CGAL/PDB/PDB.h>
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
#include <CGAL/PDB/align.h>
|
||||
#include <CGAL/PDB/align.h>
|
||||
#include <CGAL/PDB/distance.h>
|
||||
#include <CGAL/PDB/Transform.h>
|
||||
|
||||
int main(int , char *[]){
|
||||
using namespace CGAL_PDB_NS;
|
||||
//dsr::Residue res= dsr::Residue(dsr::Residue::VAL);
|
||||
//res.write(std::cout);
|
||||
//assert(argc==2);
|
||||
std::ifstream in("data/check_protein.pdb");
|
||||
CGAL_PDB_NS::PDB p(in);
|
||||
|
||||
std::cout << "There are " << p.number_of_models() << " models." << std::endl;
|
||||
|
||||
for (unsigned int i=0; i< p.number_of_models(); ++i){
|
||||
const CGAL_PDB_NS::Model &m= p.model(i);
|
||||
std::cout << "Model " << i << " has " << m.number_of_chains() << " chains" << std::endl;
|
||||
for (unsigned int j=0; j< m.number_of_chains(); ++j){
|
||||
CGAL_PDB_NS::Protein p = m.chain(j);
|
||||
double rot[3][3]={{0.309976, 0.851651, -0.422618},
|
||||
{-0.741526, 0.494764, 0.453154},
|
||||
{0.595025, 0.172916, 0.78488}},
|
||||
trans[3]={4,5,6};
|
||||
CGAL_PDB_NS::Transform tr(rot, trans);
|
||||
std::cout << "tr is " << tr<< std::endl;
|
||||
for (CGAL_PDB_NS::Protein::Residues_iterator rit= p.residues_begin();
|
||||
rit != p.residues_end(); ++rit){
|
||||
for (CGAL_PDB_NS::Residue::Atoms_iterator ait= rit->atoms_begin();
|
||||
ait != rit->atoms_end(); ++ait){
|
||||
ait->second.set_cartesian_coords(tr(ait->second.cartesian_coords()));
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "iterated" << std::endl;
|
||||
std::vector<CGAL_PDB_NS::Point> pa, pp;
|
||||
CGAL_PDB_NS::backbone_coordinates(m.chain(j).atoms_begin(), m.chain(j).atoms_end(),
|
||||
std::back_inserter(pa));
|
||||
CGAL_PDB_NS::backbone_coordinates(p.atoms_begin(), p.atoms_end(),
|
||||
std::back_inserter(pp));
|
||||
std::cout << "m has " << pa.size() << " p has " << pp.size() << std::endl;
|
||||
CGAL_PDB_NS::Transform trp= CGAL_PDB_NS::transform_taking_first_to_second( pa, pp);
|
||||
std::cout << "trp is " << trp<< std::endl;
|
||||
|
||||
double mdiff=tr.error(trp);
|
||||
assert(mdiff<.1);
|
||||
|
||||
CGAL_PDB_NS::align_second_protein_to_first( m.chain(j), p);
|
||||
|
||||
double err= no_align_cRMS(m.chain(j), p);
|
||||
double ca_err= cRMS(m.chain(j), p);
|
||||
assert(err < 1e-5);
|
||||
std::cout << err << " " << ca_err << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
#include <CGAL/PDB/Transform.h>
|
||||
#include <CGAL/PDB/Quaternion.h>
|
||||
#include <iostream>
|
||||
|
||||
int main(int, char *[]){
|
||||
CGAL::PDB::Quaternion q(CGAL::PDB::Vector(0,1,1), .3);
|
||||
//std::cout << q << std::endl;
|
||||
CGAL::PDB::Transform t(CGAL::PDB::Vector(0,0,1), q);
|
||||
//std::cout << t << std::endl;
|
||||
CGAL::PDB::Quaternion qt=t.quaternion();
|
||||
//std::cout << qt << std::endl;
|
||||
|
||||
double diff=0;
|
||||
for (unsigned int i=0; i< 4; ++i){
|
||||
diff += (q[i]-qt[i])*(q[i]-qt[i]);
|
||||
}
|
||||
CGAL_assertion(diff < .1);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -1,91 +0,0 @@
|
|||
HEADER BETA SHEET FROM 2CI2
|
||||
ATOM 354 N GLN I 47 13.808 -22.469 14.161 1.00 15.12 2CI2 330
|
||||
ATOM 355 CA GLN I 47 13.934 -21.079 14.630 1.00 15.59 2CI2 331
|
||||
ATOM 356 C GLN I 47 12.529 -20.488 14.404 1.00 14.48 2CI2 332
|
||||
ATOM 357 O GLN I 47 12.125 -20.297 13.255 1.00 15.43 2CI2 333
|
||||
ATOM 358 CB GLN I 47 15.042 -20.280 13.971 1.00 14.57 2CI2 334
|
||||
ATOM 359 CG GLN I 47 16.441 -20.754 14.352 1.00 20.31 2CI2 335
|
||||
ATOM 360 CD GLN I 47 16.787 -20.674 15.818 1.00 20.92 2CI2 336
|
||||
ATOM 361 OE1 GLN I 47 16.587 -19.708 16.552 1.00 22.99 2CI2 337
|
||||
ATOM 362 NE2 GLN I 47 17.380 -21.750 16.340 1.00 26.19 2CI2 338
|
||||
ATOM 363 N ILE I 48 11.802 -20.339 15.498 1.00 16.27 2CI2 339
|
||||
ATOM 364 CA ILE I 48 10.406 -19.875 15.481 1.00 15.80 2CI2 340
|
||||
ATOM 365 C ILE I 48 10.296 -18.353 15.480 1.00 15.66 2CI2 341
|
||||
ATOM 366 O ILE I 48 10.807 -17.686 16.389 1.00 15.96 2CI2 342
|
||||
ATOM 367 CB ILE I 48 9.587 -20.549 16.640 1.00 17.30 2CI2 343
|
||||
ATOM 368 CG1 ILE I 48 9.667 -22.092 16.476 1.00 16.79 2CI2 344
|
||||
ATOM 369 CG2 ILE I 48 8.112 -20.079 16.733 1.00 15.04 2CI2 345
|
||||
ATOM 370 CD1 ILE I 48 9.075 -22.874 17.679 1.00 21.73 2CI2 346
|
||||
ATOM 371 N ILE I 49 9.612 -17.862 14.459 1.00 14.44 2CI2 347
|
||||
ATOM 372 CA ILE I 49 9.350 -16.429 14.248 1.00 12.51 2CI2 348
|
||||
ATOM 373 C ILE I 49 7.835 -16.209 14.313 1.00 10.43 2CI2 349
|
||||
ATOM 374 O ILE I 49 7.073 -16.959 13.687 1.00 12.52 2CI2 350
|
||||
ATOM 375 CB ILE I 49 9.962 -15.963 12.882 1.00 13.39 2CI2 351
|
||||
ATOM 376 CG1 ILE I 49 11.499 -16.164 12.865 1.00 15.31 2CI2 352
|
||||
ATOM 377 CG2 ILE I 49 9.580 -14.515 12.488 1.00 8.33 2CI2 353
|
||||
ATOM 378 CD1 ILE I 49 12.287 -15.564 14.052 1.00 12.08 2CI2 354
|
||||
ATOM 379 N VAL I 50 7.424 -15.222 15.077 1.00 9.95 2CI2 355
|
||||
ATOM 380 CA VAL I 50 6.021 -14.883 15.315 1.00 9.48 2CI2 356
|
||||
ATOM 381 C VAL I 50 5.676 -13.527 14.695 1.00 11.08 2CI2 357
|
||||
ATOM 382 O VAL I 50 6.168 -12.524 15.236 1.00 11.22 2CI2 358
|
||||
ATOM 383 CB VAL I 50 5.781 -14.853 16.844 1.00 11.04 2CI2 359
|
||||
ATOM 384 CG1 VAL I 50 4.377 -14.381 17.212 1.00 12.78 2CI2 360
|
||||
ATOM 385 CG2 VAL I 50 6.099 -16.175 17.517 1.00 13.08 2CI2 361
|
||||
ATOM 386 N LEU I 51 4.861 -13.525 13.658 1.00 10.84 2CI2 362
|
||||
ATOM 387 CA LEU I 51 4.434 -12.286 13.006 1.00 7.63 2CI2 363
|
||||
ATOM 388 C LEU I 51 2.903 -12.192 12.917 1.00 8.35 2CI2 364
|
||||
ATOM 389 O LEU I 51 2.209 -13.209 12.829 1.00 7.78 2CI2 365
|
||||
ATOM 390 CB LEU I 51 5.085 -12.267 11.629 1.00 6.43 2CI2 366
|
||||
ATOM 391 CG LEU I 51 6.571 -12.463 11.463 1.00 12.23 2CI2 367
|
||||
ATOM 392 CD1 LEU I 51 6.895 -12.729 9.987 1.00 11.51 2CI2 368
|
||||
ATOM 393 CD2 LEU I 51 7.308 -11.208 11.927 1.00 10.52 2CI2 369
|
||||
ATOM 497 N ARG I 65 13.870 -22.315 9.663 1.00 11.64 2CI2 473
|
||||
ATOM 498 CA ARG I 65 12.918 -21.309 10.141 1.00 12.51 2CI2 474
|
||||
ATOM 499 C ARG I 65 11.453 -21.716 10.025 1.00 12.85 2CI2 475
|
||||
ATOM 500 O ARG I 65 11.074 -22.245 8.974 1.00 12.01 2CI2 476
|
||||
ATOM 501 CB ARG I 65 13.130 -20.016 9.321 1.00 10.70 2CI2 477
|
||||
ATOM 502 CG ARG I 65 12.169 -18.890 9.687 1.00 14.03 2CI2 478
|
||||
ATOM 503 CD ARG I 65 12.644 -17.542 9.266 1.00 11.51 2CI2 479
|
||||
ATOM 504 NE ARG I 65 12.674 -17.387 7.831 1.00 15.20 2CI2 480
|
||||
ATOM 505 CZ ARG I 65 13.460 -16.613 7.090 1.00 15.39 2CI2 481
|
||||
ATOM 506 NH1 ARG I 65 14.340 -15.768 7.596 1.00 17.74 2CI2 482
|
||||
ATOM 507 NH2 ARG I 65 13.389 -16.713 5.764 1.00 16.07 2CI2 483
|
||||
ATOM 508 N VAL I 66 10.685 -21.359 11.050 1.00 10.71 2CI2 484
|
||||
ATOM 509 CA VAL I 66 9.240 -21.555 11.079 1.00 13.23 2CI2 485
|
||||
ATOM 510 C VAL I 66 8.541 -20.253 11.517 1.00 12.86 2CI2 486
|
||||
ATOM 511 O VAL I 66 8.570 -19.906 12.710 1.00 16.02 2CI2 487
|
||||
ATOM 512 CB VAL I 66 8.740 -22.721 11.951 1.00 11.53 2CI2 488
|
||||
ATOM 513 CG1 VAL I 66 7.216 -22.881 11.850 1.00 11.98 2CI2 489
|
||||
ATOM 514 CG2 VAL I 66 9.420 -24.045 11.659 1.00 13.94 2CI2 490
|
||||
ATOM 515 N ARG I 67 7.886 -19.619 10.566 1.00 9.65 2CI2 491
|
||||
ATOM 516 CA ARG I 67 7.130 -18.389 10.853 1.00 10.83 2CI2 492
|
||||
ATOM 517 C ARG I 67 5.717 -18.746 11.304 1.00 7.13 2CI2 493
|
||||
ATOM 518 O ARG I 67 5.057 -19.492 10.560 1.00 9.94 2CI2 494
|
||||
ATOM 519 CB ARG I 67 7.001 -17.538 9.570 1.00 11.98 2CI2 495
|
||||
ATOM 520 CG ARG I 67 8.290 -16.786 9.175 1.00 11.30 2CI2 496
|
||||
ATOM 521 CD ARG I 67 8.099 -16.286 7.796 1.00 15.42 2CI2 497
|
||||
ATOM 522 NE ARG I 67 9.218 -15.651 7.158 1.00 26.19 2CI2 498
|
||||
ATOM 523 CZ ARG I 67 9.598 -15.877 5.897 1.00 23.69 2CI2 499
|
||||
ATOM 524 NH1 ARG I 67 8.987 -16.777 5.135 1.00 25.11 2CI2 500
|
||||
ATOM 525 NH2 ARG I 67 10.603 -15.150 5.399 1.00 32.20 2CI2 501
|
||||
ATOM 526 N LEU I 68 5.264 -18.178 12.388 1.00 5.51 2CI2 502
|
||||
ATOM 527 CA LEU I 68 3.881 -18.326 12.864 1.00 7.63 2CI2 503
|
||||
ATOM 528 C LEU I 68 3.149 -17.004 12.584 1.00 6.35 2CI2 504
|
||||
ATOM 529 O LEU I 68 3.629 -15.965 13.056 1.00 8.97 2CI2 505
|
||||
ATOM 530 CB LEU I 68 3.893 -18.673 14.353 1.00 6.88 2CI2 506
|
||||
ATOM 531 CG LEU I 68 4.586 -19.961 14.774 1.00 11.18 2CI2 507
|
||||
ATOM 532 CD1 LEU I 68 4.451 -20.213 16.270 1.00 2.78 2CI2 508
|
||||
ATOM 533 CD2 LEU I 68 3.981 -21.071 13.922 1.00 10.53 2CI2 509
|
||||
ATOM 534 N PHE I 69 2.068 -17.071 11.845 1.00 5.58 2CI2 510
|
||||
ATOM 535 CA PHE I 69 1.254 -15.871 11.532 1.00 5.54 2CI2 511
|
||||
ATOM 536 C PHE I 69 0.064 -15.898 12.493 1.00 6.41 2CI2 512
|
||||
ATOM 537 O PHE I 69 -0.788 -16.799 12.467 1.00 7.94 2CI2 513
|
||||
ATOM 538 CB PHE I 69 0.923 -15.768 10.047 1.00 5.59 2CI2 514
|
||||
ATOM 539 CG PHE I 69 2.063 -15.303 9.185 1.00 12.09 2CI2 515
|
||||
ATOM 540 CD1 PHE I 69 2.924 -16.230 8.593 1.00 13.33 2CI2 516
|
||||
ATOM 541 CD2 PHE I 69 2.299 -13.936 8.992 1.00 10.83 2CI2 517
|
||||
ATOM 542 CE1 PHE I 69 4.008 -15.811 7.835 1.00 13.21 2CI2 518
|
||||
ATOM 543 CE2 PHE I 69 3.384 -13.491 8.239 1.00 11.69 2CI2 519
|
||||
ATOM 544 CZ PHE I 69 4.229 -14.445 7.653 1.00 11.95 2CI2 520
|
||||
MASTER 0 0 0 0 0 0 0 0 0 0 0 0 2CI2 693
|
||||
END 2CI2 694
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -1,692 +0,0 @@
|
|||
HEADER PROTEINASE INHIBITOR (CHYMOTRYPSIN) 05-SEP-88 2CI2 2CI2 3
|
||||
COMPND CHYMOTRYPSIN INHIBITOR 2 (/CI$-2) 2CI2 4
|
||||
SOURCE BARLEY (HORDEUM $VULGARE, HIPROLY STRAIN) SEEDS 2CI2 5
|
||||
AUTHOR C.A.MC*PHALEN,M.N.G.JAMES 2CI2 6
|
||||
REVDAT 1 07-SEP-88 2CI2 0 2CI2 7
|
||||
JRNL AUTH C.A.MC*PHALEN,M.N.G.JAMES 2CI2 8
|
||||
JRNL TITL CRYSTAL AND MOLECULAR STRUCTURE OF THE SERINE 2CI2 9
|
||||
JRNL TITL 2 PROTEINASE INHIBITOR /CI$-2 FROM BARLEY SEEDS 2CI2 10
|
||||
JRNL REF BIOCHEMISTRY V. 26 261 1987 2CI2 11
|
||||
JRNL REFN ASTM BICHAW US ISSN 0006-2960 033 2CI2 12
|
||||
REMARK 1 2CI2 13
|
||||
REMARK 1 REFERENCE 1 2CI2 14
|
||||
REMARK 1 AUTH G.M.CLORE,A.M.GRONENBORN,M.N.G.JAMES,M.KJAER, 2CI2 15
|
||||
REMARK 1 AUTH 2 C.A.MC*PHALEN,F.M.POULSEN 2CI2 16
|
||||
REMARK 1 TITL COMPARISON OF THE SOLUTION AND X-RAY STRUCTURES OF 2CI2 17
|
||||
REMARK 1 TITL 2 BARLEY SERINE PROTEINASE INHIBITOR 2 2CI2 18
|
||||
REMARK 1 REF PROTEIN ENG. V. 1 313 1987 2CI2 19
|
||||
REMARK 1 REFN ASTM PRENE9 UK ISSN 0269-2139 859 2CI2 20
|
||||
REMARK 1 REFERENCE 2 2CI2 21
|
||||
REMARK 1 AUTH C.A.MC*PHALEN,I.SVENDSEN,I.JONASSEN,M.N.G.JAMES 2CI2 22
|
||||
REMARK 1 TITL CRYSTAL AND MOLECULAR STRUCTURE OF CHYMOTRYPSIN 2CI2 23
|
||||
REMARK 1 TITL 2 INHIBITOR 2 FROM BARLEY SEEDS IN COMPLEX WITH 2CI2 24
|
||||
REMARK 1 TITL 3 SUBTILISIN NOVO 2CI2 25
|
||||
REMARK 1 REF PROC.NAT.ACAD.SCI.USA V. 82 7242 1985 2CI2 26
|
||||
REMARK 1 REFN ASTM PNASA6 US ISSN 0027-8424 040 2CI2 27
|
||||
REMARK 1 REFERENCE 3 2CI2 28
|
||||
REMARK 1 AUTH C.A.MC*PHALEN,C.EVANS,K.HAYAKAWA,I.JONASSEN, 2CI2 29
|
||||
REMARK 1 AUTH 2 I.SVENDSEN,M.N.G.JAMES 2CI2 30
|
||||
REMARK 1 TITL PRELIMINARY CRYSTALLOGRAPHIC DATA FOR THE SERINE 2CI2 31
|
||||
REMARK 1 TITL 2 PROTEASE INHIBITOR /CI$-2 FROM BARLEY SEEDS 2CI2 32
|
||||
REMARK 1 REF J.MOL.BIOL. V. 168 445 1983 2CI2 33
|
||||
REMARK 1 REFN ASTM JMOBAK UK ISSN 0022-2836 070 2CI2 34
|
||||
REMARK 2 2CI2 35
|
||||
REMARK 2 RESOLUTION. 2.0 ANGSTROMS. 2CI2 36
|
||||
REMARK 3 2CI2 37
|
||||
REMARK 3 REFINEMENT. BY THE RESTRAINED LEAST SQUARES PROCEDURE OF J. 2CI2 38
|
||||
REMARK 3 KONNERT AND. W. HENDRICKSON (PROGRAM *PROLSQ*). THE R 2CI2 39
|
||||
REMARK 3 VALUE IS 0.198 FOR DATA IN THE RESOLUTION RANGE 8.0 TO 2.0 2CI2 40
|
||||
REMARK 3 ANGSTROMS WITH I .GT. SIGMA(I). 2CI2 41
|
||||
REMARK 3 2CI2 42
|
||||
REMARK 3 NUMBER OF PROTEIN ATOMS 521 2CI2 43
|
||||
REMARK 3 NUMBER OF SOLVENT ATOMS 64 2CI2 44
|
||||
REMARK 3 NUMBER OF VARIABLE PARAMETERS 2405 2CI2 45
|
||||
REMARK 3 RMS DEVIATIONS FROM IDEAL VALUES (THE VALUES OF 2CI2 46
|
||||
REMARK 3 SIGMA, IN PARENTHESES, ARE THE INPUT ESTIMATED 2CI2 47
|
||||
REMARK 3 STANDARD DEVIATIONS THAT DETERMINE THE RELATIVE 2CI2 48
|
||||
REMARK 3 WEIGHTS OF THE CORRESPONDING RESTRAINTS) 2CI2 49
|
||||
REMARK 3 DISTANCE RESTRAINTS (ANGSTROMS) 2CI2 50
|
||||
REMARK 3 BOND DISTANCE 0.007(0.008) 2CI2 51
|
||||
REMARK 3 ANGLE DISTANCE 0.029(0.016) 2CI2 52
|
||||
REMARK 3 PLANAR 1-4 DISTANCE 0.021(0.016) 2CI2 53
|
||||
REMARK 3 PLANE RESTRAINT (ANGSTROMS) 0.014(0.012) 2CI2 54
|
||||
REMARK 3 CHIRAL-CENTER RESTRAINT (ANGSTROMS**3) 0.123(0.080) 2CI2 55
|
||||
REMARK 3 NON-BONDED CONTACT RESTRAINTS (ANGSTROMS) 2CI2 56
|
||||
REMARK 3 SINGLE TORSION CONTACT 0.297(0.400) 2CI2 57
|
||||
REMARK 3 MULTIPLE TORSION CONTACT 0.276(0.400) 2CI2 58
|
||||
REMARK 3 POSSIBLE HYDROGEN BOND 0.240(0.400) 2CI2 59
|
||||
REMARK 3 CONFORMATIONAL TORSION ANGLE RESTRAINT (DEGREES) 2CI2 60
|
||||
REMARK 3 PLANAR (OMEGA) 3.0(2.8) 2CI2 61
|
||||
REMARK 3 ISOTROPIC THERMAL FACTOR RESTRAINTS (ANGSTROMS**2) 2CI2 62
|
||||
REMARK 3 MAIN-CHAIN BOND 1.956(2.000) 2CI2 63
|
||||
REMARK 3 MAIN-CHAIN ANGLE 2.909(2.000) 2CI2 64
|
||||
REMARK 3 SIDE-CHAIN BOND 3.611(3.000) 2CI2 65
|
||||
REMARK 3 SIDE-CHAIN ANGLE 5.285(3.000) 2CI2 66
|
||||
REMARK 4 2CI2 67
|
||||
REMARK 4 NO ELECTRON DENSITY WAS SEEN FOR RESIDUES 1 THROUGH 18 IN 2CI2 68
|
||||
REMARK 4 FOURIER MAPS AT ANY STAGE OF REFINEMENT. IT IS LIKELY THAT 2CI2 69
|
||||
REMARK 4 THE FIRST 18 RESIDUES OF CI-2 ARE NOT PRESENT IN THE 2CI2 70
|
||||
REMARK 4 CRYSTALLIZED INHIBITOR. SEE THE REFERENCE CITED ON THE 2CI2 71
|
||||
REMARK 4 *JRNL* RECORDS ABOVE FOR DETAILS. 2CI2 72
|
||||
REMARK 5 2CI2 73
|
||||
REMARK 5 THE ORDER OF THE FIRST FOUR RESIDUES PRESENTED ON THE 2CI2 74
|
||||
REMARK 5 *SEQRES* RECORDS BELOW IS UNKNOWN. 2CI2 75
|
||||
REMARK 6 2CI2 76
|
||||
REMARK 6 THE SHEET SPECIFIED BELOW IS AN IRREGULAR SHEET. ALL BUT 2CI2 77
|
||||
REMARK 6 ONE HYDROGEN BOND BETWEEN STRANDS 2 AND 3 ARE PROVIDED BY 2CI2 78
|
||||
REMARK 6 BRIDGING WATER MOLECULES. SEE THE REFERENCE CITED ON THE 2CI2 79
|
||||
REMARK 6 *JRNL* RECORDS ABOVE FOR DETAILS. 2CI2 80
|
||||
SEQRES 1 I 83 GLX VAL SER SER LYS LYS PRO GLU GLY VAL ASN THR GLY 2CI2 81
|
||||
SEQRES 2 I 83 ALA GLY ASP ARG HIS ASN LEU LYS THR GLU TRP PRO GLU 2CI2 82
|
||||
SEQRES 3 I 83 LEU VAL GLY LYS SER VAL GLU GLU ALA LYS LYS VAL ILE 2CI2 83
|
||||
SEQRES 4 I 83 LEU GLN ASP LYS PRO GLU ALA GLN ILE ILE VAL LEU PRO 2CI2 84
|
||||
SEQRES 5 I 83 VAL GLY THR ILE VAL THR MET GLU TYR ARG ILE ASP ARG 2CI2 85
|
||||
SEQRES 6 I 83 VAL ARG LEU PHE VAL ASP LYS LEU ASP ASN ILE ALA GLU 2CI2 86
|
||||
SEQRES 7 I 83 VAL PRO ARG VAL GLY 2CI2 87
|
||||
FORMUL 2 HOH *64(H2 O1) 2CI2 88
|
||||
HELIX 1 A SER I 31 LYS I 43 1 2CI2 89
|
||||
SHEET 1 S1 4 THR I 22 TRP I 24 0 2CI2 90
|
||||
SHEET 2 S1 4 PRO I 80 GLY I 83 -1 N VAL I 82 O THR I 22 2CI2 91
|
||||
SHEET 3 S1 4 ASP I 64 ASP I 71 -1 O ARG I 65 N GLY I 83 2CI2 92
|
||||
SHEET 4 S1 4 GLN I 47 VAL I 53 1 N GLN I 47 O ASP I 64 2CI2 93
|
||||
TURN 1 T1 TRP I 24 LEU I 27 2CI2 94
|
||||
TURN 2 T2 LEU I 27 LYS I 30 2CI2 95
|
||||
TURN 3 T3 LYS I 43 ALA I 46 2CI2 96
|
||||
TURN 4 T4 ARG I 62 ARG I 65 2CI2 97
|
||||
TURN 5 T5 ASP I 71 ASP I 74 2CI2 98
|
||||
SITE 1 RSB 2 MET I 59 GLU I 60 2CI2 99
|
||||
CRYST1 69.015 69.015 52.890 90.00 90.00 120.00 P 6 2 2 12 2CI2 100
|
||||
ORIGX1 0.014490 0.008366 0.000000 0.00000 2CI2 101
|
||||
ORIGX2 0.000000 0.016731 0.000000 0.00000 2CI2 102
|
||||
ORIGX3 0.000000 0.000000 0.018907 0.00000 2CI2 103
|
||||
SCALE1 0.014490 0.008366 0.000000 0.00000 2CI2 104
|
||||
SCALE2 0.000000 0.016731 0.000000 0.00000 2CI2 105
|
||||
SCALE3 0.000000 0.000000 0.018907 0.00000 2CI2 106
|
||||
ATOM 131 N ASN I 19 13.270 -37.510 4.242 1.00 57.52 2CI2 107
|
||||
ATOM 132 CA ASN I 19 11.912 -37.066 4.598 1.00 57.72 2CI2 108
|
||||
ATOM 133 C ASN I 19 11.944 -35.563 4.896 1.00 57.15 2CI2 109
|
||||
ATOM 134 O ASN I 19 12.868 -34.849 4.470 1.00 57.88 2CI2 110
|
||||
ATOM 135 CB ASN I 19 11.343 -37.905 5.734 1.00 60.98 2CI2 111
|
||||
ATOM 136 CG ASN I 19 12.005 -39.260 5.880 1.00 63.99 2CI2 112
|
||||
ATOM 137 OD1 ASN I 19 11.372 -40.233 6.316 1.00 66.43 2CI2 113
|
||||
ATOM 138 ND2 ASN I 19 13.283 -39.348 5.517 1.00 65.02 2CI2 114
|
||||
ATOM 139 N LEU I 20 10.919 -35.133 5.612 1.00 55.25 2CI2 115
|
||||
ATOM 140 CA LEU I 20 10.764 -33.739 6.038 1.00 50.58 2CI2 116
|
||||
ATOM 141 C LEU I 20 9.309 -33.373 6.344 1.00 47.16 2CI2 117
|
||||
ATOM 142 O LEU I 20 8.391 -33.655 5.556 1.00 45.57 2CI2 118
|
||||
ATOM 143 CB LEU I 20 11.424 -32.834 4.989 1.00 50.13 2CI2 119
|
||||
ATOM 144 CG LEU I 20 12.284 -31.692 5.507 1.00 50.99 2CI2 120
|
||||
ATOM 145 CD1 LEU I 20 13.117 -32.121 6.709 1.00 49.77 2CI2 121
|
||||
ATOM 146 CD2 LEU I 20 13.188 -31.215 4.370 1.00 52.95 2CI2 122
|
||||
ATOM 147 N LYS I 21 9.142 -32.770 7.517 1.00 42.72 2CI2 123
|
||||
ATOM 148 CA LYS I 21 7.845 -32.224 7.934 1.00 37.90 2CI2 124
|
||||
ATOM 149 C LYS I 21 8.045 -30.702 7.777 1.00 34.37 2CI2 125
|
||||
ATOM 150 O LYS I 21 8.932 -30.143 8.433 1.00 34.11 2CI2 126
|
||||
ATOM 151 CB LYS I 21 7.274 -32.526 9.297 1.00 35.30 2CI2 127
|
||||
ATOM 152 CG LYS I 21 5.763 -32.219 9.350 1.00 27.47 2CI2 128
|
||||
ATOM 153 CD LYS I 21 5.184 -32.467 10.728 1.00 28.32 2CI2 129
|
||||
ATOM 154 CE LYS I 21 3.676 -32.404 10.770 1.00 24.21 2CI2 130
|
||||
ATOM 155 NZ LYS I 21 3.194 -32.365 12.180 1.00 25.08 2CI2 131
|
||||
ATOM 156 N THR I 22 7.264 -30.158 6.866 1.00 31.34 2CI2 132
|
||||
ATOM 157 CA THR I 22 7.394 -28.744 6.505 1.00 27.32 2CI2 133
|
||||
ATOM 158 C THR I 22 6.144 -27.915 6.711 1.00 25.34 2CI2 134
|
||||
ATOM 159 O THR I 22 6.231 -26.683 6.537 1.00 24.28 2CI2 135
|
||||
ATOM 160 CB THR I 22 7.880 -28.674 4.996 1.00 25.48 2CI2 136
|
||||
ATOM 161 OG1 THR I 22 6.848 -29.388 4.246 1.00 25.70 2CI2 137
|
||||
ATOM 162 CG2 THR I 22 9.269 -29.293 4.817 1.00 27.40 2CI2 138
|
||||
ATOM 163 N GLU I 23 5.058 -28.574 7.079 1.00 23.62 2CI2 139
|
||||
ATOM 164 CA GLU I 23 3.798 -27.838 7.306 1.00 19.26 2CI2 140
|
||||
ATOM 165 C GLU I 23 2.991 -28.448 8.428 1.00 17.05 2CI2 141
|
||||
ATOM 166 O GLU I 23 2.997 -29.675 8.600 1.00 15.10 2CI2 142
|
||||
ATOM 167 CB GLU I 23 3.010 -27.695 6.045 1.00 23.29 2CI2 143
|
||||
ATOM 168 CG GLU I 23 2.195 -28.851 5.463 1.00 29.02 2CI2 144
|
||||
ATOM 169 CD GLU I 23 1.517 -28.258 4.241 1.00 33.08 2CI2 145
|
||||
ATOM 170 OE1 GLU I 23 2.221 -27.701 3.413 1.00 37.10 2CI2 146
|
||||
ATOM 171 OE2 GLU I 23 0.282 -28.290 4.322 1.00 39.26 2CI2 147
|
||||
ATOM 172 N TRP I 24 2.377 -27.565 9.190 1.00 14.26 2CI2 148
|
||||
ATOM 173 CA TRP I 24 1.619 -27.918 10.393 1.00 16.19 2CI2 149
|
||||
ATOM 174 C TRP I 24 0.164 -27.440 10.332 1.00 16.38 2CI2 150
|
||||
ATOM 175 O TRP I 24 -0.271 -26.673 11.204 1.00 16.67 2CI2 151
|
||||
ATOM 176 CB TRP I 24 2.335 -27.417 11.654 1.00 13.74 2CI2 152
|
||||
ATOM 177 CG TRP I 24 3.612 -28.094 12.010 1.00 17.24 2CI2 153
|
||||
ATOM 178 CD1 TRP I 24 3.795 -29.111 12.912 1.00 16.31 2CI2 154
|
||||
ATOM 179 CD2 TRP I 24 4.910 -27.835 11.449 1.00 14.54 2CI2 155
|
||||
ATOM 180 NE1 TRP I 24 5.111 -29.494 12.944 1.00 14.15 2CI2 156
|
||||
ATOM 181 CE2 TRP I 24 5.815 -28.737 12.055 1.00 15.43 2CI2 157
|
||||
ATOM 182 CE3 TRP I 24 5.370 -26.963 10.472 1.00 14.87 2CI2 158
|
||||
ATOM 183 CZ2 TRP I 24 7.168 -28.754 11.745 1.00 16.89 2CI2 159
|
||||
ATOM 184 CZ3 TRP I 24 6.711 -26.976 10.148 1.00 14.60 2CI2 160
|
||||
ATOM 185 CH2 TRP I 24 7.592 -27.859 10.769 1.00 17.78 2CI2 161
|
||||
ATOM 186 N PRO I 25 -0.557 -27.946 9.346 1.00 19.10 2CI2 162
|
||||
ATOM 187 CA PRO I 25 -1.975 -27.643 9.147 1.00 18.76 2CI2 163
|
||||
ATOM 188 C PRO I 25 -2.813 -27.859 10.394 1.00 19.70 2CI2 164
|
||||
ATOM 189 O PRO I 25 -3.818 -27.153 10.578 1.00 21.19 2CI2 165
|
||||
ATOM 190 CB PRO I 25 -2.427 -28.583 8.029 1.00 20.05 2CI2 166
|
||||
ATOM 191 CG PRO I 25 -1.359 -29.647 7.975 1.00 19.41 2CI2 167
|
||||
ATOM 192 CD PRO I 25 -0.074 -28.903 8.326 1.00 18.83 2CI2 168
|
||||
ATOM 193 N GLU I 26 -2.423 -28.821 11.209 1.00 20.43 2CI2 169
|
||||
ATOM 194 CA GLU I 26 -3.144 -29.188 12.429 1.00 19.22 2CI2 170
|
||||
ATOM 195 C GLU I 26 -3.049 -28.085 13.478 1.00 19.21 2CI2 171
|
||||
ATOM 196 O GLU I 26 -3.689 -28.202 14.531 1.00 21.13 2CI2 172
|
||||
ATOM 197 CB GLU I 26 -2.567 -30.438 13.098 1.00 22.19 2CI2 173
|
||||
ATOM 198 CG GLU I 26 -1.177 -30.335 13.745 1.00 21.65 2CI2 174
|
||||
ATOM 199 CD GLU I 26 -0.044 -30.775 12.862 1.00 20.90 2CI2 175
|
||||
ATOM 200 OE1 GLU I 26 -0.080 -30.647 11.658 1.00 14.10 2CI2 176
|
||||
ATOM 201 OE2 GLU I 26 0.922 -31.309 13.445 1.00 24.93 2CI2 177
|
||||
ATOM 202 N LEU I 27 -2.238 -27.086 13.191 1.00 17.70 2CI2 178
|
||||
ATOM 203 CA LEU I 27 -1.984 -26.008 14.143 1.00 16.78 2CI2 179
|
||||
ATOM 204 C LEU I 27 -2.874 -24.787 14.000 1.00 14.89 2CI2 180
|
||||
ATOM 205 O LEU I 27 -2.836 -24.019 14.989 1.00 15.43 2CI2 181
|
||||
ATOM 206 CB LEU I 27 -0.479 -25.685 14.144 1.00 18.14 2CI2 182
|
||||
ATOM 207 CG LEU I 27 0.431 -26.695 14.831 1.00 20.69 2CI2 183
|
||||
ATOM 208 CD1 LEU I 27 1.887 -26.248 14.756 1.00 23.78 2CI2 184
|
||||
ATOM 209 CD2 LEU I 27 -0.001 -26.836 16.287 1.00 18.89 2CI2 185
|
||||
ATOM 210 N VAL I 28 -3.593 -24.621 12.902 1.00 14.14 2CI2 186
|
||||
ATOM 211 CA VAL I 28 -4.454 -23.429 12.783 1.00 12.54 2CI2 187
|
||||
ATOM 212 C VAL I 28 -5.403 -23.380 13.979 1.00 13.06 2CI2 188
|
||||
ATOM 213 O VAL I 28 -6.045 -24.383 14.320 1.00 14.30 2CI2 189
|
||||
ATOM 214 CB VAL I 28 -5.161 -23.338 11.436 1.00 14.01 2CI2 190
|
||||
ATOM 215 CG1 VAL I 28 -6.027 -22.075 11.346 1.00 14.05 2CI2 191
|
||||
ATOM 216 CG2 VAL I 28 -4.190 -23.415 10.264 1.00 13.54 2CI2 192
|
||||
ATOM 217 N GLY I 29 -5.433 -22.237 14.631 1.00 12.49 2CI2 193
|
||||
ATOM 218 CA GLY I 29 -6.293 -21.956 15.772 1.00 12.66 2CI2 194
|
||||
ATOM 219 C GLY I 29 -5.701 -22.103 17.154 1.00 13.68 2CI2 195
|
||||
ATOM 220 O GLY I 29 -6.272 -21.579 18.129 1.00 12.22 2CI2 196
|
||||
ATOM 221 N LYS I 30 -4.604 -22.822 17.248 1.00 12.70 2CI2 197
|
||||
ATOM 222 CA LYS I 30 -3.896 -23.079 18.506 1.00 14.92 2CI2 198
|
||||
ATOM 223 C LYS I 30 -3.027 -21.887 18.909 1.00 13.30 2CI2 199
|
||||
ATOM 224 O LYS I 30 -2.670 -21.045 18.078 1.00 14.33 2CI2 200
|
||||
ATOM 225 CB LYS I 30 -3.026 -24.330 18.393 1.00 17.67 2CI2 201
|
||||
ATOM 226 CG LYS I 30 -3.741 -25.495 17.710 1.00 22.39 2CI2 202
|
||||
ATOM 227 CD LYS I 30 -3.498 -26.806 18.425 1.00 23.93 2CI2 203
|
||||
ATOM 228 CE LYS I 30 -4.686 -27.741 18.363 1.00 31.09 2CI2 204
|
||||
ATOM 229 NZ LYS I 30 -5.641 -27.360 17.290 1.00 34.91 2CI2 205
|
||||
ATOM 230 N SER I 31 -2.722 -21.833 20.192 1.00 14.78 2CI2 206
|
||||
ATOM 231 CA SER I 31 -1.879 -20.773 20.760 1.00 15.00 2CI2 207
|
||||
ATOM 232 C SER I 31 -0.441 -20.978 20.273 1.00 15.62 2CI2 208
|
||||
ATOM 233 O SER I 31 -0.049 -22.057 19.812 1.00 15.37 2CI2 209
|
||||
ATOM 234 CB SER I 31 -1.962 -20.751 22.276 1.00 14.91 2CI2 210
|
||||
ATOM 235 OG SER I 31 -1.076 -21.705 22.833 1.00 15.27 2CI2 211
|
||||
ATOM 236 N VAL I 32 0.300 -19.886 20.370 1.00 18.52 2CI2 212
|
||||
ATOM 237 CA VAL I 32 1.717 -19.835 20.003 1.00 16.46 2CI2 213
|
||||
ATOM 238 C VAL I 32 2.491 -20.764 20.945 1.00 16.12 2CI2 214
|
||||
ATOM 239 O VAL I 32 3.425 -21.427 20.495 1.00 16.39 2CI2 215
|
||||
ATOM 240 CB VAL I 32 2.268 -18.404 19.983 1.00 20.13 2CI2 216
|
||||
ATOM 241 CG1 VAL I 32 3.770 -18.408 20.295 1.00 22.99 2CI2 217
|
||||
ATOM 242 CG2 VAL I 32 2.032 -17.676 18.666 1.00 17.66 2CI2 218
|
||||
ATOM 243 N GLU I 33 2.078 -20.829 22.191 1.00 17.43 2CI2 219
|
||||
ATOM 244 CA GLU I 33 2.701 -21.664 23.222 1.00 19.39 2CI2 220
|
||||
ATOM 245 C GLU I 33 2.559 -23.138 22.851 1.00 20.42 2CI2 221
|
||||
ATOM 246 O GLU I 33 3.544 -23.906 22.774 1.00 20.10 2CI2 222
|
||||
ATOM 247 CB GLU I 33 2.121 -21.375 24.591 1.00 28.51 2CI2 223
|
||||
ATOM 248 CG GLU I 33 1.282 -20.147 24.847 1.00 41.74 2CI2 224
|
||||
ATOM 249 CD GLU I 33 1.059 -19.037 23.883 1.00 45.30 2CI2 225
|
||||
ATOM 250 OE1 GLU I 33 0.148 -18.217 23.941 1.00 46.73 2CI2 226
|
||||
ATOM 251 OE2 GLU I 33 1.912 -18.948 22.970 1.00 53.43 2CI2 227
|
||||
ATOM 252 N GLU I 34 1.326 -23.515 22.545 1.00 18.24 2CI2 228
|
||||
ATOM 253 CA GLU I 34 0.995 -24.867 22.108 1.00 17.75 2CI2 229
|
||||
ATOM 254 C GLU I 34 1.750 -25.158 20.810 1.00 18.11 2CI2 230
|
||||
ATOM 255 O GLU I 34 2.423 -26.201 20.740 1.00 20.56 2CI2 231
|
||||
ATOM 256 CB GLU I 34 -0.482 -25.120 21.881 1.00 20.05 2CI2 232
|
||||
ATOM 257 CG GLU I 34 -1.533 -24.790 22.925 1.00 26.42 2CI2 233
|
||||
ATOM 258 CD GLU I 34 -2.967 -25.103 22.598 1.00 29.37 2CI2 234
|
||||
ATOM 259 OE1 GLU I 34 -3.455 -26.226 22.649 1.00 31.64 2CI2 235
|
||||
ATOM 260 OE2 GLU I 34 -3.643 -24.098 22.267 1.00 27.80 2CI2 236
|
||||
ATOM 261 N ALA I 35 1.657 -24.281 19.832 1.00 14.83 2CI2 237
|
||||
ATOM 262 CA ALA I 35 2.301 -24.450 18.528 1.00 15.06 2CI2 238
|
||||
ATOM 263 C ALA I 35 3.813 -24.601 18.547 1.00 15.32 2CI2 239
|
||||
ATOM 264 O ALA I 35 4.350 -25.396 17.757 1.00 14.08 2CI2 240
|
||||
ATOM 265 CB ALA I 35 1.830 -23.345 17.595 1.00 15.31 2CI2 241
|
||||
ATOM 266 N LYS I 36 4.507 -23.894 19.410 1.00 17.27 2CI2 242
|
||||
ATOM 267 CA LYS I 36 5.962 -23.951 19.582 1.00 21.30 2CI2 243
|
||||
ATOM 268 C LYS I 36 6.380 -25.393 19.932 1.00 22.84 2CI2 244
|
||||
ATOM 269 O LYS I 36 7.258 -26.038 19.349 1.00 24.08 2CI2 245
|
||||
ATOM 270 CB LYS I 36 6.434 -23.122 20.776 1.00 24.87 2CI2 246
|
||||
ATOM 271 CG LYS I 36 7.002 -21.736 20.526 1.00 28.26 2CI2 247
|
||||
ATOM 272 CD LYS I 36 7.306 -21.034 21.850 1.00 30.78 2CI2 248
|
||||
ATOM 273 CE LYS I 36 7.796 -19.617 21.627 1.00 35.81 2CI2 249
|
||||
ATOM 274 NZ LYS I 36 7.133 -18.641 22.527 1.00 35.81 2CI2 250
|
||||
ATOM 275 N LYS I 37 5.723 -25.853 20.976 1.00 22.87 2CI2 251
|
||||
ATOM 276 CA LYS I 37 5.845 -27.168 21.584 1.00 22.10 2CI2 252
|
||||
ATOM 277 C LYS I 37 5.736 -28.313 20.594 1.00 21.22 2CI2 253
|
||||
ATOM 278 O LYS I 37 6.480 -29.300 20.733 1.00 23.27 2CI2 254
|
||||
ATOM 279 CB LYS I 37 4.737 -27.336 22.629 1.00 27.93 2CI2 255
|
||||
ATOM 280 CG LYS I 37 4.920 -28.562 23.515 1.00 32.57 2CI2 256
|
||||
ATOM 281 CD LYS I 37 4.224 -28.337 24.851 1.00 40.46 2CI2 257
|
||||
ATOM 282 CE LYS I 37 5.116 -27.599 25.832 1.00 44.72 2CI2 258
|
||||
ATOM 283 NZ LYS I 37 5.032 -26.134 25.566 1.00 49.32 2CI2 259
|
||||
ATOM 284 N VAL I 38 4.840 -28.194 19.634 1.00 19.75 2CI2 260
|
||||
ATOM 285 CA VAL I 38 4.604 -29.219 18.615 1.00 15.32 2CI2 261
|
||||
ATOM 286 C VAL I 38 5.710 -29.152 17.567 1.00 15.61 2CI2 262
|
||||
ATOM 287 O VAL I 38 6.352 -30.174 17.282 1.00 15.26 2CI2 263
|
||||
ATOM 288 CB VAL I 38 3.190 -29.150 18.018 1.00 14.16 2CI2 264
|
||||
ATOM 289 CG1 VAL I 38 3.086 -29.925 16.709 1.00 14.89 2CI2 265
|
||||
ATOM 290 CG2 VAL I 38 2.129 -29.627 18.988 1.00 12.55 2CI2 266
|
||||
ATOM 291 N ILE I 39 5.911 -27.960 17.040 1.00 16.80 2CI2 267
|
||||
ATOM 292 CA ILE I 39 6.950 -27.739 16.032 1.00 15.41 2CI2 268
|
||||
ATOM 293 C ILE I 39 8.308 -28.212 16.538 1.00 16.48 2CI2 269
|
||||
ATOM 294 O ILE I 39 9.023 -28.878 15.765 1.00 18.13 2CI2 270
|
||||
ATOM 295 CB ILE I 39 7.012 -26.274 15.505 1.00 16.94 2CI2 271
|
||||
ATOM 296 CG1 ILE I 39 5.719 -25.949 14.709 1.00 21.24 2CI2 272
|
||||
ATOM 297 CG2 ILE I 39 8.263 -26.029 14.605 1.00 16.53 2CI2 273
|
||||
ATOM 298 CD1 ILE I 39 5.392 -24.431 14.610 1.00 23.27 2CI2 274
|
||||
ATOM 299 N LEU I 40 8.657 -27.855 17.757 1.00 16.17 2CI2 275
|
||||
ATOM 300 CA LEU I 40 9.982 -28.217 18.293 1.00 18.63 2CI2 276
|
||||
ATOM 301 C LEU I 40 10.132 -29.728 18.443 1.00 21.07 2CI2 277
|
||||
ATOM 302 O LEU I 40 11.247 -30.268 18.393 1.00 20.70 2CI2 278
|
||||
ATOM 303 CB LEU I 40 10.263 -27.405 19.554 1.00 18.61 2CI2 279
|
||||
ATOM 304 CG LEU I 40 10.842 -26.016 19.388 1.00 17.07 2CI2 280
|
||||
ATOM 305 CD1 LEU I 40 11.090 -25.396 20.764 1.00 23.85 2CI2 281
|
||||
ATOM 306 CD2 LEU I 40 12.141 -26.077 18.591 1.00 19.94 2CI2 282
|
||||
ATOM 307 N GLN I 41 9.000 -30.365 18.645 1.00 23.16 2CI2 283
|
||||
ATOM 308 CA GLN I 41 8.891 -31.825 18.774 1.00 25.25 2CI2 284
|
||||
ATOM 309 C GLN I 41 9.318 -32.433 17.438 1.00 24.46 2CI2 285
|
||||
ATOM 310 O GLN I 41 10.207 -33.288 17.402 1.00 26.23 2CI2 286
|
||||
ATOM 311 CB GLN I 41 7.474 -32.234 19.153 1.00 32.52 2CI2 287
|
||||
ATOM 312 CG GLN I 41 7.314 -33.577 19.818 1.00 42.96 2CI2 288
|
||||
ATOM 313 CD GLN I 41 6.509 -33.578 21.095 1.00 46.29 2CI2 289
|
||||
ATOM 314 OE1 GLN I 41 6.503 -32.634 21.887 1.00 49.82 2CI2 290
|
||||
ATOM 315 NE2 GLN I 41 5.821 -34.705 21.308 1.00 48.08 2CI2 291
|
||||
ATOM 316 N ASP I 42 8.727 -31.943 16.370 1.00 23.73 2CI2 292
|
||||
ATOM 317 CA ASP I 42 8.929 -32.383 14.999 1.00 22.62 2CI2 293
|
||||
ATOM 318 C ASP I 42 10.168 -31.830 14.286 1.00 21.24 2CI2 294
|
||||
ATOM 319 O ASP I 42 10.572 -32.414 13.266 1.00 20.70 2CI2 295
|
||||
ATOM 320 CB ASP I 42 7.739 -32.008 14.101 1.00 21.43 2CI2 296
|
||||
ATOM 321 CG ASP I 42 6.391 -32.554 14.478 1.00 24.49 2CI2 297
|
||||
ATOM 322 OD1 ASP I 42 6.224 -33.424 15.341 1.00 30.00 2CI2 298
|
||||
ATOM 323 OD2 ASP I 42 5.429 -32.063 13.853 1.00 23.55 2CI2 299
|
||||
ATOM 324 N LYS I 43 10.612 -30.682 14.732 1.00 20.73 2CI2 300
|
||||
ATOM 325 CA LYS I 43 11.762 -29.988 14.115 1.00 18.42 2CI2 301
|
||||
ATOM 326 C LYS I 43 12.565 -29.299 15.217 1.00 18.96 2CI2 302
|
||||
ATOM 327 O LYS I 43 12.452 -28.083 15.438 1.00 19.44 2CI2 303
|
||||
ATOM 328 CB LYS I 43 11.264 -29.036 13.050 1.00 15.53 2CI2 304
|
||||
ATOM 329 CG LYS I 43 12.282 -28.156 12.359 1.00 16.07 2CI2 305
|
||||
ATOM 330 CD LYS I 43 11.660 -27.262 11.302 1.00 13.64 2CI2 306
|
||||
ATOM 331 CE LYS I 43 12.715 -26.577 10.456 1.00 14.15 2CI2 307
|
||||
ATOM 332 NZ LYS I 43 13.226 -27.491 9.406 1.00 10.85 2CI2 308
|
||||
ATOM 333 N PRO I 44 13.352 -30.106 15.923 1.00 16.81 2CI2 309
|
||||
ATOM 334 CA PRO I 44 14.183 -29.654 17.033 1.00 17.34 2CI2 310
|
||||
ATOM 335 C PRO I 44 15.097 -28.476 16.764 1.00 12.69 2CI2 311
|
||||
ATOM 336 O PRO I 44 15.460 -27.793 17.739 1.00 18.82 2CI2 312
|
||||
ATOM 337 CB PRO I 44 14.982 -30.902 17.434 1.00 19.36 2CI2 313
|
||||
ATOM 338 CG PRO I 44 14.134 -32.063 16.974 1.00 17.24 2CI2 314
|
||||
ATOM 339 CD PRO I 44 13.482 -31.566 15.700 1.00 18.51 2CI2 315
|
||||
ATOM 340 N GLU I 45 15.470 -28.229 15.542 1.00 13.52 2CI2 316
|
||||
ATOM 341 CA GLU I 45 16.354 -27.129 15.131 1.00 14.95 2CI2 317
|
||||
ATOM 342 C GLU I 45 15.625 -25.881 14.626 1.00 17.15 2CI2 318
|
||||
ATOM 343 O GLU I 45 16.271 -24.911 14.173 1.00 16.32 2CI2 319
|
||||
ATOM 344 CB GLU I 45 17.248 -27.546 13.952 1.00 9.98 2CI2 320
|
||||
ATOM 345 CG GLU I 45 16.644 -27.572 12.557 1.00 10.75 2CI2 321
|
||||
ATOM 346 CD GLU I 45 15.732 -28.688 12.165 1.00 8.14 2CI2 322
|
||||
ATOM 347 OE1 GLU I 45 15.371 -28.890 11.021 1.00 10.38 2CI2 323
|
||||
ATOM 348 OE2 GLU I 45 15.335 -29.407 13.092 1.00 7.28 2CI2 324
|
||||
ATOM 349 N ALA I 46 14.296 -25.926 14.640 1.00 16.99 2CI2 325
|
||||
ATOM 350 CA ALA I 46 13.480 -24.810 14.160 1.00 16.57 2CI2 326
|
||||
ATOM 351 C ALA I 46 13.766 -23.529 14.960 1.00 16.97 2CI2 327
|
||||
ATOM 352 O ALA I 46 13.978 -23.500 16.191 1.00 14.42 2CI2 328
|
||||
ATOM 353 CB ALA I 46 12.006 -25.178 14.177 1.00 18.81 2CI2 329
|
||||
ATOM 354 N GLN I 47 13.808 -22.469 14.161 1.00 15.12 2CI2 330
|
||||
ATOM 355 CA GLN I 47 13.934 -21.079 14.630 1.00 15.59 2CI2 331
|
||||
ATOM 356 C GLN I 47 12.529 -20.488 14.404 1.00 14.48 2CI2 332
|
||||
ATOM 357 O GLN I 47 12.125 -20.297 13.255 1.00 15.43 2CI2 333
|
||||
ATOM 358 CB GLN I 47 15.042 -20.280 13.971 1.00 14.57 2CI2 334
|
||||
ATOM 359 CG GLN I 47 16.441 -20.754 14.352 1.00 20.31 2CI2 335
|
||||
ATOM 360 CD GLN I 47 16.787 -20.674 15.818 1.00 20.92 2CI2 336
|
||||
ATOM 361 OE1 GLN I 47 16.587 -19.708 16.552 1.00 22.99 2CI2 337
|
||||
ATOM 362 NE2 GLN I 47 17.380 -21.750 16.340 1.00 26.19 2CI2 338
|
||||
ATOM 363 N ILE I 48 11.802 -20.339 15.498 1.00 16.27 2CI2 339
|
||||
ATOM 364 CA ILE I 48 10.406 -19.875 15.481 1.00 15.80 2CI2 340
|
||||
ATOM 365 C ILE I 48 10.296 -18.353 15.480 1.00 15.66 2CI2 341
|
||||
ATOM 366 O ILE I 48 10.807 -17.686 16.389 1.00 15.96 2CI2 342
|
||||
ATOM 367 CB ILE I 48 9.587 -20.549 16.640 1.00 17.30 2CI2 343
|
||||
ATOM 368 CG1 ILE I 48 9.667 -22.092 16.476 1.00 16.79 2CI2 344
|
||||
ATOM 369 CG2 ILE I 48 8.112 -20.079 16.733 1.00 15.04 2CI2 345
|
||||
ATOM 370 CD1 ILE I 48 9.075 -22.874 17.679 1.00 21.73 2CI2 346
|
||||
ATOM 371 N ILE I 49 9.612 -17.862 14.459 1.00 14.44 2CI2 347
|
||||
ATOM 372 CA ILE I 49 9.350 -16.429 14.248 1.00 12.51 2CI2 348
|
||||
ATOM 373 C ILE I 49 7.835 -16.209 14.313 1.00 10.43 2CI2 349
|
||||
ATOM 374 O ILE I 49 7.073 -16.959 13.687 1.00 12.52 2CI2 350
|
||||
ATOM 375 CB ILE I 49 9.962 -15.963 12.882 1.00 13.39 2CI2 351
|
||||
ATOM 376 CG1 ILE I 49 11.499 -16.164 12.865 1.00 15.31 2CI2 352
|
||||
ATOM 377 CG2 ILE I 49 9.580 -14.515 12.488 1.00 8.33 2CI2 353
|
||||
ATOM 378 CD1 ILE I 49 12.287 -15.564 14.052 1.00 12.08 2CI2 354
|
||||
ATOM 379 N VAL I 50 7.424 -15.222 15.077 1.00 9.95 2CI2 355
|
||||
ATOM 380 CA VAL I 50 6.021 -14.883 15.315 1.00 9.48 2CI2 356
|
||||
ATOM 381 C VAL I 50 5.676 -13.527 14.695 1.00 11.08 2CI2 357
|
||||
ATOM 382 O VAL I 50 6.168 -12.524 15.236 1.00 11.22 2CI2 358
|
||||
ATOM 383 CB VAL I 50 5.781 -14.853 16.844 1.00 11.04 2CI2 359
|
||||
ATOM 384 CG1 VAL I 50 4.377 -14.381 17.212 1.00 12.78 2CI2 360
|
||||
ATOM 385 CG2 VAL I 50 6.099 -16.175 17.517 1.00 13.08 2CI2 361
|
||||
ATOM 386 N LEU I 51 4.861 -13.525 13.658 1.00 10.84 2CI2 362
|
||||
ATOM 387 CA LEU I 51 4.434 -12.286 13.006 1.00 7.63 2CI2 363
|
||||
ATOM 388 C LEU I 51 2.903 -12.192 12.917 1.00 8.35 2CI2 364
|
||||
ATOM 389 O LEU I 51 2.209 -13.209 12.829 1.00 7.78 2CI2 365
|
||||
ATOM 390 CB LEU I 51 5.085 -12.267 11.629 1.00 6.43 2CI2 366
|
||||
ATOM 391 CG LEU I 51 6.571 -12.463 11.463 1.00 12.23 2CI2 367
|
||||
ATOM 392 CD1 LEU I 51 6.895 -12.729 9.987 1.00 11.51 2CI2 368
|
||||
ATOM 393 CD2 LEU I 51 7.308 -11.208 11.927 1.00 10.52 2CI2 369
|
||||
ATOM 394 N PRO I 52 2.416 -10.962 12.894 1.00 8.91 2CI2 370
|
||||
ATOM 395 CA PRO I 52 0.988 -10.679 12.717 1.00 8.08 2CI2 371
|
||||
ATOM 396 C PRO I 52 0.574 -11.041 11.295 1.00 11.02 2CI2 372
|
||||
ATOM 397 O PRO I 52 1.382 -10.841 10.366 1.00 11.03 2CI2 373
|
||||
ATOM 398 CB PRO I 52 0.884 -9.161 12.910 1.00 8.44 2CI2 374
|
||||
ATOM 399 CG PRO I 52 2.188 -8.710 13.474 1.00 8.74 2CI2 375
|
||||
ATOM 400 CD PRO I 52 3.218 -9.722 12.987 1.00 8.21 2CI2 376
|
||||
ATOM 401 N VAL I 53 -0.653 -11.520 11.104 1.00 13.73 2CI2 377
|
||||
ATOM 402 CA VAL I 53 -1.162 -11.852 9.752 1.00 13.43 2CI2 378
|
||||
ATOM 403 C VAL I 53 -1.148 -10.553 8.928 1.00 13.53 2CI2 379
|
||||
ATOM 404 O VAL I 53 -1.522 -9.509 9.485 1.00 12.58 2CI2 380
|
||||
ATOM 405 CB VAL I 53 -2.613 -12.380 9.772 1.00 14.76 2CI2 381
|
||||
ATOM 406 CG1 VAL I 53 -3.233 -12.469 8.383 1.00 12.98 2CI2 382
|
||||
ATOM 407 CG2 VAL I 53 -2.790 -13.681 10.534 1.00 17.50 2CI2 383
|
||||
ATOM 408 N GLY I 54 -0.799 -10.663 7.667 1.00 14.73 2CI2 384
|
||||
ATOM 409 CA GLY I 54 -0.750 -9.522 6.759 1.00 17.16 2CI2 385
|
||||
ATOM 410 C GLY I 54 0.641 -8.916 6.616 1.00 19.26 2CI2 386
|
||||
ATOM 411 O GLY I 54 0.775 -7.922 5.879 1.00 21.70 2CI2 387
|
||||
ATOM 412 N THR I 55 1.631 -9.482 7.278 1.00 19.90 2CI2 388
|
||||
ATOM 413 CA THR I 55 3.026 -9.024 7.221 1.00 19.01 2CI2 389
|
||||
ATOM 414 C THR I 55 3.733 -9.525 5.959 1.00 20.10 2CI2 390
|
||||
ATOM 415 O THR I 55 3.723 -10.705 5.577 1.00 20.03 2CI2 391
|
||||
ATOM 416 CB THR I 55 3.835 -9.379 8.534 1.00 13.94 2CI2 392
|
||||
ATOM 417 OG1 THR I 55 3.039 -8.848 9.638 1.00 14.28 2CI2 393
|
||||
ATOM 418 CG2 THR I 55 5.273 -8.870 8.656 1.00 11.44 2CI2 394
|
||||
ATOM 419 N ILE I 56 4.366 -8.581 5.287 1.00 21.85 2CI2 395
|
||||
ATOM 420 CA ILE I 56 5.139 -8.819 4.064 1.00 26.80 2CI2 396
|
||||
ATOM 421 C ILE I 56 6.579 -9.135 4.460 1.00 27.03 2CI2 397
|
||||
ATOM 422 O ILE I 56 7.249 -8.267 5.043 1.00 26.20 2CI2 398
|
||||
ATOM 423 CB ILE I 56 5.029 -7.574 3.114 1.00 34.95 2CI2 399
|
||||
ATOM 424 CG1 ILE I 56 3.532 -7.255 2.850 1.00 37.26 2CI2 400
|
||||
ATOM 425 CG2 ILE I 56 5.835 -7.765 1.797 1.00 38.25 2CI2 401
|
||||
ATOM 426 CD1 ILE I 56 3.165 -6.922 1.374 1.00 35.14 2CI2 402
|
||||
ATOM 427 N VAL I 57 7.016 -10.334 4.135 1.00 28.91 2CI2 403
|
||||
ATOM 428 CA VAL I 57 8.379 -10.774 4.491 1.00 31.56 2CI2 404
|
||||
ATOM 429 C VAL I 57 9.319 -10.718 3.294 1.00 35.26 2CI2 405
|
||||
ATOM 430 O VAL I 57 8.878 -10.587 2.133 1.00 35.25 2CI2 406
|
||||
ATOM 431 CB VAL I 57 8.280 -12.143 5.194 1.00 30.70 2CI2 407
|
||||
ATOM 432 CG1 VAL I 57 7.631 -12.051 6.575 1.00 31.82 2CI2 408
|
||||
ATOM 433 CG2 VAL I 57 7.560 -13.177 4.349 1.00 25.22 2CI2 409
|
||||
ATOM 434 N THR I 58 10.607 -10.825 3.594 1.00 38.04 2CI2 410
|
||||
ATOM 435 CA THR I 58 11.673 -10.826 2.570 1.00 41.77 2CI2 411
|
||||
ATOM 436 C THR I 58 11.719 -12.200 1.893 1.00 42.78 2CI2 412
|
||||
ATOM 437 O THR I 58 11.710 -13.236 2.588 1.00 44.39 2CI2 413
|
||||
ATOM 438 CB THR I 58 13.075 -10.436 3.177 1.00 43.20 2CI2 414
|
||||
ATOM 439 OG1 THR I 58 12.819 -9.628 4.374 1.00 47.09 2CI2 415
|
||||
ATOM 440 CG2 THR I 58 14.010 -9.719 2.198 1.00 45.92 2CI2 416
|
||||
ATOM 441 N MET I 59 11.805 -12.198 0.578 1.00 42.43 2CI2 417
|
||||
ATOM 442 CA MET I 59 11.790 -13.423 -0.231 1.00 42.89 2CI2 418
|
||||
ATOM 443 C MET I 59 12.923 -14.402 -0.034 1.00 41.48 2CI2 419
|
||||
ATOM 444 O MET I 59 13.182 -15.246 -0.920 1.00 43.82 2CI2 420
|
||||
ATOM 445 CB MET I 59 11.487 -13.044 -1.667 1.00 48.81 2CI2 421
|
||||
ATOM 446 CG MET I 59 12.377 -13.589 -2.744 1.00 50.54 2CI2 422
|
||||
ATOM 447 SD MET I 59 11.939 -12.708 -4.297 1.00 51.98 2CI2 423
|
||||
ATOM 448 CE MET I 59 13.386 -11.632 -4.439 1.00 52.05 2CI2 424
|
||||
ATOM 449 N GLU I 60 13.534 -14.434 1.126 1.00 41.22 2CI2 425
|
||||
ATOM 450 CA GLU I 60 14.630 -15.348 1.473 1.00 39.34 2CI2 426
|
||||
ATOM 451 C GLU I 60 14.165 -16.660 2.096 1.00 38.65 2CI2 427
|
||||
ATOM 452 O GLU I 60 13.464 -16.641 3.129 1.00 40.31 2CI2 428
|
||||
ATOM 453 CB GLU I 60 15.553 -14.670 2.495 1.00 41.16 2CI2 429
|
||||
ATOM 454 CG GLU I 60 15.004 -14.303 3.874 1.00 34.03 2CI2 430
|
||||
ATOM 455 CD GLU I 60 15.948 -13.599 4.798 1.00 28.96 2CI2 431
|
||||
ATOM 456 OE1 GLU I 60 16.303 -12.443 4.660 1.00 30.34 2CI2 432
|
||||
ATOM 457 OE2 GLU I 60 16.353 -14.327 5.723 1.00 28.34 2CI2 433
|
||||
ATOM 458 N TYR I 61 14.611 -17.778 1.555 1.00 36.27 2CI2 434
|
||||
ATOM 459 CA TYR I 61 14.251 -19.116 2.030 1.00 33.51 2CI2 435
|
||||
ATOM 460 C TYR I 61 15.194 -19.748 3.044 1.00 33.19 2CI2 436
|
||||
ATOM 461 O TYR I 61 16.326 -20.096 2.653 1.00 37.23 2CI2 437
|
||||
ATOM 462 CB TYR I 61 14.150 -20.079 0.814 1.00 29.28 2CI2 438
|
||||
ATOM 463 CG TYR I 61 13.798 -21.485 1.251 1.00 28.41 2CI2 439
|
||||
ATOM 464 CD1 TYR I 61 14.755 -22.500 1.318 1.00 31.55 2CI2 440
|
||||
ATOM 465 CD2 TYR I 61 12.497 -21.791 1.634 1.00 27.17 2CI2 441
|
||||
ATOM 466 CE1 TYR I 61 14.412 -23.787 1.735 1.00 28.91 2CI2 442
|
||||
ATOM 467 CE2 TYR I 61 12.136 -23.065 2.053 1.00 26.04 2CI2 443
|
||||
ATOM 468 CZ TYR I 61 13.097 -24.064 2.099 1.00 28.55 2CI2 444
|
||||
ATOM 469 OH TYR I 61 12.703 -25.305 2.513 1.00 26.67 2CI2 445
|
||||
ATOM 470 N ARG I 62 14.727 -20.014 4.255 1.00 29.39 2CI2 446
|
||||
ATOM 471 CA ARG I 62 15.539 -20.644 5.299 1.00 23.99 2CI2 447
|
||||
ATOM 472 C ARG I 62 14.903 -21.907 5.873 1.00 22.75 2CI2 448
|
||||
ATOM 473 O ARG I 62 13.892 -21.886 6.586 1.00 20.32 2CI2 449
|
||||
ATOM 474 CB ARG I 62 15.854 -19.676 6.440 1.00 27.80 2CI2 450
|
||||
ATOM 475 CG ARG I 62 16.717 -18.484 6.052 1.00 28.78 2CI2 451
|
||||
ATOM 476 CD ARG I 62 18.009 -18.462 6.782 1.00 32.63 2CI2 452
|
||||
ATOM 477 NE ARG I 62 17.969 -19.139 8.072 1.00 33.31 2CI2 453
|
||||
ATOM 478 CZ ARG I 62 19.023 -19.200 8.893 1.00 31.69 2CI2 454
|
||||
ATOM 479 NH1 ARG I 62 20.179 -18.614 8.592 1.00 28.13 2CI2 455
|
||||
ATOM 480 NH2 ARG I 62 18.915 -19.879 10.037 1.00 31.67 2CI2 456
|
||||
ATOM 481 N ILE I 63 15.581 -23.002 5.623 1.00 17.45 2CI2 457
|
||||
ATOM 482 CA ILE I 63 15.194 -24.357 6.003 1.00 18.72 2CI2 458
|
||||
ATOM 483 C ILE I 63 14.963 -24.580 7.480 1.00 18.40 2CI2 459
|
||||
ATOM 484 O ILE I 63 14.082 -25.410 7.839 1.00 23.17 2CI2 460
|
||||
ATOM 485 CB ILE I 63 16.213 -25.314 5.264 1.00 22.99 2CI2 461
|
||||
ATOM 486 CG1 ILE I 63 15.612 -26.713 4.984 1.00 26.52 2CI2 462
|
||||
ATOM 487 CG2 ILE I 63 17.599 -25.398 5.950 1.00 19.42 2CI2 463
|
||||
ATOM 488 CD1 ILE I 63 16.672 -27.837 4.742 1.00 24.70 2CI2 464
|
||||
ATOM 489 N ASP I 64 15.632 -23.860 8.364 1.00 14.60 2CI2 465
|
||||
ATOM 490 CA ASP I 64 15.500 -24.051 9.809 1.00 14.66 2CI2 466
|
||||
ATOM 491 C ASP I 64 14.469 -23.145 10.478 1.00 10.73 2CI2 467
|
||||
ATOM 492 O ASP I 64 14.340 -23.221 11.714 1.00 12.65 2CI2 468
|
||||
ATOM 493 CB ASP I 64 16.845 -23.914 10.535 1.00 19.91 2CI2 469
|
||||
ATOM 494 CG ASP I 64 17.527 -22.577 10.305 1.00 20.76 2CI2 470
|
||||
ATOM 495 OD1 ASP I 64 17.446 -21.999 9.205 1.00 21.61 2CI2 471
|
||||
ATOM 496 OD2 ASP I 64 18.137 -22.110 11.298 1.00 25.03 2CI2 472
|
||||
ATOM 497 N ARG I 65 13.870 -22.315 9.663 1.00 11.64 2CI2 473
|
||||
ATOM 498 CA ARG I 65 12.918 -21.309 10.141 1.00 12.51 2CI2 474
|
||||
ATOM 499 C ARG I 65 11.453 -21.716 10.025 1.00 12.85 2CI2 475
|
||||
ATOM 500 O ARG I 65 11.074 -22.245 8.974 1.00 12.01 2CI2 476
|
||||
ATOM 501 CB ARG I 65 13.130 -20.016 9.321 1.00 10.70 2CI2 477
|
||||
ATOM 502 CG ARG I 65 12.169 -18.890 9.687 1.00 14.03 2CI2 478
|
||||
ATOM 503 CD ARG I 65 12.644 -17.542 9.266 1.00 11.51 2CI2 479
|
||||
ATOM 504 NE ARG I 65 12.674 -17.387 7.831 1.00 15.20 2CI2 480
|
||||
ATOM 505 CZ ARG I 65 13.460 -16.613 7.090 1.00 15.39 2CI2 481
|
||||
ATOM 506 NH1 ARG I 65 14.340 -15.768 7.596 1.00 17.74 2CI2 482
|
||||
ATOM 507 NH2 ARG I 65 13.389 -16.713 5.764 1.00 16.07 2CI2 483
|
||||
ATOM 508 N VAL I 66 10.685 -21.359 11.050 1.00 10.71 2CI2 484
|
||||
ATOM 509 CA VAL I 66 9.240 -21.555 11.079 1.00 13.23 2CI2 485
|
||||
ATOM 510 C VAL I 66 8.541 -20.253 11.517 1.00 12.86 2CI2 486
|
||||
ATOM 511 O VAL I 66 8.570 -19.906 12.710 1.00 16.02 2CI2 487
|
||||
ATOM 512 CB VAL I 66 8.740 -22.721 11.951 1.00 11.53 2CI2 488
|
||||
ATOM 513 CG1 VAL I 66 7.216 -22.881 11.850 1.00 11.98 2CI2 489
|
||||
ATOM 514 CG2 VAL I 66 9.420 -24.045 11.659 1.00 13.94 2CI2 490
|
||||
ATOM 515 N ARG I 67 7.886 -19.619 10.566 1.00 9.65 2CI2 491
|
||||
ATOM 516 CA ARG I 67 7.130 -18.389 10.853 1.00 10.83 2CI2 492
|
||||
ATOM 517 C ARG I 67 5.717 -18.746 11.304 1.00 7.13 2CI2 493
|
||||
ATOM 518 O ARG I 67 5.057 -19.492 10.560 1.00 9.94 2CI2 494
|
||||
ATOM 519 CB ARG I 67 7.001 -17.538 9.570 1.00 11.98 2CI2 495
|
||||
ATOM 520 CG ARG I 67 8.290 -16.786 9.175 1.00 11.30 2CI2 496
|
||||
ATOM 521 CD ARG I 67 8.099 -16.286 7.796 1.00 15.42 2CI2 497
|
||||
ATOM 522 NE ARG I 67 9.218 -15.651 7.158 1.00 26.19 2CI2 498
|
||||
ATOM 523 CZ ARG I 67 9.598 -15.877 5.897 1.00 23.69 2CI2 499
|
||||
ATOM 524 NH1 ARG I 67 8.987 -16.777 5.135 1.00 25.11 2CI2 500
|
||||
ATOM 525 NH2 ARG I 67 10.603 -15.150 5.399 1.00 32.20 2CI2 501
|
||||
ATOM 526 N LEU I 68 5.264 -18.178 12.388 1.00 5.51 2CI2 502
|
||||
ATOM 527 CA LEU I 68 3.881 -18.326 12.864 1.00 7.63 2CI2 503
|
||||
ATOM 528 C LEU I 68 3.149 -17.004 12.584 1.00 6.35 2CI2 504
|
||||
ATOM 529 O LEU I 68 3.629 -15.965 13.056 1.00 8.97 2CI2 505
|
||||
ATOM 530 CB LEU I 68 3.893 -18.673 14.353 1.00 6.88 2CI2 506
|
||||
ATOM 531 CG LEU I 68 4.586 -19.961 14.774 1.00 11.18 2CI2 507
|
||||
ATOM 532 CD1 LEU I 68 4.451 -20.213 16.270 1.00 2.78 2CI2 508
|
||||
ATOM 533 CD2 LEU I 68 3.981 -21.071 13.922 1.00 10.53 2CI2 509
|
||||
ATOM 534 N PHE I 69 2.068 -17.071 11.845 1.00 5.58 2CI2 510
|
||||
ATOM 535 CA PHE I 69 1.254 -15.871 11.532 1.00 5.54 2CI2 511
|
||||
ATOM 536 C PHE I 69 0.064 -15.898 12.493 1.00 6.41 2CI2 512
|
||||
ATOM 537 O PHE I 69 -0.788 -16.799 12.467 1.00 7.94 2CI2 513
|
||||
ATOM 538 CB PHE I 69 0.923 -15.768 10.047 1.00 5.59 2CI2 514
|
||||
ATOM 539 CG PHE I 69 2.063 -15.303 9.185 1.00 12.09 2CI2 515
|
||||
ATOM 540 CD1 PHE I 69 2.924 -16.230 8.593 1.00 13.33 2CI2 516
|
||||
ATOM 541 CD2 PHE I 69 2.299 -13.936 8.992 1.00 10.83 2CI2 517
|
||||
ATOM 542 CE1 PHE I 69 4.008 -15.811 7.835 1.00 13.21 2CI2 518
|
||||
ATOM 543 CE2 PHE I 69 3.384 -13.491 8.239 1.00 11.69 2CI2 519
|
||||
ATOM 544 CZ PHE I 69 4.229 -14.445 7.653 1.00 11.95 2CI2 520
|
||||
ATOM 545 N VAL I 70 0.072 -14.937 13.400 1.00 7.81 2CI2 521
|
||||
ATOM 546 CA VAL I 70 -0.893 -14.807 14.480 1.00 6.70 2CI2 522
|
||||
ATOM 547 C VAL I 70 -1.933 -13.701 14.306 1.00 10.75 2CI2 523
|
||||
ATOM 548 O VAL I 70 -1.791 -12.706 13.598 1.00 8.45 2CI2 524
|
||||
ATOM 549 CB VAL I 70 -0.182 -14.794 15.849 1.00 3.28 2CI2 525
|
||||
ATOM 550 CG1 VAL I 70 0.815 -15.948 15.986 1.00 4.29 2CI2 526
|
||||
ATOM 551 CG2 VAL I 70 0.495 -13.475 16.183 1.00 3.98 2CI2 527
|
||||
ATOM 552 N ASP I 71 -3.046 -13.959 14.981 1.00 11.12 2CI2 528
|
||||
ATOM 553 CA ASP I 71 -4.238 -13.107 15.079 1.00 12.63 2CI2 529
|
||||
ATOM 554 C ASP I 71 -4.081 -12.235 16.333 1.00 14.44 2CI2 530
|
||||
ATOM 555 O ASP I 71 -3.074 -12.351 17.058 1.00 17.27 2CI2 531
|
||||
ATOM 556 CB ASP I 71 -5.514 -13.958 15.062 1.00 7.46 2CI2 532
|
||||
ATOM 557 CG ASP I 71 -5.869 -14.578 16.391 1.00 8.37 2CI2 533
|
||||
ATOM 558 OD1 ASP I 71 -5.102 -14.498 17.367 1.00 12.91 2CI2 534
|
||||
ATOM 559 OD2 ASP I 71 -6.946 -15.205 16.517 1.00 9.72 2CI2 535
|
||||
ATOM 560 N LYS I 72 -5.051 -11.380 16.574 1.00 13.75 2CI2 536
|
||||
ATOM 561 CA LYS I 72 -5.097 -10.438 17.680 1.00 13.74 2CI2 537
|
||||
ATOM 562 C LYS I 72 -4.946 -11.083 19.051 1.00 15.88 2CI2 538
|
||||
ATOM 563 O LYS I 72 -4.589 -10.376 20.015 1.00 16.72 2CI2 539
|
||||
ATOM 564 CB LYS I 72 -6.456 -9.729 17.730 1.00 13.34 2CI2 540
|
||||
ATOM 565 CG LYS I 72 -6.507 -8.381 17.036 1.00 20.82 2CI2 541
|
||||
ATOM 566 CD LYS I 72 -7.817 -7.657 17.322 1.00 21.70 2CI2 542
|
||||
ATOM 567 CE LYS I 72 -7.679 -6.538 18.330 1.00 21.57 2CI2 543
|
||||
ATOM 568 NZ LYS I 72 -8.402 -5.330 17.839 1.00 30.14 2CI2 544
|
||||
ATOM 569 N LEU I 73 -5.275 -12.356 19.142 1.00 16.38 2CI2 545
|
||||
ATOM 570 CA LEU I 73 -5.201 -13.055 20.437 1.00 18.38 2CI2 546
|
||||
ATOM 571 C LEU I 73 -3.989 -13.979 20.495 1.00 19.84 2CI2 547
|
||||
ATOM 572 O LEU I 73 -3.851 -14.718 21.490 1.00 22.48 2CI2 548
|
||||
ATOM 573 CB LEU I 73 -6.544 -13.733 20.702 1.00 22.11 2CI2 549
|
||||
ATOM 574 CG LEU I 73 -7.766 -12.854 20.907 1.00 22.63 2CI2 550
|
||||
ATOM 575 CD1 LEU I 73 -8.985 -13.712 21.224 1.00 24.13 2CI2 551
|
||||
ATOM 576 CD2 LEU I 73 -7.484 -11.876 22.047 1.00 24.80 2CI2 552
|
||||
ATOM 577 N ASP I 74 -3.163 -13.927 19.472 1.00 19.04 2CI2 553
|
||||
ATOM 578 CA ASP I 74 -1.954 -14.754 19.386 1.00 20.64 2CI2 554
|
||||
ATOM 579 C ASP I 74 -2.256 -16.222 19.066 1.00 17.76 2CI2 555
|
||||
ATOM 580 O ASP I 74 -1.538 -17.062 19.642 1.00 18.05 2CI2 556
|
||||
ATOM 581 CB ASP I 74 -1.118 -14.670 20.675 1.00 25.90 2CI2 557
|
||||
ATOM 582 CG ASP I 74 -0.466 -13.319 20.898 1.00 29.31 2CI2 558
|
||||
ATOM 583 OD1 ASP I 74 0.082 -12.750 19.940 1.00 30.95 2CI2 559
|
||||
ATOM 584 OD2 ASP I 74 -0.524 -12.847 22.054 1.00 30.81 2CI2 560
|
||||
ATOM 585 N ASN I 75 -3.259 -16.487 18.263 1.00 14.97 2CI2 561
|
||||
ATOM 586 CA ASN I 75 -3.598 -17.863 17.854 1.00 13.91 2CI2 562
|
||||
ATOM 587 C ASN I 75 -3.042 -18.012 16.436 1.00 12.18 2CI2 563
|
||||
ATOM 588 O ASN I 75 -2.896 -16.949 15.809 1.00 13.00 2CI2 564
|
||||
ATOM 589 CB ASN I 75 -5.101 -18.132 17.948 1.00 13.31 2CI2 565
|
||||
ATOM 590 CG ASN I 75 -5.494 -18.262 19.407 1.00 15.19 2CI2 566
|
||||
ATOM 591 OD1 ASN I 75 -4.723 -18.834 20.193 1.00 19.14 2CI2 567
|
||||
ATOM 592 ND2 ASN I 75 -6.631 -17.697 19.772 1.00 17.73 2CI2 568
|
||||
ATOM 593 N ILE I 76 -2.730 -19.221 16.019 1.00 11.90 2CI2 569
|
||||
ATOM 594 CA ILE I 76 -2.185 -19.433 14.667 1.00 12.65 2CI2 570
|
||||
ATOM 595 C ILE I 76 -3.342 -19.252 13.677 1.00 11.59 2CI2 571
|
||||
ATOM 596 O ILE I 76 -4.322 -20.009 13.762 1.00 14.18 2CI2 572
|
||||
ATOM 597 CB ILE I 76 -1.478 -20.810 14.457 1.00 9.22 2CI2 573
|
||||
ATOM 598 CG1 ILE I 76 -0.257 -21.048 15.354 1.00 13.74 2CI2 574
|
||||
ATOM 599 CG2 ILE I 76 -1.097 -21.028 12.960 1.00 6.37 2CI2 575
|
||||
ATOM 600 CD1 ILE I 76 0.140 -20.018 16.424 1.00 13.42 2CI2 576
|
||||
ATOM 601 N ALA I 77 -3.162 -18.316 12.767 1.00 9.88 2CI2 577
|
||||
ATOM 602 CA ALA I 77 -4.214 -17.967 11.809 1.00 8.17 2CI2 578
|
||||
ATOM 603 C ALA I 77 -4.079 -18.616 10.449 1.00 11.23 2CI2 579
|
||||
ATOM 604 O ALA I 77 -5.055 -18.635 9.669 1.00 11.49 2CI2 580
|
||||
ATOM 605 CB ALA I 77 -4.229 -16.428 11.726 1.00 4.65 2CI2 581
|
||||
ATOM 606 N GLU I 78 -2.891 -19.085 10.120 1.00 9.22 2CI2 582
|
||||
ATOM 607 CA GLU I 78 -2.597 -19.763 8.857 1.00 13.06 2CI2 583
|
||||
ATOM 608 C GLU I 78 -1.699 -20.960 9.151 1.00 10.24 2CI2 584
|
||||
ATOM 609 O GLU I 78 -1.083 -21.009 10.226 1.00 13.48 2CI2 585
|
||||
ATOM 610 CB GLU I 78 -1.928 -18.872 7.823 1.00 16.66 2CI2 586
|
||||
ATOM 611 CG GLU I 78 -1.442 -17.490 8.233 1.00 24.46 2CI2 587
|
||||
ATOM 612 CD GLU I 78 -1.217 -16.534 7.100 1.00 22.99 2CI2 588
|
||||
ATOM 613 OE1 GLU I 78 -0.765 -16.862 6.021 1.00 29.51 2CI2 589
|
||||
ATOM 614 OE2 GLU I 78 -1.530 -15.365 7.390 1.00 27.97 2CI2 590
|
||||
ATOM 615 N VAL I 79 -1.647 -21.889 8.224 1.00 12.11 2CI2 591
|
||||
ATOM 616 CA VAL I 79 -0.849 -23.111 8.362 1.00 11.23 2CI2 592
|
||||
ATOM 617 C VAL I 79 0.637 -22.743 8.418 1.00 10.70 2CI2 593
|
||||
ATOM 618 O VAL I 79 1.125 -22.175 7.430 1.00 12.86 2CI2 594
|
||||
ATOM 619 CB VAL I 79 -1.054 -24.095 7.183 1.00 13.33 2CI2 595
|
||||
ATOM 620 CG1 VAL I 79 -0.023 -25.223 7.255 1.00 10.05 2CI2 596
|
||||
ATOM 621 CG2 VAL I 79 -2.463 -24.645 7.074 1.00 10.55 2CI2 597
|
||||
ATOM 622 N PRO I 80 1.266 -23.104 9.509 1.00 9.97 2CI2 598
|
||||
ATOM 623 CA PRO I 80 2.714 -22.871 9.687 1.00 10.84 2CI2 599
|
||||
ATOM 624 C PRO I 80 3.493 -23.711 8.672 1.00 11.17 2CI2 600
|
||||
ATOM 625 O PRO I 80 3.107 -24.865 8.398 1.00 11.21 2CI2 601
|
||||
ATOM 626 CB PRO I 80 2.966 -23.306 11.130 1.00 12.38 2CI2 602
|
||||
ATOM 627 CG PRO I 80 1.620 -23.328 11.814 1.00 10.40 2CI2 603
|
||||
ATOM 628 CD PRO I 80 0.663 -23.737 10.696 1.00 11.53 2CI2 604
|
||||
ATOM 629 N ARG I 81 4.557 -23.162 8.131 1.00 10.29 2CI2 605
|
||||
ATOM 630 CA ARG I 81 5.395 -23.823 7.129 1.00 13.19 2CI2 606
|
||||
ATOM 631 C ARG I 81 6.855 -23.394 7.251 1.00 14.50 2CI2 607
|
||||
ATOM 632 O ARG I 81 7.114 -22.263 7.689 1.00 16.59 2CI2 608
|
||||
ATOM 633 CB ARG I 81 4.933 -23.501 5.698 1.00 14.36 2CI2 609
|
||||
ATOM 634 CG ARG I 81 3.956 -24.494 5.110 1.00 22.23 2CI2 610
|
||||
ATOM 635 CD ARG I 81 3.417 -24.045 3.794 1.00 33.13 2CI2 611
|
||||
ATOM 636 NE ARG I 81 2.449 -22.972 3.956 1.00 40.24 2CI2 612
|
||||
ATOM 637 CZ ARG I 81 1.124 -23.113 3.908 1.00 41.54 2CI2 613
|
||||
ATOM 638 NH1 ARG I 81 0.526 -24.221 3.488 1.00 40.91 2CI2 614
|
||||
ATOM 639 NH2 ARG I 81 0.385 -22.109 4.392 1.00 45.11 2CI2 615
|
||||
ATOM 640 N VAL I 82 7.747 -24.270 6.813 1.00 14.70 2CI2 616
|
||||
ATOM 641 CA VAL I 82 9.190 -23.996 6.828 1.00 13.66 2CI2 617
|
||||
ATOM 642 C VAL I 82 9.560 -22.976 5.747 1.00 13.30 2CI2 618
|
||||
ATOM 643 O VAL I 82 8.985 -23.009 4.640 1.00 12.70 2CI2 619
|
||||
ATOM 644 CB VAL I 82 10.004 -25.297 6.632 1.00 14.43 2CI2 620
|
||||
ATOM 645 CG1 VAL I 82 11.478 -24.982 6.349 1.00 17.60 2CI2 621
|
||||
ATOM 646 CG2 VAL I 82 9.882 -26.249 7.805 1.00 15.45 2CI2 622
|
||||
ATOM 647 N GLY I 83 10.551 -22.146 6.059 1.00 12.36 2CI2 623
|
||||
ATOM 648 CA GLY I 83 11.026 -21.174 5.057 1.00 13.03 2CI2 624
|
||||
ATOM 649 C GLY I 83 11.395 -19.829 5.657 1.00 11.77 2CI2 625
|
||||
ATOM 650 O GLY I 83 10.798 -19.541 6.714 1.00 15.36 2CI2 626
|
||||
ATOM 651 OXT GLY I 83 12.222 -19.137 5.054 1.00 16.40 2CI2 627
|
||||
TER 652 GLY I 83 2CI2 628
|
||||
HETATM 653 O HOH 84 -0.329 -13.254 6.640 1.00 24.81 2CI2 629
|
||||
HETATM 654 O HOH 85 20.537 -17.890 5.103 0.98 51.62 2CI2 630
|
||||
HETATM 655 O HOH 86 3.985 -5.480 6.143 0.93 22.19 2CI2 631
|
||||
HETATM 656 O HOH 87 13.612 -14.849 -5.298 1.00 37.67 2CI2 632
|
||||
HETATM 657 O HOH 88 2.323 -19.638 7.496 0.75 19.24 2CI2 633
|
||||
HETATM 658 O HOH 89 8.493 -20.055 7.668 1.00 10.51 2CI2 634
|
||||
HETATM 659 O HOH 90 1.392 -19.519 10.757 0.69 8.41 2CI2 635
|
||||
HETATM 660 O HOH 91 14.304 -32.137 12.328 0.88 20.39 2CI2 636
|
||||
HETATM 661 O HOH 92 8.165 -34.925 12.441 1.00 27.86 2CI2 637
|
||||
HETATM 662 O HOH 93 -3.208 -8.404 12.277 0.80 18.92 2CI2 638
|
||||
HETATM 663 O HOH 94 2.873 -36.659 17.649 0.48 20.25 2CI2 639
|
||||
HETATM 664 O HOH 95 -8.502 -16.494 17.981 1.00 6.91 2CI2 640
|
||||
HETATM 665 O HOH 96 13.110 -21.154 18.099 1.00 21.03 2CI2 641
|
||||
HETATM 666 O HOH 97 15.611 -24.679 18.097 1.00 16.43 2CI2 642
|
||||
HETATM 667 O HOH 98 -8.313 -18.290 22.531 1.00 34.75 2CI2 643
|
||||
HETATM 668 O HOH 99 6.311 -23.358 23.845 1.00 42.27 2CI2 644
|
||||
HETATM 669 O HOH 100 9.592 -7.442 4.540 1.00 21.71 2CI2 645
|
||||
HETATM 670 O HOH 101 17.915 -14.447 0.209 1.00 46.91 2CI2 646
|
||||
HETATM 671 O HOH 102 4.643 -20.183 7.815 0.79 11.79 2CI2 647
|
||||
HETATM 672 O HOH 103 8.776 -39.486 8.344 0.33 20.46 2CI2 648
|
||||
HETATM 673 O HOH 104 20.049 -19.093 13.191 0.88 25.50 2CI2 649
|
||||
HETATM 674 O HOH 105 -1.050 -35.346 12.637 0.98 32.03 2CI2 650
|
||||
HETATM 675 O HOH 106 -0.528 -37.282 13.452 0.74 34.20 2CI2 651
|
||||
HETATM 676 O HOH 107 -2.814 -10.035 13.791 0.52 7.98 2CI2 652
|
||||
HETATM 677 O HOH 108 7.629 -22.058 1.674 1.00 51.13 2CI2 653
|
||||
HETATM 678 O HOH 109 2.064 -5.457 11.942 1.00 65.35 2CI2 654
|
||||
HETATM 679 O HOH 110 23.048 -21.016 12.391 1.00 32.12 2CI2 655
|
||||
HETATM 680 O HOH 111 2.660 -35.407 12.320 1.00 37.99 2CI2 656
|
||||
HETATM 681 O HOH 112 19.516 -21.255 13.031 0.79 32.01 2CI2 657
|
||||
HETATM 682 O HOH 113 21.191 -22.240 18.079 0.59 21.14 2CI2 658
|
||||
HETATM 683 O HOH 114 6.941 -36.073 17.397 0.64 48.88 2CI2 659
|
||||
HETATM 684 O HOH 115 -10.533 -17.031 20.300 0.55 21.45 2CI2 660
|
||||
HETATM 685 O HOH 116 5.641 -38.800 22.958 1.00 52.61 2CI2 661
|
||||
HETATM 686 O HOH 117 19.782 -25.123 22.901 0.75 34.24 2CI2 662
|
||||
HETATM 687 O HOH 118 13.266 -20.427 23.057 0.64 34.89 2CI2 663
|
||||
HETATM 688 O HOH 119 -5.628 -30.359 22.925 0.73 48.31 2CI2 664
|
||||
HETATM 689 O HOH 120 8.529 -29.351 22.983 1.00 32.02 2CI2 665
|
||||
HETATM 690 O HOH 121 13.517 -29.044 26.642 0.86 34.70 2CI2 666
|
||||
HETATM 691 O HOH 122 0.323 -6.119 8.978 0.96 39.54 2CI2 667
|
||||
HETATM 692 O HOH 123 -4.037 -15.671 6.351 1.00 35.45 2CI2 668
|
||||
HETATM 693 O HOH 124 15.631 -11.826 -0.761 0.93 46.62 2CI2 669
|
||||
HETATM 694 O HOH 125 4.800 -4.562 12.199 1.00 39.72 2CI2 670
|
||||
HETATM 695 O HOH 126 13.468 -18.103 17.589 0.73 26.09 2CI2 671
|
||||
HETATM 696 O HOH 127 -3.023 -2.235 18.293 1.00 41.70 2CI2 672
|
||||
HETATM 697 O HOH 128 18.407 -24.479 17.873 0.52 9.70 2CI2 673
|
||||
HETATM 698 O HOH 129 -7.836 -2.378 19.154 0.73 60.68 2CI2 674
|
||||
HETATM 699 O HOH 130 21.030 -19.090 21.742 1.00 47.98 2CI2 675
|
||||
HETATM 700 O HOH 131 1.881 -32.214 22.846 0.83 46.85 2CI2 676
|
||||
HETATM 701 O HOH 132 -7.515 -4.664 22.763 0.83 35.53 2CI2 677
|
||||
HETATM 702 O HOH 133 -2.229 -10.591 22.682 1.00 50.61 2CI2 678
|
||||
HETATM 703 O HOH 134 22.150 -25.947 24.001 0.83 44.94 2CI2 679
|
||||
HETATM 704 O HOH 135 11.224 -29.647 8.973 0.70 19.43 2CI2 680
|
||||
HETATM 705 O HOH 136 5.258 -34.075 4.412 0.40 18.69 2CI2 681
|
||||
HETATM 706 O HOH 137 1.459 -39.256 4.127 0.60 23.87 2CI2 682
|
||||
HETATM 707 O HOH 138 4.530 -28.781 -0.047 1.00 43.13 2CI2 683
|
||||
HETATM 708 O HOH 139 11.913 -34.478 18.581 0.64 33.68 2CI2 684
|
||||
HETATM 709 O HOH 140 -5.065 -32.731 22.028 0.78 44.05 2CI2 685
|
||||
HETATM 710 O HOH 141 -2.568 -32.082 23.071 1.00 50.49 2CI2 686
|
||||
HETATM 711 O HOH 142 5.202 -19.362 24.595 1.00 47.01 2CI2 687
|
||||
HETATM 712 O HOH 143 8.744 -16.337 23.550 0.95 39.33 2CI2 688
|
||||
HETATM 713 O HOH 144 16.078 -37.479 4.200 1.00 32.94 2CI2 689
|
||||
HETATM 714 O HOH 145 -3.995 -3.539 23.173 0.45 29.34 2CI2 690
|
||||
HETATM 715 O HOH 146 -8.826 -33.316 22.007 0.73 42.83 2CI2 691
|
||||
HETATM 716 O HOH 147 -1.791 -21.764 25.717 0.74 27.23 2CI2 692
|
||||
MASTER 68 0 0 1 4 5 1 6 585 1 0 7 2CI2 693
|
||||
END 2CI2 694
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* check_equal.h
|
||||
* PDB-xcode
|
||||
*
|
||||
* Created by Daniel Russel on 2/7/07.
|
||||
* Copyright 2007 __MyCompanyName__. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
int return_code__=EXIT_SUCCESS;
|
||||
|
||||
void check_equal(std::istream &a, std::istream &b) {
|
||||
do {
|
||||
char bufa[1000];
|
||||
char bufb[1000];
|
||||
a.getline(bufa, 1000);
|
||||
b.getline(bufb, 1000);
|
||||
if (!a && !b) {
|
||||
break;
|
||||
} else if (!a) {
|
||||
std::cerr << "Source missing: " << bufb << std::endl;
|
||||
return_code__=EXIT_FAILURE;
|
||||
} else if (!b) {
|
||||
std::cerr << "Target missing: " << bufa << std::endl;
|
||||
return_code__=EXIT_FAILURE;
|
||||
} else {
|
||||
if (strcmp(bufa, bufb) != 0) {
|
||||
std::cerr << "Lines are not equal. They are \n";
|
||||
std::cerr << bufa << std::endl;
|
||||
std::cerr << bufb << std::endl;
|
||||
return_code__=EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
} while (true);
|
||||
}
|
||||
|
||||
|
|
@ -1 +0,0 @@
|
|||
- move distance_matrix to use CGAL image
|
||||
Loading…
Reference in New Issue