1 /*  $Id: seq_edit.cpp 632623 2021-06-03 17:38:11Z ivanov $
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: Justin Foley, NCBI
27 *
28 * File Description:
29 *   functions for editing sequences
30 */
31 #include <ncbi_pch.hpp>
32 #include <corelib/ncbistd.hpp>
33 #include <objmgr/seq_vector.hpp>
34 
35 #include <objects/seq/Seq_inst.hpp>
36 #include <objects/seq/Seq_data.hpp>
37 #include <objects/seq/seqport_util.hpp>
38 
39 #include <objtools/edit/seq_edit.hpp>
40 
41 BEGIN_NCBI_SCOPE
BEGIN_SCOPE(objects)42 BEGIN_SCOPE(objects)
43 BEGIN_SCOPE(edit)
44 
45 void g_ConvertDeltaToRawSeq(CBioseq& bioseq, CScope* pScope)
46 {
47     auto& seq_inst = bioseq.SetInst();
48 
49     _ASSERT(seq_inst.GetRepr() == CSeq_inst::eRepr_delta);
50     _ASSERT(seq_inst.IsSetLength());
51 
52     CSeqVector seq_vec(bioseq, pScope, CBioseq_Handle::eCoding_Iupac);
53     string seqdata;
54     seq_vec.GetSeqData(0, seq_inst.GetLength(), seqdata);
55     auto pSeqData =
56         Ref(new CSeq_data(seqdata, seq_vec.GetCoding()));
57     CSeqportUtil::Pack(pSeqData.GetPointer());
58 
59 
60     seq_inst.SetRepr(CSeq_inst::eRepr_raw);
61     seq_inst.SetSeq_data(*pSeqData);
62     seq_inst.ResetExt();
63 }
64 
65 END_SCOPE(edit)
66 END_SCOPE(objects)
67 END_NCBI_SCOPE
68