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

Go to the SVN repository for this file.

1 #ifndef _GUI_PACKAGES_SEQUPDATE_INPUT_HPP_
2 #define _GUI_PACKAGES_SEQUPDATE_INPUT_HPP_
3 /* $Id: update_seq_input.hpp 44068 2019-10-18 18:57:05Z asztalos $
4  * ===========================================================================
5  *
6  * PUBLIC DOMAIN NOTICE
7  * National Center for Biotechnology Information
8  *
9  * This software/database is a "United States Government Work" under the
10  * terms of the United States Copyright Act. It was written as part of
11  * the author's official duties as a United States Government employee and
12  * thus cannot be copyrighted. This software/database is freely available
13  * to the public for use. The National Library of Medicine and the U.S.
14  * Government have not placed any restriction on its use or reproduction.
15  *
16  * Although all reasonable efforts have been taken to ensure the accuracy
17  * and reliability of the software and data, the NLM and the U.S.
18  * Government do not and cannot warrant the performance or results that
19  * may be obtained by using this software or data. The NLM and the U.S.
20  * Government disclaim all warranties, express or implied, including
21  * warranties of performance, merchantability or fitness for any particular
22  * purpose.
23  *
24  * Please cite the author in any work or product based on this material.
25  *
26  * ===========================================================================
27  *
28  * Authors: Andrea Asztalos
29  */
30 
31 #include <corelib/ncbistd.hpp>
32 #include <corelib/ncbiexpt.hpp>
33 #include <corelib/ncbiobj.hpp>
34 #include <util/format_guess.hpp>
35 #include <gui/gui_export.h>
37 #include <objmgr/bioseq_handle.hpp>
39 
40 
43  class CSeq_entry_Handle;
44  class CSeq_id;
45  class CSeq_literal;
47 
48 class IWorkbench;
49 
50 /// Sets up the old and the update sequences, and generates the alignment between them.
52 {
53 public:
54  CUpdateSeq_Input(void);
55  CUpdateSeq_Input(const objects::CBioseq_Handle& old_bsh, const objects::CBioseq_Handle& upd_bsh);
57 
58  const objects::CBioseq_Handle& GetOldBioseq(void) const { return m_OldSeq; }
59  objects::CBioseq_Handle GetNCOldBioseq(void) const { return m_OldSeq; }
60  const objects::CBioseq_Handle& GetUpdateBioseq(void) const { return m_UpdSeq; }
61  CConstRef<objects::CSeq_align> GetAlignment(void) const { return m_Align; }
62  void SetAlignment(const objects::CSeq_align* align) { m_Align.Reset(align); }
63 
64  bool SetOldBioseqAndScope(IWorkbench* workbench, const objects::CSeq_entry_Handle& tse);
65  bool SetOldBioseqAndScope(const objects::CBioseq_Handle& bsh);
66  bool SetUpdateBioseq(const objects::CBioseq_Handle& bsh);
67 
68  /// Reads single update sequence from the clipboard. It supports FASTA and text ASN formats.
69  bool ReadUpdateSequenceFromClipboard(objects::ILineErrorListener* msg_listener);
70  /// Reads (ASN.1 or FASTA) single update sequence from a file
71  bool ReadSingleUpdateSequence(objects::ILineErrorListener* msg_listener);
72  /// Reads single update sequence identified by an accession
73  bool ReadSingleAccession(void);
74 
75  bool HaveIdenticalResidues(void) const;
76 
77  bool IsReadyForUpdate(void) const;
78 
79  bool UpdateSeqHasFeatures(void) const;
80  bool OldSeqHasFeatures(void) const;
81  bool OldSeqHasProteinFeats() const;
82 
83  /// Calculates the alignment between the old and the update sequence, sets m_Align member.
84  /// To be used only in the unit tests
85  void CalculateAlignmentForUnitTest(void);
86 
87  static CRef<objects::CSeq_annot> s_Align2IdenticalSeq(const objects::CBioseq_Handle& subject, const objects::CBioseq_Handle& query);
88 
89  /// Converts delta literals to raw sequence, applies only to NA sequences
90  static void s_ConvertDeltaToRawEntry(objects::CSeq_entry& entry);
91  static void s_ConvertDeltaToRawBioseq(objects::CBioseq& bseq);
92 
93  // Functions used to determine whether the sequence can be converted to raw sequence
94  static bool s_IsGoodLiteral(const objects::CSeq_literal& lit);
95  static bool s_IsDeltaWithNoGaps(const objects::CBioseq& bseq);
96 
97  static bool s_IsDeltaWithFarPointers(const objects::CBioseq& bseq);
98 
99  /// When the old and the update sequences have the same ID, the ID of the update sequence is modified
100  static void s_FixCollidingIDs_Entry(objects::CSeq_entry& entry, const objects::CBioseq::TId& seq_ids);
101 
102  unsigned int CountBioseqs();
103  // will discard the update sequence and the alignment
104  void ResetUpdateSequence();
105 
106 private:
107  bool x_ReadFromStream(CNcbiIstream& istr, objects::ILineErrorListener* msg_listener);
108  bool x_ReadUpdateSeq_Fasta(CNcbiIstream& istr, objects::ILineErrorListener* msg_listener);
109  bool x_ReadUpdateSeq_ASN(CNcbiIstream& istr);
110  bool x_ReadAccession(const string& acc_id);
111 
112  // These functions in turn call the static functions with similar names
113  void x_FixCollidingIDs_Entry(objects::CSeq_entry& entry);
114  void x_FixCollidingIDs_Bioseq(objects::CBioseq& bioseq);
115 
116  /// Function fixes colliding IDs, add the update entry to the scope and sets m_UpdSeq member
117  void x_AddNewEntryToScope(CRef<objects::CSeq_entry> entry);
118 
119 
120  objects::CBioseq_Handle m_OldSeq;
121  objects::CBioseq_Handle m_UpdSeq;
123  ///@note
124  /// both the old and the update sequence should be placed in the same scope (NgAligner + visualization purposes)
126 };
127 
129 
130 #endif
131  // _GUI_PACKAGES_SEQUPDATE_INPUT_HPP_
CObject –.
Definition: ncbiobj.hpp:180
CSeq_entry_Handle –.
Sets up the old and the update sequences, and generates the alignment between them.
bool SetOldBioseqAndScope(const objects::CBioseq_Handle &bsh)
bool SetOldBioseqAndScope(IWorkbench *workbench, const objects::CSeq_entry_Handle &tse)
void SetAlignment(const objects::CSeq_align *align)
objects::CBioseq_Handle m_UpdSeq
CConstRef< objects::CSeq_align > GetAlignment(void) const
objects::CBioseq_Handle GetNCOldBioseq(void) const
CRef< objects::CScope > m_Scope
objects::CBioseq_Handle m_OldSeq
CUpdateSeq_Input(const objects::CBioseq_Handle &old_bsh, const objects::CBioseq_Handle &upd_bsh)
const objects::CBioseq_Handle & GetUpdateBioseq(void) const
CConstRef< objects::CSeq_align > m_Align
const objects::CBioseq_Handle & GetOldBioseq(void) const
IWorkbench is the central interface in the application framework.
Definition: workbench.hpp:113
Include a standard set of the NCBI C++ Toolkit most basic headers.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
Definition: ncbistre.hpp:146
#define NCBI_GUIPKG_SEQUENCE_EDIT_EXPORT
Definition: gui_export.h:515
Defines to provide correct exporting from DLLs in Windows.
Defines NCBI C++ exception handling.
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
static string subject
static string query
Modified on Sun Jun 23 05:15:41 2024 by modify_doxy.py rev. 669887