Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ChemicalShiftScoringScheme.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 ChemicalShiftScoringScheme.cc
11 /// @brief method implementations for ChemicalShiftScoringScheme 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  core::Size pos1,
37  core::Size pos2
38 ) {
39 
40  using core::Size;
41  using core::Real;
42 
44  dynamic_cast< ChemicalShiftSequence * > ( seq1() )
45  );
47  dynamic_cast< ChemicalShiftSequence * > ( seq2() )
48  );
49 
50  runtime_assert( pos1 <= prof1->length() );
51  runtime_assert( pos2 <= prof2->length() );
52  runtime_assert( prof1->prof_row(pos1).size() == prof2->prof_row(pos2).size() );
53 
54  //CA.q.dat.dev 0.828795509906
55  //CB.q.dat.dev 0.969003290496
56  //C.q.dat.dev 0.948093982461
57  //HA.q.dat.dev 0.231641960268
58  //HN.q.dat.dev 0.725943902221
59  //N.q.dat.dev 2.78164308475
60 
61  Real const a(2), b(4); // constants for sigmoid smoothing trick
62 
63  Size n_aa( prof1->prof_row(pos1).size() );
64  Size count( 0 );
65  Real score( 0.0 );
66  for ( Size i = 1; i <= n_aa; ++i ) {
67  Real const & q_shift( prof1->prof_row(pos1)[i] );
68  Real const & v_shift( prof2->prof_row(pos2)[i] );
69  Real const & v_sigma( prof2->sigma(pos2,i) );
70 
71  if ( is_good( q_shift ) && is_good( v_shift ) ) {
72  Real sig_diff(std::abs((q_shift - v_shift) / v_sigma ));
73  Real sigmoid_diff( 1 / ( 1 + exp((a*sig_diff)-b) ) );
74 
75  //for ( Size jj = 1; jj < i; ++jj ) std::cout << " ";
76  //std::cout << "comparing " << q_shift << " and " << v_shift <<
77  // " (sig_diff = " << sig_diff << ")" << std::endl <<
78  // " (v_sigma = " << v_sigma << ")" << std::endl;
79  //for ( Size jj = 1; jj < i; ++jj ) std::cout << " ";
80  //std::cout << "sigmoid_diff = " << sigmoid_diff << std::endl;
81 
82  ++count;
83  score += sigmoid_diff;
84  }
85  }
86 
87  if ( count != 0 ) {
88  score = ( score / count ) * n_aa;
89  }
90 
91  //score *= 3;
92  //std::cout << "score(" << pos1 << "," << pos2 << ") = " << score
93  // << std::endl << std::endl;
94 
95  return score;
96 } // score
97 
98 } // sequence
99 } // core