NCBI C++ ToolKit
multireader.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef TABLE2ASN_MULTIREADER_HPP
2 #define TABLE2ASN_MULTIREADER_HPP
3 
4 #include <util/format_guess.hpp>
5 #include <corelib/ncbistre.hpp>
6 #include <corelib/ncbiutil.hpp>
7 #include <shared_mutex>
8 
10 
11 namespace objects
12 {
13 class CScope;
14 class CSeq_entry;
15 class CSeq_submit;
16 class CSeq_descr;
17 class CSeqdesc;
18 class ILineErrorListener;
19 class CIdMapper;
20 class CBioseq;
21 class CSeq_annot;
22 class CGff3Reader;
24 }
25 
26 class CTable2AsnContext;
27 class CSerialObject;
28 class CAnnotationLoader;
29 union CFileContentInfo;
31 
34 
35 // ============================================================================
37 // ============================================================================
38 {
39 public:
41  ~CMultiReader();
42 
43  using TAnnots = list<CRef<CSeq_annot>>;
45 
47 
48  void LoadTemplate(const string& ifname);
49  void LoadGFF3Fasta(istream& in, TAnnots& annots);
50  void LoadGFF3Fasta(istream& in, TAnnotMap& annotMap);
51  void AddAnnots(TAnnotMap& annotMap, set<string>& matchedAnnots, CBioseq& bioseq) const;
52 
53  void LoadAnnotMap(const string& filename, TAnnotMap& annotMap);
54  void AddAnnotToMap(CRef<CSeq_annot> pAnnot, TAnnotMap& annotMap);
55  void LoadDescriptors(const string& ifname, CRef<objects::CSeq_descr> & out_desc) const;
56  void ApplyDescriptors(objects::CSeq_entry & obj, const objects::CSeq_descr & source) const;
57  void WriteObject(const CSerialObject&, ostream&);
60  CFormatGuess::EFormat OpenFile(const string& filename, CRef<CSerialObject>& input_sequence, TAnnotMap& annotMap);
61  CRef<CSerialObject> FetchEntry(const CFormatGuess::EFormat& format, const string& objectType,
62  unique_ptr<CNcbiIstream>& pIstr, TAnnotMap& annotMap);
63  static
65 protected:
66 private:
67  void MergeDescriptors(objects::CSeq_descr & dest, const objects::CSeq_descr & source) const;
68  void MergeDescriptors(objects::CSeq_descr & dest, const objects::CSeqdesc & source) const;
69 
70  bool AtSeqenceData() const { return mAtSequenceData; };
71 
73  CRef<CSerialObject> xApplyTemplate(CRef<CSerialObject> obj, bool merge_template_descriptors) const;
75  CRef<CSerialObject> xReadASN1Binary(CObjectIStream& pObjIstrm, const string& content_type) const;
76  TAnnots xReadGFF3(CNcbiIstream& instream, bool post_process);
77  TAnnots xReadGTF(CNcbiIstream& instream);
79  void x_PostProcessAnnots(TAnnots& annots) const;
80  bool xGetAnnotLoader(CAnnotationLoader& loader, const string& filename);
81 
82  unique_ptr<CObjectIStream> xCreateASNStream(const string& filename) const;
83  unique_ptr<CObjectIStream> xCreateASNStream(CFormatGuess::EFormat format, unique_ptr<istream>& instream) const;
86 
87  bool x_HasMatch(bool matchVersions,
88  const string& idString, TAnnotMap& annotMap, set<string>& matchedAnnots, list<CRef<CSeq_annot>>& annots) const;
89  bool x_HasExactMatch(const string& idString, TAnnotMap& annotMap, set<string>& matchedAnnots, list<CRef<CSeq_annot>>& annots) const;
90 
91  int m_iFlags;
92  string m_AnnotName;
93  string m_AnnotTitle;
95  unique_ptr<CObjectIStream> m_obj_stream;
96  shared_ptr<objects::CGff3LocationMerger> m_gff3_merger;
98  mutable shared_mutex m_Mutex;
99 };
100 
101 void g_ModifySeqIds(CSeq_annot& annot, const CSeq_id& match, CRef<CSeq_id> new_id);
102 
104 
105 #endif
CArgs –.
Definition: ncbiargs.hpp:379
EFormat
The formats are checked in the same order as declared here.
IdMapper base class implementation.
Definition: idmapper.hpp:56
string m_AnnotName
Definition: multireader.hpp:92
bool xGetAnnotLoader(CAnnotationLoader &loader, const string &filename)
void LoadGFF3Fasta(istream &in, TAnnots &annots)
static void GetSeqEntry(CRef< objects::CSeq_entry > &entry, CRef< objects::CSeq_submit > &submit, CRef< CSerialObject > obj)
string m_AnnotTitle
Definition: multireader.hpp:93
list< CRef< CSeq_annot > > TAnnots
Definition: multireader.hpp:43
TAnnots xReadGFF3(CNcbiIstream &instream, bool post_process)
void MergeDescriptors(objects::CSeq_descr &dest, const objects::CSeq_descr &source) const
void MergeDescriptors(objects::CSeq_descr &dest, const objects::CSeqdesc &source) const
CMultiReader(CTable2AsnContext &context)
shared_mutex m_Mutex
Definition: multireader.hpp:98
unique_ptr< CObjectIStream > xCreateASNStream(const string &filename) const
void LoadAnnotMap(const string &filename, TAnnotMap &annotMap)
CTable2AsnContext & m_context
Definition: multireader.hpp:94
void AddAnnots(TAnnotMap &annotMap, set< string > &matchedAnnots, CBioseq &bioseq) const
CRef< CSerialObject > ReadNextEntry()
bool x_HasMatch(bool matchVersions, const string &idString, TAnnotMap &annotMap, set< string > &matchedAnnots, list< CRef< CSeq_annot >> &annots) const
static const set< TTypeInfo > kSupportedTypes
Definition: multireader.hpp:46
CFormatGuess::EFormat xAnnotGetFormat(CNcbiIstream &) const
shared_ptr< objects::CGff3LocationMerger > m_gff3_merger
Definition: multireader.hpp:96
CRef< CSerialObject > xReadASN1Binary(CObjectIStream &pObjIstrm, const string &content_type) const
bool AtSeqenceData() const
Definition: multireader.hpp:70
map< string, list< CRef< CSeq_annot > >> TAnnotMap
Definition: multireader.hpp:44
CRef< CSerialObject > FetchEntry(const CFormatGuess::EFormat &format, const string &objectType, unique_ptr< CNcbiIstream > &pIstr, TAnnotMap &annotMap)
bool mAtSequenceData
Definition: multireader.hpp:97
void WriteObject(const CSerialObject &, ostream &)
void LoadDescriptors(const string &ifname, CRef< objects::CSeq_descr > &out_desc) const
bool x_HasExactMatch(const string &idString, TAnnotMap &annotMap, set< string > &matchedAnnots, list< CRef< CSeq_annot >> &annots) const
TAnnots xReadGTF(CNcbiIstream &instream)
void ApplyDescriptors(objects::CSeq_entry &obj, const objects::CSeq_descr &source) const
CRef< CSerialObject > xApplyTemplate(CRef< CSerialObject > obj, bool merge_template_descriptors) const
CRef< objects::CSeq_entry > xReadFasta(CNcbiIstream &instream)
CRef< objects::CSeq_entry > ReadAlignment(CNcbiIstream &instream, const CArgs &args)
void AddAnnotToMap(CRef< CSeq_annot > pAnnot, TAnnotMap &annotMap)
CFormatGuess::EFormat OpenFile(const string &filename, CRef< CSerialObject > &input_sequence, TAnnotMap &annotMap)
CRef< objects::CSeq_entry > xReadFlatfile(CFormatGuess::EFormat format, const string &filename)
void LoadTemplate(const string &ifname)
void x_PostProcessAnnots(TAnnots &annots) const
CFormatGuess::EFormat xInputGetFormat(CNcbiIstream &, CFileContentInfo *=nullptr) const
unique_ptr< CObjectIStream > m_obj_stream
Definition: multireader.hpp:95
CRef< CSerialObject > xReadASN1Text(CObjectIStream &pObjIstrm) const
CObjectIStream –.
Definition: objistr.hpp:93
CScope –.
Definition: scope.hpp:92
@Seq_descr.hpp User-defined methods of the data storage class.
Definition: Seq_descr.hpp:55
Definition: Seq_entry.hpp:56
Base class for all serializable objects.
Definition: serialbase.hpp:150
Definition: map.hpp:338
Definition: set.hpp:45
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
Definition: ncbistre.hpp:146
USING_SCOPE(objects)
void g_ModifySeqIds(CSeq_annot &annot, const CSeq_id &match, CRef< CSeq_id > new_id)
const CharType(& source)[N]
Definition: pointer.h:1149
NCBI C++ stream class wrappers for triggering between "new" and "old" C++ stream libraries.
Useful/utility classes and methods.
static Format format
Definition: njn_ioutil.cpp:53
std::istream & in(std::istream &in_, double &x_)
static int match(register const pcre_uchar *eptr, register const pcre_uchar *ecode, const pcre_uchar *mstart, int offset_top, match_data *md, eptrblock *eptrb, unsigned int rdepth)
Definition: pcre_exec.c:513
static CS_CONTEXT * context
Definition: will_convert.c:21
Modified on Mon May 20 04:58:48 2024 by modify_doxy.py rev. 669887