Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SpliceSegment.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 protocols/protein_interface_design/movers/Splice.cc
11 /// @brief
12 /// @author Sarel Fleishman (sarel@weizmann.ac.il)
13 
14 // Unit headers
17 #include <utility/exit.hh>
18 #include <boost/foreach.hpp>
19 #define foreach BOOST_FOREACH
20 // Package headers
21 #include <basic/Tracer.hh>
22 #include <utility/vector1.hh>
23 #include <utility/file/FileName.hh>
24 #include <utility/io/izstream.hh>
25 #include <iostream>
26 #include <sstream>
27 
28 namespace protocols {
29 namespace protein_interface_design {
30 namespace movers {
31 
32 static basic::Tracer TR( "protocols.protein_interface_design.movers.SpliceSegment" );
33 
34 using namespace core::sequence;
35 using namespace std;
36 
38  sequence_profile_.clear();
39  pdb_to_profile_map_.clear();
40 }
41 
43 
44 void
45 SpliceSegment::read_profile( string const file_name, string const segment_name ){
46  SequenceProfileOP new_seqprof( new SequenceProfile );
47  utility::file::FileName const fname( file_name );
48  TR<<"reading sequence profile from "<<file_name<<std::endl;
49  new_seqprof->read_from_file( fname );
50  sequence_profile_.insert( pair< string, SequenceProfileOP >( segment_name, new_seqprof ) );
51 }
52 
55  return sequence_profile_[ segment_name ];
56 }
57 
58 void
59 SpliceSegment::add_pdb_profile_pair( std::string const pdb, string const profile_name ){
60  pdb_to_profile_map_.insert( pair< string, string >( pdb, profile_name ) );
61 }
62 
63 /// @brief this is the most useful method, returning the sequence profile according to a pdb file name
66  return sequence_profile_[ pdb_to_profile_map_[ pdb_name ] ];
67 }
68 
70 SpliceSegment::sequence_profile( string const profile_name ){
71  return sequence_profile_[ profile_name ];
72 }
73 
74 /// @brief generate one long sequence profile out of several sequence-profile segments.
77  SequenceProfileOP concatenated_profile( new SequenceProfile );
78  core::Size current_profile_size( 0 );
79  foreach( SequenceProfileOP const prof, profiles ){
80  for( core::Size pos = 1; pos <= prof->size(); ++pos ){
81  current_profile_size++;
82  concatenated_profile->prof_row( prof->prof_row( pos ), current_profile_size );
83  }
84  }
85  TR<<"concatenated "<<profiles.size()<<" profiles with a total length of "<<concatenated_profile->size()<<std::endl;
86  return concatenated_profile;
87 }
88 
89 /// @brief reads the pdb-profile match file, matching each pdb file to one profile
90 void
92  utility::io::izstream data( file_name );
93  if ( !data )
94  utility_exit_with_message( "File not found " + file_name );
95  TR<<"Loading pdb profile pairs from file "<<file_name<<std::endl;
96  string line;
97  getline( data, line );
98  if( line.length() > 2 )
99  utility_exit_with_message( "pdb/profile file empty or corrupted "+file_name );
100  istringstream line_stream( line );
101  while( !line_stream.eof() ){
102  std::string pdb, profile;
103  line_stream >> pdb >> profile;
104  pdb_to_profile_map_.insert( pair< string, string >( pdb, profile ) );
105  }
106 }
107 
108 } //movers
109 } //protein_interface_design
110 } //protocols