1 #ifndef FEAT__HPP
2 #define FEAT__HPP
3 
4 /*  $Id: feature.hpp 594609 2019-10-07 15:37:03Z vasilche $
5 * ===========================================================================
6 *
7 *                            PUBLIC DOMAIN NOTICE
8 *               National Center for Biotechnology Information
9 *
10 *  This software/database is a "United States Government Work" under the
11 *  terms of the United States Copyright Act.  It was written as part of
12 *  the author's official duties as a United States Government employee and
13 *  thus cannot be copyrighted.  This software/database is freely available
14 *  to the public for use. The National Library of Medicine and the U.S.
15 *  Government have not placed any restriction on its use or reproduction.
16 *
17 *  Although all reasonable efforts have been taken to ensure the accuracy
18 *  and reliability of the software and data, the NLM and the U.S.
19 *  Government do not and cannot warrant the performance or results that
20 *  may be obtained by using this software or data. The NLM and the U.S.
21 *  Government disclaim all warranties, express or implied, including
22 *  warranties of performance, merchantability or fitness for any particular
23 *  purpose.
24 *
25 *  Please cite the author in any work or product based on this material.
26 *
27 * ===========================================================================
28 *
29 * Author:  Clifford Clausen
30 *
31 * File Description:
32 *   Feature utilities
33 */
34 
35 #include <corelib/ncbistd.hpp>
36 #include <objmgr/annot_selector.hpp>
37 #include <objmgr/mapped_feat.hpp>
38 #include <objmgr/seq_loc_mapper.hpp>
39 #include <objmgr/util/seq_loc_util.hpp>
40 #include <objects/seqfeat/Gb_qual.hpp>
41 
42 
43 BEGIN_NCBI_SCOPE
44 BEGIN_SCOPE(objects)
45 
46 // Forward declarations
47 class CSeq_feat;
48 class CScope;
49 class CFeat_CI;
50 class CTSE_Handle;
51 class CFeat_id;
52 class CGene_ref;
53 class CGb_qual;
54 
55 BEGIN_SCOPE(feature)
56 
57 
58 /** @addtogroup ObjUtilFeature
59  *
60  * @{
61  */
62 
63 
64 /** @name GetLabel
65  * Returns a label for a CSeq_feat. Label may be based on just the type of
66  * feature, just the content of the feature, or both. If scope is 0, then the
67  * label will not include information from feature products.
68  * @{
69  */
70 
71 enum FFeatLabelFlags {
72     fFGL_Type         = 1 <<  1, ///< Always include the feature's type.
73     fFGL_Content      = 1 <<  2, ///< Include its content if there is any.
74     fFGL_Both         = fFGL_Type | fFGL_Content,
75     fFGL_NoComments   = 1 <<  3, ///< Leave out comments, even as fallbacks.
76     fFGL_NoQualifiers = 1 <<  4  ///< Leave out qualifiers.
77 };
78 typedef int TFeatLabelFlags; ///< binary OR of FFeatLabelFlags
79 
80 NCBI_XOBJUTIL_EXPORT
81 void GetLabel(const CSeq_feat& feat, string* label, TFeatLabelFlags flags,
82               CScope* scope = 0);
83 
84 /// For compatibility with legacy code.
85 enum ELabelType {
86     eType,
87     eContent,
88     eBoth
89 };
90 
91 NCBI_XOBJUTIL_EXPORT
92 NCBI_DEPRECATED
93 void GetLabel (const CSeq_feat&    feat,
94                string*             label,
95                ELabelType          label_type,
96                CScope*             scope = 0);
97 
98 /* @} */
99 
100 
101 class CFeatIdRemapper : public CObject
102 {
103 public:
104 
105     void Reset(void);
106     size_t GetFeatIdsCount(void) const;
107 
108     int RemapId(int old_id, const CTSE_Handle& tse);
109     bool RemapId(CFeat_id& id, const CTSE_Handle& tse);
110     bool RemapId(CFeat_id& id, const CFeat_CI& feat_it);
111     bool RemapIds(CSeq_feat& feat, const CTSE_Handle& tse);
112     CRef<CSeq_feat> RemapIds(const CFeat_CI& feat_it);
113 
114 private:
115     typedef pair<int, CTSE_Handle> TFullId;
116     typedef map<TFullId, int> TIdMap;
117     TIdMap m_IdMap;
118 };
119 
120 
121 class NCBI_XOBJUTIL_EXPORT CFeatComparatorByLabel : public CObject,
122                                                     public IFeatComparator
123 {
124 public:
125     virtual bool Less(const CSeq_feat& f1,
126                       const CSeq_feat& f2,
127                       CScope* scope);
128 };
129 
130 
131 NCBI_XOBJUTIL_EXPORT
132 CMappedFeat MapSeq_feat(const CSeq_feat_Handle& feat,
133                         const CBioseq_Handle& master_seq,
134                         const CRange<TSeqPos>& range);
135 NCBI_XOBJUTIL_EXPORT
136 CMappedFeat MapSeq_feat(const CSeq_feat_Handle& feat,
137                         const CSeq_id_Handle& master_id,
138                         const CRange<TSeqPos>& range);
139 NCBI_XOBJUTIL_EXPORT
140 CMappedFeat MapSeq_feat(const CSeq_feat_Handle& feat,
141                         const CBioseq_Handle& master_seq);
142 NCBI_XOBJUTIL_EXPORT
143 CMappedFeat MapSeq_feat(const CSeq_feat_Handle& feat,
144                         const CSeq_id_Handle& master_id);
145 
146 
147 /// @name GetParentFeature
148 /// Returns a best parent feature for a CMappedFeat.
149 /// CSeq_feat_Handle is convertible to a CMappedFeat so it can be used too.
150 NCBI_XOBJUTIL_EXPORT
151 CMappedFeat GetParentFeature(const CMappedFeat& feat);
152 
153 struct STypeLink;
154 class CFeatTreeIndex;
155 
156 /////////////////////////////////////////////////////////////////////////////
157 /// CFeatTree
158 ///
159 /// CFeatTree class builds a parent-child feature tree in a more efficient way
160 /// than repeatedly calling of GetParentFeature() for each feature.
161 /// The algorithm of a parent search is the same as the one used by
162 /// GetParentFeature().
163 ///
164 /// The class CFeatTree works with a set of features which should be
165 /// specified via AddFeature() or AddFeatures() call.
166 /// The actual tree is built when the first time method GetParent()
167 /// or GetChildren() is called after adding new features.
168 /// Features can be added later, but the parent information is cached and will
169 /// not change if parents were found already. However, features with no parent
170 /// will be processed again in attempt to find parents from the newly added
171 /// features.
172 class NCBI_XOBJUTIL_EXPORT CFeatTree : public CObject
173 {
174 public:
175     /// Construct empty tree.
176     CFeatTree(void);
177     /// Construct a tree with features collected by a CFeat_CI.
178     explicit
179     CFeatTree(CFeat_CI it);
180     /// Construct a tree with features from a Seq-annot
181     explicit
182     CFeatTree(const CSeq_annot_Handle& sah);
183     /// Construct a tree with features from a Seq-annot, restricted by an annot
184     /// selector.
185     explicit
186     CFeatTree(const CSeq_annot_Handle& sah, const SAnnotSelector& sel);
187     /// Construct a tree with features from a Seq-entry
188     explicit
189     CFeatTree(const CSeq_entry_Handle& seh);
190     /// Construct a tree with features from a Seq-entry, restricted by an annot
191     /// selector.
192     explicit
193     CFeatTree(const CSeq_entry_Handle& seh, const SAnnotSelector& sel);
194     /// Destructor.
195     ~CFeatTree(void);
196 
197     CFeatTree(const CFeatTree&);
198     CFeatTree& operator=(const CFeatTree&);
199 
200     /// Mode of processing feature ids
201     enum EFeatIdMode {
202         eFeatId_ignore,
203         eFeatId_by_type, // default
204         eFeatId_always
205     };
GetFeatIdMode(void) const206     EFeatIdMode GetFeatIdMode(void) const {
207         return m_FeatIdMode;
208     }
209     void SetFeatIdMode(EFeatIdMode mode);
210 
211     /// Mode of processing feature ids
212     enum EBestGeneFeatIdMode {
213         eBestGeneFeatId_ignore,
214         eBestGeneFeatId_always // default
215     };
GetBestGeneFeatIdMode(void) const216     EBestGeneFeatIdMode GetBestGeneFeatIdMode(void) const {
217         return m_BestGeneFeatIdMode;
218     }
219     void SetBestGeneFeatIdMode(EBestGeneFeatIdMode mode);
220 
221     /// Mode for taking into account best gene
222     ///   eGeneCheck_match will try to match a parent feature only
223     ///   if they both match to the same gene
224     enum EGeneCheckMode {
225         eGeneCheck_ignore,
226         eGeneCheck_match // default
227     };
GetGeneCheckMode(void) const228     EGeneCheckMode GetGeneCheckMode(void) const {
229         return m_GeneCheckMode;
230     }
231     void SetGeneCheckMode(EGeneCheckMode mode);
232 
233     /// Mode for taking into account gene xref to a missing genes
234     ///
GetIgnoreMissingGeneXref(void) const235     bool GetIgnoreMissingGeneXref(void) const {
236         return m_IgnoreMissingGeneXref;
237     }
238     void SetIgnoreMissingGeneXref(bool ignore = true);
239 
240     /// Mode of processing SNP strands
241     enum ESNPStrandMode {
242         eSNPStrand_same,
243         eSNPStrand_both  // default
244     };
GetSNPStrandMode(void) const245     ESNPStrandMode GetSNPStrandMode(void) const {
246         return m_SNPStrandMode;
247     }
248     void SetSNPStrandMode(ESNPStrandMode mode);
249 
250     /// Add all features collected by a CFeat_CI to the tree.
251     void AddFeatures(CFeat_CI it);
252     /// Add a single feature to the tree.
253     void AddFeature(const CMappedFeat& feat);
254 
255     /// Add all features from bottom_type to top_type for a feature.
256     void AddFeaturesFor(CScope& scope, const CSeq_loc& loc,
257                         CSeqFeatData::ESubtype bottom_type,
258                         CSeqFeatData::ESubtype top_type,
259                         const SAnnotSelector* base_sel = 0,
260                         bool skip_bottom = false);
261     void AddFeaturesFor(const CMappedFeat& feat,
262                         CSeqFeatData::ESubtype bottom_type,
263                         CSeqFeatData::ESubtype top_type,
264                         const SAnnotSelector* base_sel = 0);
265     void AddFeaturesFor(const CMappedFeat& feat,
266                         CSeqFeatData::ESubtype top_type,
267                         const SAnnotSelector* base_sel = 0);
268     /// Add all necessary features to get genes for a mRNA feature.
269     void AddGenesForMrna(const CMappedFeat& mrna_feat,
270                          const SAnnotSelector* base_sel = 0);
271     /// Add all necessary features to get cdregions for a mRNA feature.
272     void AddCdsForMrna(const CMappedFeat& mrna_feat,
273                        const SAnnotSelector* base_sel = 0);
274     /// Add all necessary features to get mRNAs for a gene feature.
275     void AddMrnasForGene(const CMappedFeat& gene_feat,
276                          const SAnnotSelector* base_sel = 0);
277     /// Add all necessary features to get cdregions for a gene feature.
278     void AddCdsForGene(const CMappedFeat& gene_feat,
279                        const SAnnotSelector* base_sel = 0);
280     /// Add all necessary features to get genes for a cdregion feature.
281     void AddGenesForCds(const CMappedFeat& cds_feat,
282                         const SAnnotSelector* base_sel = 0);
283     /// Add all necessary features to get mRNAs for a cdregion feature.
284     void AddMrnasForCds(const CMappedFeat& cds_feat,
285                         const SAnnotSelector* base_sel = 0);
286     /// Add all necessary features to get genes for an arbitrary feature.
287     void AddGenesForFeat(const CMappedFeat& feat,
288                          const SAnnotSelector* base_sel = 0);
289 
290     /// Find a corresponding CMappedFeat for a feature already added to a tree.
291     /// Will throw an exception if the feature is not in the tree.
292     const CMappedFeat& GetMappedFeat(const CSeq_feat_Handle& feat) const;
293     /// Return nearest parent of a feature.
294     /// Will throw an exception if the feature is not in the tree.
295     /// Will return null CMappedFeat if the feature has no parent.
296     CMappedFeat GetParent(const CMappedFeat& feat);
297     /// Return parent of a feature of the specified type, it may be not
298     /// the nearest parent, but a parent's parent, and so on.
299     /// Will throw an exception if the feature is not in the tree.
300     /// Will return null CMappedFeat if the feature has no parent of the type.
301     CMappedFeat GetParent(const CMappedFeat& feat,
302                           CSeqFeatData::E_Choice type);
303     /// Return parent of a feature of the specified subtype, it may be not
304     /// the nearest parent, but a parent's parent, and so on.
305     /// Will throw an exception if the feature is not in the tree.
306     /// Will return null CMappedFeat if the feature has no parent of the type.
307     CMappedFeat GetParent(const CMappedFeat& feat,
308                           CSeqFeatData::ESubtype subtype);
309     /// Return all nearest children of a feature.
310     /// Will throw an exception if the feature is not in the tree.
311     /// Will return an empty vector if the feature has no children.
312     /// If the feat argument is null then all the features without parent
313     /// are returned.
314     vector<CMappedFeat> GetChildren(const CMappedFeat& feat);
315     /// Store all nearest children of a feature into a vector.
316     /// Will throw an exception if the feature is not in the tree.
317     /// The second argument will become empty if the feature has no children.
318     /// If the feat argument is null then all the features without parent
319     /// are returned.
320     void GetChildrenTo(const CMappedFeat& feat, vector<CMappedFeat>& children);
321     /// Return all root features (w/o parent).
GetRootFeatures(void)322     vector<CMappedFeat> GetRootFeatures(void) {
323         return GetChildren(CMappedFeat());
324     }
325     /// Store all root features (w/o parent) into a vector.
GetRootFeaturesTo(vector<CMappedFeat> & children)326     void GetRootFeaturesTo(vector<CMappedFeat>& children) {
327         GetChildrenTo(CMappedFeat(), children);
328     }
329 
330     enum EBestGeneType {
331         eBestGene_TreeOnly,        // determined by feature position in tree
332         eBestGene_AllowOverlapped, // get gene from tree, then by overlapping
333         eBestGene_OverlappedOnly   // get gene by overlapping only
334     };
335 
336     /// Return parent gene if exists or best overlapping gene
337     CMappedFeat GetBestGene(const CMappedFeat& feat,
338                             EBestGeneType lookup_type = eBestGene_TreeOnly);
339 
340 public:
341     class CFeatInfo {
342     public:
343         CFeatInfo(void);
344         ~CFeatInfo(void);
345 
346         const CTSE_Handle& GetTSE(void) const;
IsSetParent(void) const347         bool IsSetParent(void) const {
348             return m_IsSetParent;
349         }
IsSetGene(void) const350         bool IsSetGene(void) const {
351             return m_IsSetGene;
352         }
GetSubtype(void) const353         CSeqFeatData::ESubtype GetSubtype(void) const {
354             return m_Feat.GetFeatSubtype();
355         }
IsGene(void) const356         bool IsGene(void) const {
357             return GetSubtype() == CSeqFeatData::eSubtype_gene;
358         }
GivesGeneToChildren(void) const359         bool GivesGeneToChildren(void) const {
360             return IsGene() || IsSetGene();
361         }
GetChildrenGene(void)362         CFeatInfo* GetChildrenGene(void) {
363             return IsGene()? this: m_Gene;
364         }
365 
366         typedef vector<CFeatInfo*> TChildren;
367 
368         size_t m_AddIndex;
369         CMappedFeat m_Feat;
370         CRange<TSeqPos> m_MasterRange;
371         bool m_CanMatchByQual;
372         bool m_IsSetParent, m_IsSetGene, m_IsSetChildren, m_MultiId;
NCBI_PACKED_ENUM_TYPE(Int1)373         enum EIsLinkedToRoot NCBI_PACKED_ENUM_TYPE(Int1) {
374             eIsLinkedToRoot_unknown,
375             eIsLinkedToRoot_linked,
376             eIsLinkedToRoot_linking
377         } NCBI_PACKED_ENUM_END();
378         EIsLinkedToRoot m_IsLinkedToRoot;
379         CFeatInfo* m_Parent;
380         CFeatInfo* m_Gene;
381         TChildren m_Children;
382     };
383     typedef vector<CFeatInfo*> TFeatArray;
384 
385 protected:
386     typedef vector<CFeatInfo*> TChildren;
387 
388     void x_Init(void);
389 
390     CFeatInfo& x_GetInfo(const CSeq_feat_Handle& feat);
391     CFeatInfo& x_GetInfo(const CMappedFeat& feat);
392     CFeatInfo* x_FindInfo(const CSeq_feat_Handle& feat);
393 
394     void x_AssignParents(void);
395     void x_AssignParentsByOverlap(TFeatArray& features,
396                                   const STypeLink& link);
397     bool x_AssignParentByRef(CFeatInfo& info);
398 
399     void x_AssignGenesByOverlap(TFeatArray& features);
400     void x_AssignGenes(void);
401 
402     pair<int, CFeatInfo*>
403     x_LookupParentByRef(CFeatInfo& info,
404                         CSeqFeatData::ESubtype parent_type);
405     void x_VerifyLinkedToRoot(CFeatInfo& info);
406 
407     void x_SetParent(CFeatInfo& info, CFeatInfo& parent);
408     void x_SetNoParent(CFeatInfo& info);
409     CFeatInfo* x_GetParent(CFeatInfo& info);
410     const TChildren& x_GetChildren(CFeatInfo& info);
411     void x_SetGeneRecursive(CFeatInfo& info, CFeatInfo* gene);
412     void x_SetGene(CFeatInfo& info, CFeatInfo* gene);
413 
414     typedef map<CSeq_feat_Handle, CFeatInfo> TInfoMap;
415     typedef vector<CFeatInfo*> TInfoArray;
416 
417     size_t m_AssignedParents, m_AssignedGenes;
418     TInfoMap m_InfoMap;
419     TInfoArray m_InfoArray;
420     CFeatInfo m_RootInfo;
421     EFeatIdMode m_FeatIdMode;
422     EBestGeneFeatIdMode m_BestGeneFeatIdMode;
423     EGeneCheckMode m_GeneCheckMode;
424     bool m_IgnoreMissingGeneXref;
425     ESNPStrandMode m_SNPStrandMode;
426     CRef<CFeatTreeIndex> m_Index;
427 };
428 
429 
430 /* @} */
431 
432 
433 /////////////////////////////////////////////////////////////////////////////
434 // Versions of functions with lookup using CFeatTree
435 
436 NCBI_XOBJUTIL_EXPORT
437 CMappedFeat
438 GetBestGeneForMrna(const CMappedFeat& mrna_feat,
439                    CFeatTree* feat_tree = 0,
440                    const SAnnotSelector* base_sel = 0,
441                    CFeatTree::EBestGeneType lookup_type = CFeatTree::eBestGene_TreeOnly);
442 
443 
444 NCBI_XOBJUTIL_EXPORT
445 CMappedFeat
446 GetBestGeneForCds(const CMappedFeat& cds_feat,
447                   CFeatTree* feat_tree = 0,
448                   const SAnnotSelector* base_sel = 0,
449                   CFeatTree::EBestGeneType lookup_type = CFeatTree::eBestGene_TreeOnly);
450 
451 
452 NCBI_XOBJUTIL_EXPORT
453 CMappedFeat
454 GetBestMrnaForCds(const CMappedFeat& cds_feat,
455                   CFeatTree* feat_tree = 0,
456                   const SAnnotSelector* base_sel = 0);
457 
458 
459 NCBI_XOBJUTIL_EXPORT
460 CMappedFeat
461 GetBestCdsForMrna(const CMappedFeat& mrna_feat,
462                   CFeatTree* feat_tree = 0,
463                   const SAnnotSelector* base_sel = 0);
464 
465 
466 NCBI_XOBJUTIL_EXPORT
467 void GetMrnasForGene(const CMappedFeat& gene_feat,
468                      list< CMappedFeat >& mrna_feats,
469                      CFeatTree* feat_tree = 0,
470                      const SAnnotSelector* base_sel = 0);
471 
472 
473 NCBI_XOBJUTIL_EXPORT
474 void GetCdssForGene(const CMappedFeat& gene_feat,
475                     list< CMappedFeat >& cds_feats,
476                     CFeatTree* feat_tree = 0,
477                     const SAnnotSelector* base_sel = 0);
478 
479 
480 NCBI_XOBJUTIL_EXPORT
481 CMappedFeat
482 GetBestGeneForFeat(const CMappedFeat& feat,
483                    CFeatTree* feat_tree = 0,
484                    const SAnnotSelector* base_sel = 0,
485                    CFeatTree::EBestGeneType lookup_type = CFeatTree::eBestGene_TreeOnly);
486 
487 
488 NCBI_XOBJUTIL_EXPORT
489 CMappedFeat
490 GetBestParentForFeat(const CMappedFeat& feat,
491                      CSeqFeatData::ESubtype parent_subtype,
492                      CFeatTree* feat_tree = 0,
493                      const SAnnotSelector* base_sel = 0);
494 
495 
496 NCBI_XOBJUTIL_EXPORT
497 CMappedFeat
498 GetBestOverlappingFeat(const CMappedFeat& feat,
499                        CSeqFeatData::ESubtype need_subtype,
500                        sequence::EOverlapType overlap_type,
501                        CFeatTree* feat_tree = 0,
502                        const SAnnotSelector* base_sel = 0);
503 
504 
505 /// Create CSeq_loc_Mapper from a feature, check for special cases
506 /// like exceptions in CDS features. Return null on error.
507 NCBI_XOBJUTIL_EXPORT
508 CRef<CSeq_loc_Mapper>
509 CreateSeqLocMapperFromFeat(const CSeq_feat& feat,
510                            CSeq_loc_Mapper::EFeatMapDirection dir,
511                            CScope* scope = 0);
512 
513 
514 NCBI_XOBJUTIL_EXPORT
515 void ClearFeatureIds(const CSeq_entry_EditHandle& entry);
516 NCBI_XOBJUTIL_EXPORT
517 void ClearFeatureIds(const CSeq_annot_EditHandle& annot);
518 NCBI_XOBJUTIL_EXPORT
519 void ReassignFeatureIds(const CSeq_entry_EditHandle& entry);
520 NCBI_XOBJUTIL_EXPORT
521 void ReassignFeatureIds(const CSeq_annot_EditHandle& annot);
522 NCBI_XOBJUTIL_EXPORT
523 bool GetFeatureGeneBiotype(feature::CFeatTree& ft,
524                            CMappedFeat mf,
525                            string& biotype);
526 NCBI_XOBJUTIL_EXPORT
527 bool GetFeatureGeneBiotypeFaster(feature::CFeatTree& ft,
528                            CMappedFeat mf,
529                            string& biotype);
530 
531 typedef enum {
532     eLocationInFrame_InFrame = 0,
533     eLocationInFrame_BadStart,
534     eLocationInFrame_BadStop,
535     eLocationInFrame_BadStartAndStop,
536     eLocationInFrame_NotIn
537 } ELocationInFrame;
538 
539 /// Determines whether location loc is in frame with coding region cds
540 /// @param cds coding region feature [in]
541 /// @param loc location to compare to coding region
542 /// @return enumerated return value indicates frame is good or either endpoint is bad
543 ELocationInFrame NCBI_XOBJUTIL_EXPORT IsLocationInFrame (const CSeq_feat_Handle& cds, const CSeq_loc& loc);
544 
545 /// Promotes coding region from Seq-annot on nucleotide sequence to Seq-annot
546 /// on nuc-prot-set if necessary and appropriate
547 /// @param orig_feat coding region feature [in]
548 /// @return enumerated return value indicates whether a change was made
549 NCBI_XOBJUTIL_EXPORT bool PromoteCDSToNucProtSet(objects::CSeq_feat_Handle& orig_feat);
550 
551 /// AdjustFeaturePartialFlagForLocation
552 /// A function to ensure that Seq-feat.partial is set if either end of the
553 /// feature is partial, and clear if neither end of the feature is partial
554 /// @param new_feat   The feature to be adjusted (if necessary)
555 ///
556 /// @return           Boolean to indicate whether the feature was changed
557 NCBI_XOBJUTIL_EXPORT bool AdjustFeaturePartialFlagForLocation(CSeq_feat& new_feat);
558 
559 /// CopyFeaturePartials
560 /// A function to copy the start and end partialness from one feature to another
561 /// @param dst       The feature to be adjusted (if necessary)
562 /// @param src       The CDS to match
563 ///
564 /// @return          Boolean to indicate whether the feature was changed
565 NCBI_XOBJUTIL_EXPORT bool CopyFeaturePartials(CSeq_feat& dst, const CSeq_feat& src);
566 
567 /// AdjustProteinMolInfoToMatchCDS
568 /// A function to change an existing MolInfo to match a coding region
569 /// @param molinfo  The MolInfo to be adjusted (if necessary)
570 /// @param cds      The CDS to match
571 ///
572 /// @return         Boolean to indicate whether molinfo was changed
573 NCBI_XOBJUTIL_EXPORT bool AdjustProteinMolInfoToMatchCDS(CMolInfo& molinfo, const CSeq_feat& cds);
574 
575 /// AdjustForCDSPartials
576 /// A function to make all of the necessary related changes to
577 /// a Seq-entry after the partialness of a coding region has been
578 /// changed.
579 /// @param cds        The feature for which adjustments are to be made
580 /// @param seh        The Seq-entry-handle to be adjusted (if necessary)
581 ///
582 /// @return           Boolean to indicate whether the Seq-entry-handle was changed
583 NCBI_XOBJUTIL_EXPORT bool AdjustForCDSPartials(const CSeq_feat& cds, CSeq_entry_Handle seh);
584 
585 /// AdjustForCDSPartials
586 /// A function to make all of the necessary related changes to
587 /// a Seq-entry after the partialness of a coding region has been
588 /// changed.
589 /// @param cds        The feature for which adjustments are to be made
590 /// @param scope      The scope in which to find the protein sequence
591 ///
592 /// @return           Boolean to indicate whether the Seq-entry-handle was changed
593 NCBI_XOBJUTIL_EXPORT bool AdjustForCDSPartials(const CSeq_feat& cds, CScope& scope);
594 
595 /// RetranslateCDS
596 /// A function to replace the protein Bioseq pointed to by cds.product
597 /// with the current translation of the coding region cds.
598 /// @param cds        The feature for which adjustments are to be made
599 ///
600 /// @return           Boolean to indicate whether the coding region was retranslated.
601 NCBI_XOBJUTIL_EXPORT bool RetranslateCDS(const CSeq_feat& cds, CScope& scope);
602 
603 /// AddFeatureToBioseq
604 /// A function to add a feature to a Bioseq - will create a new feature table
605 /// Seq-annot if necessary.
606 /// @param seq        The sequence on which to add the feature
607 /// @param f          The feature to add
608 /// @param scope      The scope that contains the sequence
609 NCBI_XOBJUTIL_EXPORT void AddFeatureToBioseq(const CBioseq& seq, const CSeq_feat& f, CScope& scope);
610 
611 /// AddProteinFeature
612 /// A function to create a protein feature with the specified protein name
613 /// @param seq          The Bioseq on which to create the protein feature
614 /// @param protein_name The protein name
615 /// @param cds          The coding region for this protein feature
616 /// @param scope        The scope in which the sequence can be found
617 NCBI_XOBJUTIL_EXPORT void AddProteinFeature(const CBioseq& seq, const string& protein_name, const CSeq_feat& cds, CScope& scope);
618 
619 END_SCOPE(feature)
620 END_SCOPE(objects)
621 END_NCBI_SCOPE
622 
623 #endif  /* FEAT__HPP */
624