Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
L1ScoringScheme.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 L1ScoringScheme.cc
11 /// @brief method implementations for L1ScoringScheme class.
12 /// @author James Thompson
13 
14 #include <core/types.hh>
19 
20 #include <utility/exit.hh>
21 // AUTO-REMOVED #include <iostream>
22 #include <string>
23 
24 #include <complex>
25 
26 #include <utility/vector1.hh>
27 
28 
29 
30 namespace core {
31 namespace sequence {
32 
34  SequenceOP seq1,
35  SequenceOP seq2,
36  Size pos1,
37  Size pos2
38  ) {
40  static_cast < SequenceProfile * > ( seq1() )
41  );
43  static_cast < SequenceProfile * > ( seq2() )
44  );
45 
46  runtime_assert( pos1 <= prof1->length() );
47  runtime_assert( pos2 <= prof2->length() );
48  runtime_assert( prof1->prof_row(pos1).size() == prof2->prof_row(pos2).size() );
49 
50  // compare the two profiles using L1 city-block distance
51  Size n_aa( prof1->prof_row(pos1).size() );
52  Real score( 0.0 );
53  for ( Size i = 1; i <= n_aa; ++i ) {
54  Real const & p1_num( prof1->prof_row(pos1)[i] );
55  Real const & p2_num( prof2->prof_row(pos2)[i] );
56  if ( is_good( p1_num ) && is_good( p2_num ) ) {
57  //for ( Size jj = 1; jj < i; ++jj ) std::cout << " ";
58  //std::cout << "comparing " << p1_num << " and " << p2_num << std::endl;
59  score += std::abs( p1_num - p2_num );
60  } else {
61  score += 1.0;
62  }
63  }
64 
65  score *= -1;
66  // make the score a positive number where bigger is better!
67  //std::cout << "score(" << pos1 << "," << pos2 << ") = " << score
68  // << std::endl << std::endl;
69  return score;
70 
71  // pseudocount a little to prevent score fom being 0.
72  //Real const very_small_value( 1e-15 );
73  //if ( score <= very_small_value ) score = very_small_value;
74  //return std::exp( -1 * score );
75  } // score
76 
77 } // sequence
78 } // core