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

Go to the SVN repository for this file.

00001 /*  $Id: feat_ci.cpp 50919 2011-08-18 13:26:53Z kornbluh $
00002 * ===========================================================================
00003 *
00004 *                            PUBLIC DOMAIN NOTICE
00005 *               National Center for Biotechnology Information
00006 *
00007 *  This software/database is a "United States Government Work" under the
00008 *  terms of the United States Copyright Act.  It was written as part of
00009 *  the author's official duties as a United States Government employee and
00010 *  thus cannot be copyrighted.  This software/database is freely available
00011 *  to the public for use. The National Library of Medicine and the U.S.
00012 *  Government have not placed any restriction on its use or reproduction.
00013 *
00014 *  Although all reasonable efforts have been taken to ensure the accuracy
00015 *  and reliability of the software and data, the NLM and the U.S.
00016 *  Government do not and cannot warrant the performance or results that
00017 *  may be obtained by using this software or data. The NLM and the U.S.
00018 *  Government disclaim all warranties, express or implied, including
00019 *  warranties of performance, merchantability or fitness for any particular
00020 *  purpose.
00021 *
00022 *  Please cite the author in any work or product based on this material.
00023 *
00024 * ===========================================================================
00025 *
00026 * Author: Aleksey Grichenko, Eugene Vasilchenko
00027 *
00028 * File Description:
00029 *   Object manager iterators
00030 *
00031 */
00032 
00033 #include <ncbi_pch.hpp>
00034 #include <objmgr/feat_ci.hpp>
00035 #include <objmgr/bioseq_handle.hpp>
00036 #include <objmgr/seq_entry_handle.hpp>
00037 #include <objmgr/seq_annot_handle.hpp>
00038 #include <objmgr/impl/annot_object.hpp>
00039 #include <objmgr/impl/seq_annot_info.hpp>
00040 #include <objmgr/impl/snp_annot_info.hpp>
00041 #include <objmgr/impl/annot_type_index.hpp>
00042 #include <objmgr/impl/tse_info.hpp>
00043 #include <objects/seqfeat/Gb_qual.hpp>
00044 #include <objects/seqfeat/SeqFeatXref.hpp>
00045 #include <objects/general/Dbtag.hpp>
00046 #include <objects/general/Object_id.hpp>
00047 #include <objects/seqloc/Seq_id.hpp>
00048 #include <objects/seqloc/Na_strand.hpp>
00049 #include <objects/seqloc/Seq_loc.hpp>
00050 #include <objects/seqloc/Seq_point.hpp>
00051 #include <objects/seqloc/Seq_interval.hpp>
00052 
00053 BEGIN_NCBI_SCOPE
00054 BEGIN_SCOPE(objects)
00055 
00056 
00057 CFeat_CI::CFeat_CI(void)
00058 {
00059 }
00060 
00061 
00062 CFeat_CI::CFeat_CI(const CFeat_CI& iter)
00063     : CAnnotTypes_CI(iter)
00064 {
00065     Update();
00066 }
00067 
00068 
00069 CFeat_CI::~CFeat_CI(void)
00070 {
00071 }
00072 
00073 
00074 CFeat_CI& CFeat_CI::operator= (const CFeat_CI& iter)
00075 {
00076     if ( this != &iter ) {
00077         CAnnotTypes_CI::operator=(iter);
00078         Update();
00079     }
00080     return *this;
00081 }
00082 
00083 
00084 CFeat_CI::CFeat_CI(const CBioseq_Handle& bioseq)
00085     : CAnnotTypes_CI(CSeq_annot::C_Data::e_Ftable,
00086                      bioseq,
00087                      CRange<TSeqPos>::GetWhole(),
00088                      eNa_strand_unknown)
00089 {
00090     Update();
00091 }
00092 
00093 
00094 CFeat_CI::CFeat_CI(const CBioseq_Handle& bioseq,
00095                    const SAnnotSelector& sel)
00096     : CAnnotTypes_CI(CSeq_annot::C_Data::e_Ftable,
00097                      bioseq,
00098                      CRange<TSeqPos>::GetWhole(),
00099                      eNa_strand_unknown,
00100                      &sel)
00101 {
00102     Update();
00103 }
00104 
00105 
00106 CFeat_CI::CFeat_CI(const CBioseq_Handle& bioseq,
00107                    const CRange<TSeqPos>& range,
00108                    ENa_strand strand)
00109     : CAnnotTypes_CI(CSeq_annot::C_Data::e_Ftable,
00110                      bioseq,
00111                      range,
00112                      strand)
00113 {
00114     Update();
00115 }
00116 
00117 
00118 CFeat_CI::CFeat_CI(const CBioseq_Handle& bioseq,
00119                    const CRange<TSeqPos>& range,
00120                    const SAnnotSelector& sel)
00121     : CAnnotTypes_CI(CSeq_annot::C_Data::e_Ftable,
00122                      bioseq,
00123                      range,
00124                      eNa_strand_unknown,
00125                      &sel)
00126 {
00127     Update();
00128 }
00129 
00130 
00131 CFeat_CI::CFeat_CI(const CBioseq_Handle& bioseq,
00132                    const CRange<TSeqPos>& range,
00133                    ENa_strand strand,
00134                    const SAnnotSelector& sel)
00135     : CAnnotTypes_CI(CSeq_annot::C_Data::e_Ftable,
00136                      bioseq,
00137                      range,
00138                      strand,
00139                      &sel)
00140 {
00141     Update();
00142 }
00143 
00144 
00145 CFeat_CI::CFeat_CI(CScope& scope,
00146                    const CSeq_loc& loc)
00147     : CAnnotTypes_CI(CSeq_annot::C_Data::e_Ftable,
00148                      scope,
00149                      loc)
00150 {
00151     Update();
00152 }
00153 
00154 
00155 CFeat_CI::CFeat_CI(CScope& scope,
00156                    const CSeq_loc& loc,
00157                    const SAnnotSelector& sel)
00158     : CAnnotTypes_CI(CSeq_annot::C_Data::e_Ftable,
00159                      scope,
00160                      loc,
00161                      &sel)
00162 {
00163     Update();
00164 }
00165 
00166 
00167 CFeat_CI::CFeat_CI(const CSeq_annot_Handle& annot)
00168     : CAnnotTypes_CI(CSeq_annot::C_Data::e_Ftable,
00169                      annot)
00170 {
00171     Update();
00172 }
00173 
00174 
00175 CFeat_CI::CFeat_CI(const CSeq_annot_Handle& annot,
00176                    const SAnnotSelector& sel)
00177     : CAnnotTypes_CI(CSeq_annot::C_Data::e_Ftable,
00178                      annot,
00179                      &sel)
00180 {
00181     Update();
00182 }
00183 
00184 
00185 CFeat_CI::CFeat_CI(const CSeq_entry_Handle& entry)
00186     : CAnnotTypes_CI(CSeq_annot::C_Data::e_Ftable,
00187                      entry)
00188 {
00189     Update();
00190 }
00191 
00192 
00193 CFeat_CI::CFeat_CI(const CSeq_entry_Handle& entry,
00194                    const SAnnotSelector& sel)
00195     : CAnnotTypes_CI(CSeq_annot::C_Data::e_Ftable,
00196                      entry,
00197                      &sel)
00198 {
00199     Update();
00200 }
00201 
00202 
00203 CFeat_CI::CFeat_CI(const CTSE_Handle& tse,
00204                    const SAnnotSelector& sel,
00205                    const TFeatureId& feat_id)
00206     : CAnnotTypes_CI(tse.GetScope())
00207 {
00208     x_AddFeaturesWithId(tse, sel, feat_id);
00209 }
00210 
00211 
00212 CFeat_CI::CFeat_CI(const CTSE_Handle& tse,
00213                    const SAnnotSelector& sel,
00214                    const TFeatureIdInt& int_id)
00215     : CAnnotTypes_CI(tse.GetScope())
00216 {
00217     CObject_id feat_id;
00218     feat_id.SetId(int_id);
00219     x_AddFeaturesWithId(tse, sel, feat_id);
00220 }
00221 
00222 
00223 CFeat_CI::CFeat_CI(const CTSE_Handle& tse,
00224                    const SAnnotSelector& sel,
00225                    const TFeatureIdStr& str_id)
00226     : CAnnotTypes_CI(tse.GetScope())
00227 {
00228     CObject_id feat_id;
00229     feat_id.SetStr(str_id);
00230     x_AddFeaturesWithId(tse, sel, feat_id);
00231 }
00232 
00233 
00234 void CFeat_CI::x_AddFeaturesWithId(const CTSE_Handle& tse,
00235                                    const SAnnotSelector& sel,
00236                                    const TFeatureId& feat_id)
00237 {
00238     CSeqFeatData::ESubtype subtype = sel.GetFeatSubtype();
00239     if ( subtype == CSeqFeatData::eSubtype_any ) {
00240         if ( sel.GetFeatProduct() ) {
00241             x_AddFeatures(sel, tse.GetFeaturesWithXref(subtype, feat_id));
00242         }
00243         else {
00244             x_AddFeatures(sel, tse.GetFeaturesWithId(subtype, feat_id));
00245         }
00246     }
00247     else {
00248         pair<size_t, size_t> range = CAnnotType_Index::GetIndexRange(sel);
00249         for ( size_t i = range.first; i < range.second; ++i ) {
00250             subtype = CAnnotType_Index::GetSubtypeForIndex(i);
00251             if ( !tse.x_GetTSE_Info().x_HasFeaturesWithId(subtype) ) {
00252                 continue;
00253             }
00254             if ( sel.GetFeatProduct() ) {
00255                 x_AddFeatures(sel, tse.GetFeaturesWithXref(subtype, feat_id));
00256             }
00257             else {
00258                 x_AddFeatures(sel, tse.GetFeaturesWithId(subtype, feat_id));
00259             }
00260         }
00261     }
00262     Rewind();
00263 }
00264 
00265 
00266 void CFeat_CI::x_AddFeatures(const SAnnotSelector& sel,
00267                              const TSeq_feat_Handles& feats)
00268 {
00269     CAnnot_Collector& collector = GetCollector();
00270     collector.m_Selector = &sel;
00271     ITERATE ( TSeq_feat_Handles, it, feats ) {
00272         const CAnnotObject_Info& info = it->x_GetAnnotObject_Info();
00273         if ( collector.x_MatchLimitObject(info) ) {
00274             CAnnotObject_Ref feat_ref(info, it->GetAnnot());
00275             collector.x_AddObject(feat_ref);
00276         }
00277     }
00278 }
00279 
00280 
00281 END_SCOPE(objects)
00282 END_NCBI_SCOPE
Modified on Sat Mar 28 10:14:45 2015 by modify_doxy.py rev. 426318