Rosetta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
super_aln.cc
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file
11 /// @brief
12 /// @author James Thompson
13 
14 // libRosetta headers
15 
16 #include <core/types.hh>
17 
18 #include <devel/init.hh>
19 #include <core/conformation/Residue.hh>
20 #include <core/chemical/ChemicalManager.hh>
21 #include <core/pose/Pose.hh>
22 #include <core/scoring/rms_util.hh>
23 
24 #include <core/import_pose/pose_stream/PoseInputStream.hh>
25 #include <core/import_pose/pose_stream/PoseInputStream.fwd.hh>
26 #include <core/import_pose/pose_stream/PDBPoseInputStream.hh>
27 
28 #include <core/id/AtomID.hh>
29 #include <core/id/AtomID_Map.hh>
30 
31 #include <utility/vector1.hh>
33 #include <numeric/xyzVector.hh>
34 
35 #include <core/sequence/util.hh>
36 #include <core/id/SequenceMapping.hh>
37 #include <core/sequence/SequenceAlignment.hh>
38 
39 using core::Size;
40 using core::Real;
41 using utility::vector1;
42 
43 // option key includes
44 #include <basic/options/option.hh>
45 #include <basic/options/keys/in.OptionKeys.gen.hh>
46 #include <basic/options/keys/cm.OptionKeys.gen.hh>
47 #include <basic/options/keys/out.OptionKeys.gen.hh>
48 
49 #include <core/pose/util.hh>
50 
51 //Auto Headers
52 #include <core/pose/util.tmpl.hh>
53 
54 int
55 main( int argc, char * argv [] ) {
56  try {
57 
58  using namespace core::chemical;
59  using namespace basic::options::OptionKeys;
60  using namespace basic::options;
61  using namespace core::import_pose::pose_stream;
62 
63  using core::id::AtomID;
64  using core::id::AtomID_Map;
65  using utility::vector1;
66  using core::id::SequenceMapping;
67  using core::sequence::SequenceAlignment;
68 
69  devel::init( argc, argv );
70 
71  // setup residue types
72  ResidueTypeSetCOP rsd_set =
73  ChemicalManager::get_instance()->residue_type_set( "fa_standard" );
74 
75  PoseInputStreamOP pdb_input( new PDBPoseInputStream( option[ in::file::s ]() ) );
76 
77  core::pose::Pose pose1, pose2;
78  pdb_input->fill_pose( pose1, *rsd_set );
79  pdb_input->fill_pose( pose2, *rsd_set );
80 
81  vector1< std::string > align_fns = option[ in::file::alignment ]();
82  vector1< SequenceAlignment > alns = core::sequence::read_aln(
83  option[ cm::aln_format ](), align_fns.front()
84  );
85 
86  SequenceAlignment aln = alns.front();
87  SequenceMapping mapping = aln.sequence_mapping(1,2);
88 
90 
91  if ( option[ in::target_residues ].user() ) {
92  // user-specified residues
93  residues = option[ in::target_residues ]();
94  } else {
95  // use all aligned residues
96  for ( Size ii = 1; ii <= pose1.total_residue(); ++ii ) {
97  residues.push_back(ii);
98  }
99  }
100 
101  AtomID_Map< AtomID > atom_map;
102  core::pose::initialize_atomid_map( atom_map, pose1, core::id::BOGUS_ATOM_ID );
103  typedef vector1< Size >::const_iterator iter;
104  for ( iter it = residues.begin(), end = residues.end(); it != end; ++it ) {
105  Size const templ_ii( mapping[*it] );
106  if ( templ_ii == 0 ) {
107  continue;
108  }
109  if ( ! pose1.residue(*it).has("CA") ) continue;
110  if ( ! pose2.residue(templ_ii).has("CA") ) continue;
111  //std::cout << *it << " => " << templ_ii << std::endl;
112  AtomID const id1( pose1.residue(*it).atom_index("CA"), *it );
113  AtomID const id2( pose2.residue(templ_ii).atom_index("CA"), templ_ii );
114  atom_map.set( id1, id2 );
115  }
116 
117  using core::scoring::superimpose_pose;
118  // rmsd numbers look wrong ...
119  //core::Real const rmsd( superimpose_pose( pose1, pose2, atom_map ) );
120  //std::cout << "superimposed with rmsd of " << rmsd << std::endl;
121  superimpose_pose( pose1, pose2, atom_map );
123  std::string output_name( fns[1] + ".super.pdb" );
124  if ( option[ out::file::o ].user() ) {
125  output_name = option[ out::file::o ]();
126  }
127  pose1.dump_pdb( output_name );
128  std::cout << "wrote pdb with name " << output_name << std::endl;
129  } catch ( utility::excn::EXCN_Base const & e ) {
130  std::cout << "caught exception " << e.msg() << std::endl;
131  return -1;
132  }
133 
134  return 0;
135 } // int main
virtual std::string const msg() const
Definition: EXCN_Base.hh:70
void init(int argc, char *argv[])
Command line init() version.
Definition: init.cc:23
BooleanOptionKey const user("options:user")
Definition: OptionKeys.hh:40
core::pose::Pose Pose
Definition: supercharge.cc:101
utility::keys::lookup::end< KeyType > const end
common derived classes for thrown exceptions
int main(int argc, char *argv[])
Definition: super_aln.cc:55
std::vector with 1-based indexing
Definition: vector1.fwd.hh:44
rule< Scanner, options_closure::context_t > options
Definition: Tag.cc:377
double Real
Definition: types.hh:39
ocstream cout(std::cout)
Wrapper around std::cout.
Definition: ocstream.hh:287
vector1: std::vector with 1-based indexing
Program options global and initialization function.
Fast (x,y,z)-coordinate numeric vector.
platform::Size Size
Definition: random.fwd.hh:30
rule< Scanner, option_closure::context_t > option
Definition: Tag.cc:378