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

Go to the SVN repository for this file.

1 /*
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: Alexey Dobronadezhdin
27  *
28  * File Description:
29  *
30  * ===========================================================================
31  */
32 #include <ncbi_pch.hpp>
33 
35 
36 #include "base_report.hpp"
37 #include "seqid_hook.hpp"
38 
41 
42 namespace pub_report
43 {
44 
46 {
47  CConstRef<CSeq_id> best_seq_id;
48 
49  int best_score = INT_MAX;
50  for (const CRef<CSeq_id>& it : ids) {
51  if (CSeq_id::e_Genbank == it->Which()) {
52  return it;
53  }
54 
55  int score = it->BaseBestRankScore();
56  if (best_score > score) {
57  best_seq_id = it;
58  best_score = score;
59  }
60  }
61 
62  return best_seq_id;
63 }
64 
66  m_report(report) {}
67 
69 {
70  CBioseq::TId ids;
71  CObjectInfo info(&ids, (*member).GetTypeInfo());
72  in.ReadObject(info);
73 
74  CConstRef<CSeq_id> best_seq_id = GetBestId(ids);
75 
76  if (best_seq_id.NotEmpty()) {
77  string label;
78  best_seq_id->GetLabel(&label, CSeq_id::eContent);
80  }
81 
82  member.ResetLocalSkipHook(in);
83 }
84 
85 }
CObjectIStream –.
Definition: objistr.hpp:93
CObjectInfo –.
Definition: objectinfo.hpp:597
CObjectTypeInfoMI –.
Definition: objectiter.hpp:246
virtual void SetCurrentSeqId(const std::string &name)
Definition: base_report.hpp:51
CSkipSeqIdHook(CBaseReport &report)
Definition: seqid_hook.cpp:65
void SkipClassMember(CObjectIStream &in, const CObjectTypeInfoMI &member) override
Definition: seqid_hook.cpp:68
void GetLabel(string *label, ELabelType type=eDefault, TLabelFlags flags=fLabel_Default) const
Append a label for this Seq-id to the supplied string.
Definition: Seq_id.cpp:2040
int BaseBestRankScore(void) const
Definition: Seq_id.cpp:3080
@ eContent
Untagged human-readable accession or the like.
Definition: Seq_id.hpp:605
void ResetLocalSkipHook(CObjectIStream &stream) const
Definition: objectiter.cpp:157
bool NotEmpty(void) const THROWS_NONE
Check if CConstRef is not empty – pointing to an object and has a non-null value.
Definition: ncbiobj.hpp:1392
static const char label[]
list< CRef< CSeq_id > > TId
Definition: Bioseq_.hpp:94
static MDB_envinfo info
Definition: mdb_load.c:37
static CConstRef< CSeq_id > GetBestId(const CBioseq::TId &ids)
Definition: seqid_hook.cpp:45
std::istream & in(std::istream &in_, double &x_)
USING_SCOPE(objects)
USING_NCBI_SCOPE
Definition: seqid_hook.cpp:39
Modified on Fri Sep 20 14:58:04 2024 by modify_doxy.py rev. 669887