NCBI C++ ToolKit
score_builder_unit_test.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: score_builder_unit_test.cpp 93090 2021-03-04 15:04:45Z grichenk $
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government have not placed any restriction on its use or reproduction.
13 *
14 * Although all reasonable efforts have been taken to ensure the accuracy
15 * and reliability of the software and data, the NLM and the U.S.
16 * Government do not and cannot warrant the performance or results that
17 * may be obtained by using this software or data. The NLM and the U.S.
18 * Government disclaim all warranties, express or implied, including
19 * warranties of performance, merchantability or fitness for any particular
20 * purpose.
21 *
22 * Please cite the author in any work or product based on this material.
23 *
24 * ===========================================================================
25 *
26 * Author: Christiam Camacho, NCBI
27 *
28 * File Description:
29 * Unit tests for the CScoreBuilder class.
30 *
31 * NOTE:
32 * Boost.Test reports some memory leaks when compiled in MSVC even for this
33 * simple code. Maybe it's related to some toolkit static variables.
34 * To avoid annoying messages about memory leaks run this program with
35 * parameter --detect_memory_leak=0
36 *
37 * ===========================================================================
38 */
39 
40 #include <ncbi_pch.hpp>
41 
42 // This macro should be defined before inclusion of test_boost.hpp in all
43 // "*.cpp" files inside executable except one. It is like function main() for
44 // non-Boost.Test executables is defined only in one *.cpp file - other files
45 // should not include it. If NCBI_BOOST_NO_AUTO_TEST_MAIN will not be defined
46 // then test_boost.hpp will define such "main()" function for tests.
47 //
48 // Usually if your unit tests contain only one *.cpp file you should not
49 // care about this macro at all.
50 //
51 //#undef NCBI_BOOST_NO_AUTO_TEST_MAIN
52 
53 
54 // This header must be included before all Boost.Test headers if there are any
55 #include <corelib/test_boost.hpp>
63 #include <objmgr/scope.hpp>
65 
66 #include <serial/serial.hpp>
67 #include <serial/objistr.hpp>
68 
69 #include <common/test_assert.h> /* This header must go last */
70 
71 extern const std::string sc_TestEntries;
72 
75 
77 {
78  // Here we make descriptions of command line parameters that we are
79  // going to use.
80 
81  arg_desc->AddKey("data-in", "InputData",
82  "Concatenated Seq-aligns used to generate gene models",
84 }
85 
86 
87 BOOST_AUTO_TEST_CASE(Test_Score_Builder)
88 {
91  CRef<CScope> scope(new CScope(*om));
92  scope->AddDefaults();
93 
94  {{
96  while (istr) {
97  CRef<CSeq_entry> entry(new CSeq_entry);
98  try {
99  istr >> MSerial_AsnText >> *entry;
100  }
101  catch (CEofException&) {
102  break;
103  }
104  scope->AddTopLevelSeqEntry(*entry);
105  }
106  }}
107 
108 
109  CScoreBuilder score_builder(blast::eBlastn);
110 
111  const CArgs& args = CNcbiApplication::Instance()->GetArgs();
112  CNcbiIstream& istr = args["data-in"].AsInputFile();
113  while (istr) {
114  CSeq_align alignment;
115  try {
116  istr >> MSerial_AsnText >> alignment;
117  }
118  catch (CEofException&) {
119  break;
120  }
121 
122  switch (alignment.GetSegs().Which()) {
124  LOG_POST(Error << "checking alignment: Dense-seg");
125  break;
127  LOG_POST(Error << "checking alignment: Disc");
128  break;
130  LOG_POST(Error << "checking alignment: Std-seg");
131  break;
133  LOG_POST(Error << "checking alignment: Spliced-seg");
134  break;
135 
136  default:
137  LOG_POST(Error << "checking alignment: unknown");
138  break;
139  }
140 
141  ///
142  /// we test several distinct scores
143  ///
144 
145  int kExpectedIdentities = 0;
147  kExpectedIdentities);
148 
149  int kExpectedMismatches = 0;
151  kExpectedMismatches);
152 
153  int kExpectedGapOpen = 0;
154  alignment.GetNamedScore("gapopen",
155  kExpectedGapOpen);
156 
157  int kExpectedGaps = 0;
158  alignment.GetNamedScore("gap_bases",
159  kExpectedGaps);
160 
161  int kExpectedLength = 0;
162  alignment.GetNamedScore("length",
163  kExpectedLength);
164 
165  int kExpectedScore = 0;
167  kExpectedScore);
168 
169  double kExpectedPctIdentity_Gapped = 0;
171  kExpectedPctIdentity_Gapped);
172 
173  double kExpectedPctIdentity_Ungapped = 0;
175  kExpectedPctIdentity_Ungapped);
176 
177  double kExpectedPctIdentity_GapOpeningOnly = 0;
179  kExpectedPctIdentity_GapOpeningOnly);
180 
181  double kExpectedPctCoverage = 0;
183  kExpectedPctCoverage);
184 
185  double kExpectedHighQualityPctCoverage = 0;
187  kExpectedHighQualityPctCoverage);
188 
189  int kExpectedPositiveCount = -1;
191  kExpectedPositiveCount);
192 
193  int kExpectedNegativeCount = -1;
195  kExpectedNegativeCount);
196 
197  map<string,double> expected_scores;
198  ITERATE (CSeq_align::TScore, score_it, alignment.GetScore()) {
199  if ((*score_it)->GetId().IsStr()) {
200  expected_scores[(*score_it)->GetId().GetStr()] =
201  (*score_it)->GetValue().IsReal()
202  ? (*score_it)->GetValue().GetReal()
203  : (double)(*score_it)->GetValue().GetInt();
204  }
205  }
206 
207  /// reset scores to avoid any taint in score generation
208  alignment.ResetScore();
209 
210  /// check alignment length
211  {{
212  int actual =
213  score_builder.GetAlignLength(alignment);
214  LOG_POST(Error << "Verifying score: length: "
215  << kExpectedLength << " == " << actual);
216  BOOST_CHECK_EQUAL(kExpectedLength, actual);
217  }}
218 
219  /// check identity count
220  /// NB: not for std-segs!
221  if ( !alignment.GetSegs().IsStd() ) {
222  int actual =
223  score_builder.GetIdentityCount(*scope, alignment);
224  LOG_POST(Error << "Verifying score: num_ident: "
225  << kExpectedIdentities << " == " << actual);
226  BOOST_CHECK_EQUAL(kExpectedIdentities, actual);
227  }
228 
229  /// check mismatch count
230  if ( !alignment.GetSegs().IsStd() ) {
231  int actual =
232  score_builder.GetMismatchCount(*scope, alignment);
233  LOG_POST(Error << "Verifying score: num_mismatch: "
234  << kExpectedMismatches << " == " << actual);
235  BOOST_CHECK_EQUAL(kExpectedMismatches, actual);
236  }
237 
238  /// check uninitialized / wrongly initialized variables
239  /// (CXX-1594 - GetMismatchCount() adds to incoming values blindly)
240  if ( !alignment.GetSegs().IsStd() ) {
241  int mismatches = 1000;
242  int identities = 1000;
243  score_builder.GetMismatchCount(*scope, alignment,
244  identities, mismatches);
245  BOOST_CHECK_EQUAL(kExpectedMismatches, mismatches);
246  BOOST_CHECK_EQUAL(kExpectedIdentities, identities);
247  }
248 
249  /// check gap count (= gap openings)
250  {{
251  int actual =
252  score_builder.GetGapCount(alignment);
253  LOG_POST(Error << "Verifying score: gapopen: "
254  << kExpectedGapOpen << " == " << actual);
255  BOOST_CHECK_EQUAL(kExpectedGapOpen, actual);
256  }}
257 
258  /// check gap base length (= sum of lengths of all gaps)
259  if ( !alignment.GetSegs().IsStd() ) {
260  int actual =
261  score_builder.GetGapBaseCount(alignment);
262  LOG_POST(Error << "Verifying score: gap_bases: "
263  << kExpectedGaps << " == " << actual);
264  BOOST_CHECK_EQUAL(kExpectedGaps, actual);
265  }
266 
267  /// check percent identity (gapped)
268  if ( !alignment.GetSegs().IsStd() ) {
269  double actual =
270  score_builder.GetPercentIdentity(*scope, alignment,
272  LOG_POST(Error << "Verifying score: pct_identity_gap: "
273  << kExpectedPctIdentity_Gapped << " == " << actual);
274 
275  /// machine precision is a problem here
276  /// we verify to 12 digits of precision
277  BOOST_CHECK_CLOSE(kExpectedPctIdentity_Gapped,
278  actual, 1e-12);
279 
280  /**
281  CScore score;
282  score.SetId().SetStr("pct_identity_gap");
283  score.SetValue().SetReal(actual);
284  cerr << MSerial_AsnText << score;
285  **/
286  }
287 
288  /// check percent identity (ungapped)
289  if ( !alignment.GetSegs().IsStd() ) {
290  double actual =
291  score_builder.GetPercentIdentity(*scope, alignment,
293  LOG_POST(Error << "Verifying score: pct_identity_ungap: "
294  << kExpectedPctIdentity_Ungapped << " == " << actual);
295 
296  /// machine precision is a problem here
297  /// we verify to 12 digits of precision
298  BOOST_CHECK_CLOSE(kExpectedPctIdentity_Ungapped,
299  actual, 1e-12);
300 
301  /**
302  CScore score;
303  score.SetId().SetStr("pct_identity_ungap");
304  score.SetValue().SetReal(actual);
305  cerr << MSerial_AsnText << score;
306  **/
307  }
308 
309  /// check percent identity (GapOpeningOnly-style)
310  if ( !alignment.GetSegs().IsStd() ) {
311  double actual =
312  score_builder.GetPercentIdentity(*scope, alignment,
314  LOG_POST(Error << "Verifying score: pct_identity_gapopen_only: "
315  << kExpectedPctIdentity_GapOpeningOnly << " == " << actual);
316 
317  /// machine precision is a problem here
318  /// we verify to 12 digits of precision
319  BOOST_CHECK_CLOSE(kExpectedPctIdentity_GapOpeningOnly,
320  actual, 1e-12);
321 
322  /**
323  CScore score;
324  score.SetId().SetStr("pct_identity_gbdna");
325  score.SetValue().SetReal(actual);
326  cerr << MSerial_AsnText << score;
327  **/
328  }
329 
330  /// check percent coverage
331  {{
332  double actual =
333  score_builder.GetPercentCoverage(*scope, alignment);
334  LOG_POST(Error << "Verifying score: pct_coverage: "
335  << kExpectedPctCoverage << " == " << actual);
336 
337  /// machine precision is a problem here
338  /// we verify to 12 digits of precision
339  BOOST_CHECK_CLOSE(kExpectedPctCoverage,
340  actual, 1e-12);
341 
342  /**
343  CScore score;
344  score.SetId().SetStr("pct_coverage");
345  score.SetValue().SetReal(actual);
346  cerr << MSerial_AsnText << score;
347  **/
348  }}
349 
350  /// check high-quality percent coverage if data has it
351  if ( !alignment.GetSegs().IsStd() ) {
352  double actual = 0.0;
353  score_builder.AddScore(*scope, alignment,
356  LOG_POST(Error << "Verifying score: pct_coverage_hiqual: "
357  << kExpectedHighQualityPctCoverage << " == " << actual);
358 
359  /// machine precision is a problem here
360  /// we verify to 12 digits of precision
361  BOOST_CHECK_CLOSE(kExpectedHighQualityPctCoverage,
362  actual, 1e-12);
363 
364  /**
365  CScore score;
366  score.SetId().SetStr("pct_coverage_hiqual");
367  score.SetValue().SetReal(actual);
368  cerr << MSerial_AsnText << score;
369  **/
370  }
371 
372  if (alignment.GetSegs().IsDenseg()) {
373  ///
374  /// our encoded dense-segs have a BLAST-style 'score'
375  ///
376  int actual =
377  score_builder.GetBlastScore(*scope, alignment);
378  LOG_POST(Error << "Verifying score: score: "
379  << kExpectedScore << " == " << actual);
380  BOOST_CHECK_EQUAL(kExpectedScore, actual);
381  }
382 
383  if (kExpectedPositiveCount >= 0) {
384  int actual = 0.0;
385  score_builder.AddScore(*scope, alignment,
388  LOG_POST(Error << "Verifying score: num_positives: "
389  << kExpectedPositiveCount << " == " << actual);
390  BOOST_CHECK_EQUAL(kExpectedPositiveCount, actual);
391  score_builder.AddScore(*scope, alignment,
394  LOG_POST(Error << "Verifying score: num_negatives: "
395  << kExpectedNegativeCount << " == " << actual);
396  BOOST_CHECK_EQUAL(kExpectedNegativeCount, actual);
397  }
398 
399  if (alignment.GetSegs().IsSpliced() &&
400  alignment.GetSegs().GetSpliced().GetProduct_type() ==
402  {
403  score_builder.AddSplignScores(alignment);
404 
405  ITERATE (CSeq_align::TScore, score_it, alignment.GetScore()) {
406  string score_name = (*score_it)->GetId().GetStr();
407  double actual =
408  (*score_it)->GetValue().IsReal()
409  ? (*score_it)->GetValue().GetReal()
410  : (double)(*score_it)->GetValue().GetInt();
411  double expected = expected_scores[score_name];
412  LOG_POST(Error << "Verifying score: " << score_name << ": "
413  << expected << " == " << actual);
414 
415  BOOST_CHECK_CLOSE(expected, actual, 1e-12);
416  }
417  }
418  }
419 }
420 
421 const string sc_TestEntries = "\
422 Seq-entry ::= seq {\
423  id {\
424  general {\
425  db \"dbEST\",\
426  tag id 5929311\
427  },\
428  genbank {\
429  accession \"BE669435\",\
430  version 1\
431  },\
432  gi 10029976\
433  },\
434  inst {\
435  repr raw,\
436  mol rna,\
437  length 683,\
438  strand ss,\
439  seq-data ncbi2na 'FFC14200700A8BEB8084DFE879F774BD79ED210DE0B1FF0BB05E7470\
440 5749784549CEEDBEDF847BBA827FAFA9044FB40BC0350ECDD4D4E2B4F5838E8F53B44B7099D0E0\
441 4E5350B47EA27DD7AE882953DE53253E49E7468A2C9554A91D3793AAEA92291FB12BB7D1FAB4A6\
442 BD3158AEEA93AE7C5BBAA4AA195BC1E48EDE7893B526EACEA27A8F4D3FE7388E5E9E532BE13858\
443 3CA9D3CE1BDE852C769EFA9EA7144E3413BB8C3B7C1EA1A22C20'H\
444  },\
445  annot {\
446  {\
447  desc {\
448  name \"NCBI_GPIPE\"\
449  },\
450  data ftable {\
451  {\
452  data region \"alignable\",\
453  location int {\
454  from 0,\
455  to 426,\
456  strand unknown,\
457  id gi 10029976\
458  }\
459  }\
460  }\
461  }\
462  }\
463 }\
464 Seq-entry ::= seq {\
465  id {\
466  general {\
467  db \"dbEST\",\
468  tag id 5929424\
469  },\
470  genbank {\
471  accession \"BE669548\",\
472  version 1\
473  },\
474  gi 10030089\
475  },\
476  inst {\
477  repr raw,\
478  mol rna,\
479  length 470,\
480  strand ss,\
481  seq-data ncbi2na 'E6965809820A09D79575C09E09409829FC0A504292EF80AED4494400\
482 8208D646D1517D69A58211E61D6884950335DA0899D52880427E14739CD342FD67851E2DE53810\
483 8C81104111FBBD3EE8EF0250424523C04A7B8209ECE13E3BAD06D04578F7978E88820A4CEF61E9\
484 D78F18E7FA3BE50403E234D0'H\
485  },\
486  annot {\
487  {\
488  desc {\
489  name \"NCBI_GPIPE\"\
490  },\
491  data ftable {\
492  {\
493  data region \"alignable\",\
494  location int {\
495  from 0,\
496  to 417,\
497  strand unknown,\
498  id gi 10030089\
499  }\
500  }\
501  }\
502  }\
503  }\
504 }\
505 Seq-entry ::= seq {\
506  id {\
507  general {\
508  db \"dbEST\",\
509  tag id 5929425\
510  },\
511  genbank {\
512  accession \"BE669549\",\
513  version 1\
514  },\
515  gi 10030090\
516  },\
517  inst {\
518  repr raw,\
519  mol rna,\
520  length 490,\
521  strand ss,\
522  seq-data ncbi2na 'D108E9960260828275E55D70278250260A7F029420A4BBE02BB51251\
523 0020823591B4545F5A69608479875A212540CD768226754A20109F851CE734D0BF59E1478B794E\
524 0823208410447EEF4FBA3BC094109148F0129EE0827B384F8EE942B4115E3DA5E3A22082933BD8\
525 7A75E3C639FE8EF94100FA8D3701E2D490'H\
526  },\
527  annot {\
528  {\
529  desc {\
530  name \"NCBI_GPIPE\"\
531  },\
532  data ftable {\
533  {\
534  data region \"alignable\",\
535  location int {\
536  from 0,\
537  to 438,\
538  strand unknown,\
539  id gi 10030090\
540  }\
541  }\
542  }\
543  }\
544  }\
545 }\
546 Seq-entry ::= seq {\
547  id {\
548  general {\
549  db \"GENEMARK\",\
550  tag id 4295\
551  }\
552  },\
553  descr {\
554  molinfo {\
555  biomol peptide,\
556  completeness complete\
557  }\
558  },\
559  inst {\
560  repr raw,\
561  mol aa,\
562  length 642,\
563  seq-data iupacaa \"MFITRTFSDMKIGKKLGLSFGVLIVATLAIALLAFKGFQSIKENSAKQDVTV\
564 NMVNTLSKARMNRLLYQYTKDEQYAQVNARALNELSAHFDTLKKFDWNAQGEQQLDVLGSALQSYQTLRQAFYLASKK\
565 TFAASAVIQGNDLLTLGQSLDGVNIPAQPEAMLQVLRLASLLKEVAGDVERFIDKPTEASKVEIYGNITSIEQIRTQL\
566 SALAIPEIQTVLNTQKTDLTQLKQAFTDYMTAVGAEAAASSQLSAVAEKLNTSVAELFDYQASESTSALLNAERQIAV\
567 VAALCILLSLLVAWRITRAITVPLKETLSVAQRISEGDLTATLSTTRRDELGQLMQAVSVMNESLQNIITNVRDGVNS\
568 VARASSEIAAGNMDLSSRTEQQSAAVVQTAASMEELTSTVKQNAENAHHASQLATEASANAGRGGDIIRNVVTTMQGI\
569 TTSSGKIGEIISVINGISFQTNILALNAAVEAARAGEQGRGFAVVAGEVRNLAQRSSVAAKEIETLIRDSLHRVNEGS\
570 TLVDQAGSTMDEIVLSVTQVKDIMSEIAAASDEQNRGISQIAQAMTEMDTTTQQNAALVEESSAAASSLESQAEELEK\
571 TVAVFRLPANKSGMAVSHSTAKSVTKAPVSLRQPNPAEGNWETF\"\
572  }\
573 }\
574 ";
575 
576 BOOST_AUTO_TEST_CASE(Test_GetBlastScore)
577 {
580  CRef<CScope> scope(new CScope(*om));
581  scope->AddDefaults();
582 
583 string buf = " \
584 Seq-align ::= { \
585  type partial, \
586  dim 2, \
587  segs denseg { \
588  dim 2, \
589  numseg 3, \
590  ids { \
591  gi 446828913, \
592  gi 16763395 \
593  }, \
594  starts { \
595  0, 0, \
596  44, -1, \
597  56, 44 \
598  }, \
599  lens { \
600  44, \
601  12, \
602  213 \
603  }, \
604  strands { \
605  unknown, unknown, \
606  unknown, unknown, \
607  unknown, unknown \
608  } } } \
609 Seq-align ::= { \
610  type partial, \
611  dim 2, \
612  segs std { \
613  { \
614  dim 2, \
615  ids { \
616  gi 446828913, \
617  gi 16763395 \
618  }, \
619  loc { \
620  int { \
621  from 0, to 43, \
622  strand unknown, \
623  id gi 446828913 \
624  }, \
625  int { \
626  from 0, to 43, \
627  strand unknown, \
628  id gi 16763395 \
629  } } }, \
630  { \
631  dim 2, \
632  ids { \
633  gi 446828913, \
634  gi 16763395 \
635  }, \
636  loc { \
637  int { \
638  from 44, to 55, \
639  strand unknown, \
640  id gi 446828913 \
641  }, \
642  empty gi 16763395 \
643  } }, \
644  { \
645  dim 2, \
646  ids { \
647  gi 446828913, \
648  gi 16763395 \
649  }, \
650  loc { \
651  int { \
652  from 56, to 268, \
653  strand unknown, \
654  id gi 446828913 \
655  }, \
656  int { \
657  from 44, to 256, \
658  strand unknown, \
659  id gi 16763395 \
660  } } } } } \
661 Seq-align ::= { \
662  type partial, \
663  dim 2, \
664  segs std { \
665  { \
666  dim 2, \
667  ids { \
668  gi 446828913, \
669  gi 16763390 \
670  }, \
671  loc { \
672  int { \
673  from 0, to 43, \
674  strand unknown, \
675  id gi 446828913 \
676  }, \
677  int { \
678  from 5755, to 5886, \
679  strand minus, \
680  id gi 16763390 \
681  } } }, \
682  { \
683  dim 2, \
684  ids { \
685  gi 446828913, \
686  gi 16763390 \
687  }, \
688  loc { \
689  int { \
690  from 44, to 55, \
691  strand unknown, \
692  id gi 446828913 \
693  }, \
694  empty gi 16763390 \
695  } }, \
696  { \
697  dim 2, \
698  ids { \
699  gi 446828913, \
700  gi 16763390 \
701  }, \
702  loc { \
703  int { \
704  from 56, to 268, \
705  strand unknown, \
706  id gi 446828913 \
707  }, \
708  int { \
709  from 5116, to 5754, \
710  strand minus, \
711  id gi 16763390 \
712  } } } } } \
713 Seq-align ::= { \
714  type global, \
715  dim 2, \
716  segs spliced { \
717  product-id gi 446828913, \
718  genomic-id gi 16763390, \
719  genomic-strand minus, \
720  product-type protein, \
721  exons { \
722  { \
723  product-start protpos { \
724  amin 0, frame 1 \
725  }, \
726  product-end protpos { \
727  amin 268, frame 3 \
728  }, \
729  genomic-start 5116, \
730  genomic-end 5886, \
731  parts { \
732  match 3, \
733  diag 120, \
734  product-ins 36, \
735  diag 648 \
736  }, \
737  partial FALSE \
738  } \
739  }, \
740  product-length 269 \
741  } \
742 } \
743 ";
744 
745  int expected_score = 1301;
746 
747  CNcbiIstrstream istrs(buf);
748 
750 
751  CSeq_align align;
752 
753  //dense-seg
754  *istr >> align;
755  {{
756  CScoreBuilder score_builder(blast::eBlastp);
757  int dense_seg_score = score_builder.GetBlastScore(*scope, align);
758  BOOST_CHECK_EQUAL(dense_seg_score, expected_score);
759  }}
760 
761  //std-seg protein-to-protein
762  *istr >> align;
763  {{
764  CScoreBuilder score_builder(blast::eTblastn);
765  int std_seg_p2p_score = score_builder.GetBlastScore(*scope, align);
766  BOOST_CHECK_EQUAL(std_seg_p2p_score, expected_score);
767  }}
768 
769  //std-seg protein-to-nucleotide
770  *istr >> align;
771  {{
772  CScoreBuilder score_builder(blast::eTblastn);
773  int std_seg_p2n_score = score_builder.GetBlastScore(*scope, align);
774  BOOST_CHECK_EQUAL(std_seg_p2n_score, expected_score);
775  }}
776 
777  //spliced-seg
778  *istr >> align;
779  {{
780  CScoreBuilder score_builder(blast::eTblastn);
781  int spliced_seg_score = score_builder.GetBlastScore(*scope, align);
782  BOOST_CHECK_EQUAL(spliced_seg_score, expected_score);
783 
784  CScoreLookup lu;
785  lu.SetScope(*scope);
786  int prosplign_tblastn_score = lu.GetScore(align, "prosplign_tblastn_score");
787  BOOST_CHECK_EQUAL(prosplign_tblastn_score, expected_score);
788  }}
789 }
User-defined methods of the data storage class.
User-defined methods of the data storage class.
@ eBlastn
Nucl-Nucl (traditional blastn)
Definition: blast_types.hpp:58
@ eBlastp
Protein-Protein.
Definition: blast_types.hpp:59
@ eTblastn
Protein-Translated nucl.
Definition: blast_types.hpp:61
CArgs –.
Definition: ncbiargs.hpp:379
static TRegisterLoaderInfo RegisterInObjectManager(CObjectManager &om, CReader *reader=0, CObjectManager::EIsDefault is_default=CObjectManager::eDefault, CObjectManager::TPriority priority=CObjectManager::kPriority_NotSet)
Definition: gbloader.cpp:366
static CNcbiApplication * Instance(void)
Singleton method.
Definition: ncbiapp.cpp:244
CObjectIStream –.
Definition: objistr.hpp:93
CScope –.
Definition: scope.hpp:92
TSeqPos GetAlignLength(const CSeq_align &align, bool ungapped=false)
Compute the length of the alignment (= length of all segments, gaps + aligned)
int GetIdentityCount(CScope &scope, const CSeq_align &align)
Compute the number of identities in the alignment.
void AddSplignScores(const CSeq_align &align, CSeq_align::TScore &scores)
Compute the six splign scores.
int GetGapCount(const CSeq_align &align)
Compute the number of gaps in the alignment.
double GetPercentCoverage(CScope &scope, const CSeq_align &align, unsigned query=0)
Compute percent coverage of the query (sequence 0) (range 0-100)
double GetPercentIdentity(CScope &scope, const CSeq_align &align, EPercentIdentityType type=eGapped)
int GetMismatchCount(CScope &scope, const CSeq_align &align)
Compute the number of mismatches in the alignment.
int GetGapBaseCount(const CSeq_align &align)
Compute the number of gap bases in the alignment (= length of all gap segments)
void AddScore(CScope &scope, CSeq_align &align, EScoreType score)
deprecated: use CSeq_align::EScoreType directly
int GetBlastScore(CScope &scope, const CSeq_align &align)
Compute the BLAST score of the alignment.
void SetScope(objects::CScope &scope)
CScoreLookup uses a scope internally.
double GetScore(const objects::CSeq_align &align, const string &score_name)
Get requested score for alignment.
@ eScore_PercentIdentity_GapOpeningOnly
Definition: Seq_align.hpp:165
@ eScore_PercentIdentity_Gapped
Definition: Seq_align.hpp:163
@ eScore_PercentIdentity_Ungapped
Definition: Seq_align.hpp:164
@ eScore_NegativeCount
Definition: Seq_align.hpp:151
@ eScore_PositiveCount
Definition: Seq_align.hpp:148
@ eScore_PercentCoverage
Definition: Seq_align.hpp:168
@ eScore_HighQualityPercentCoverage
Definition: Seq_align.hpp:177
@ eScore_IdentityCount
Definition: Seq_align.hpp:145
@ eScore_MismatchCount
Definition: Seq_align.hpp:154
bool GetNamedScore(const string &id, int &score) const
Get score.
Definition: Seq_align.cpp:563
Definition: Seq_entry.hpp:56
virtual const CArgs & GetArgs(void) const
Get parsed command line arguments.
Definition: ncbiapp.cpp:285
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
@ eInputFile
Name of file (must exist and be readable)
Definition: ncbiargs.hpp:595
string
Definition: cgiapp.hpp:687
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
Definition: ncbidiag.hpp:226
void Error(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1197
#define MSerial_AsnText
I/O stream manipulators –.
Definition: serialbase.hpp:696
@ eSerial_AsnText
ASN.1 text.
Definition: serialdef.hpp:73
static CObjectIStream * Open(ESerialDataFormat format, CNcbiIstream &inStream, bool deleteInStream)
Create serial object reader and attach it to an input stream.
Definition: objistr.cpp:195
static CRef< CObjectManager > GetInstance(void)
Return the existing object manager or create one.
CSeq_entry_Handle AddTopLevelSeqEntry(CSeq_entry &top_entry, TPriority pri=kPriority_Default, EExist action=eExist_Default)
Add seq_entry, default priority is higher than for defaults or loaders Add object to the score with p...
Definition: scope.cpp:522
void AddDefaults(TPriority pri=kPriority_Default)
Add default data loaders from object manager.
Definition: scope.cpp:504
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
Definition: ncbistre.hpp:146
E_Choice Which(void) const
Which variant is currently selected.
Definition: Seq_align_.hpp:691
vector< CRef< CScore > > TScore
Definition: Seq_align_.hpp:398
void ResetScore(void)
Reset Score data member.
Definition: Seq_align_.cpp:295
TProduct_type GetProduct_type(void) const
Get the Product_type member data.
const TSpliced & GetSpliced(void) const
Get the variant data.
Definition: Seq_align_.cpp:219
bool IsStd(void) const
Check if variant Std is selected.
Definition: Seq_align_.hpp:746
bool IsSpliced(void) const
Check if variant Spliced is selected.
Definition: Seq_align_.hpp:778
const TScore & GetScore(void) const
Get the Score member data.
Definition: Seq_align_.hpp:896
const TSegs & GetSegs(void) const
Get the Segs member data.
Definition: Seq_align_.hpp:921
bool IsDenseg(void) const
Check if variant Denseg is selected.
Definition: Seq_align_.hpp:740
char * buf
The Object manager core.
static const char * expected[]
Definition: bcp.c:42
USING_SCOPE(objects)
const std::string sc_TestEntries
NCBITEST_INIT_CMDLINE(arg_desc)
BOOST_AUTO_TEST_CASE(Test_Score_Builder)
CRef< objects::CObjectManager > om
Utility stuff for more convenient using of Boost.Test library.
Modified on Mon Dec 11 02:38:10 2023 by modify_doxy.py rev. 669887