feature_item.cpp
来自「ncbi源码」· C++ 代码 · 共 2,018 行 · 第 1/5 页
CPP
2,018 行
"oxidative-deamination", "pyrrolidone-carboxylic-acid", "gamma-carboxyglutamic-acid", "blocked", "lipid-binding", "np-binding", "DNA binding", "signal-peptide", "transit-peptide", "transmembrane-region", "unclassified"};static const string s_PsecStrText[] = { "", "helix", "sheet", "turn"};// -- FeatureHeaderCFeatHeaderItem::CFeatHeaderItem(CBioseqContext& ctx) : CFlatItem(&ctx){ x_GatherInfo(ctx);}void CFeatHeaderItem::x_GatherInfo(CBioseqContext& ctx){ if ( ctx.Config().IsFormatFTable() ) { m_Id.Reset(ctx.GetPrimaryId()); }}// -- FeatureItem// constructorCFeatureItemBase::CFeatureItemBase(const CSeq_feat& feat, CBioseqContext& ctx, const CSeq_loc* loc) : CFlatItem(&ctx), m_Feat(&feat), m_Loc(loc != 0 ? loc : &feat.GetLocation()){}CConstRef<CFlatFeature> CFeatureItemBase::Format(void) const{ CRef<CFlatFeature> ff(new CFlatFeature(GetKey(), *new CFlatSeqLoc(GetLoc(), *GetContext()), *m_Feat)); if ( ff ) { x_FormatQuals(*ff); } return ff;}static bool s_CheckFuzz(const CInt_fuzz& fuzz){ return !(fuzz.IsLim() && fuzz.GetLim() == CInt_fuzz::eLim_unk);}static bool s_LocIsFuzz(const CSeq_feat& feat, const CSeq_loc& loc){ if ( feat.GetData().GetSubtype() == CSeqFeatData::eSubtype_imp && feat.GetData().IsImp() ) { // unmappable impfeats const CSeqFeatData::TImp& imp = feat.GetData().GetImp(); if ( imp.CanGetLoc() ) { const string& imploc = imp.GetLoc(); if ( imploc.find('<') != NPOS || imploc.find('>') != NPOS ) { return true; } } } else { // any regular feature test location for fuzz for ( CSeq_loc_CI it(loc); it; ++it ) { const CSeq_loc& l = it.GetSeq_loc(); switch ( l.Which() ) { case CSeq_loc::e_Pnt: {{ if ( l.GetPnt().CanGetFuzz() ) { if ( s_CheckFuzz(l.GetPnt().GetFuzz()) ) { return true; } } break; }} case CSeq_loc::e_Packed_pnt: {{ if ( l.GetPacked_pnt().CanGetFuzz() ) { if ( s_CheckFuzz(l.GetPacked_pnt().GetFuzz()) ) { return true; } } break; }} case CSeq_loc::e_Int: {{ bool fuzz = false; if ( l.GetInt().CanGetFuzz_from() ) { fuzz = s_CheckFuzz(l.GetInt().GetFuzz_from()); } if ( !fuzz && l.GetInt().CanGetFuzz_to() ) { fuzz = s_CheckFuzz(l.GetInt().GetFuzz_to()); } if ( fuzz ) { return true; } break; }} default: break; } } } return false;}/////////////////////////////////////////////////////////////////////////////// CFeatureItemstring CFeatureItem::GetKey(void) const{ CBioseqContext& ctx = *GetContext(); CSeqFeatData::E_Choice type = m_Feat->GetData().Which(); CSeqFeatData::ESubtype subtype = m_Feat->GetData().GetSubtype(); if ( GetContext()->IsProt() ) { if ( IsMappedFromProt() && type == CSeqFeatData::e_Prot ) { if ( subtype == CSeqFeatData::eSubtype_preprotein || subtype == CSeqFeatData::eSubtype_mat_peptide_aa || subtype == CSeqFeatData::eSubtype_sig_peptide_aa || subtype == CSeqFeatData::eSubtype_transit_peptide_aa ) { return "Precursor"; } } switch ( subtype ) { case CSeqFeatData::eSubtype_region: return "Region"; case CSeqFeatData::eSubtype_bond: return "Bond"; case CSeqFeatData::eSubtype_site: return "Site"; default: break; } } else if ( subtype == CSeqFeatData::eSubtype_preprotein && !ctx.IsRefSeq() ) { return "misc_feature"; } // deal with unmappable impfeats if ( subtype == CSeqFeatData::eSubtype_imp && type == CSeqFeatData::e_Imp ) { const CSeqFeatData::TImp& imp = m_Feat->GetData().GetImp(); if ( imp.CanGetKey() ) { return imp.GetKey(); } } return CFeatureItemBase::GetKey();}// constructor from CSeq_featCFeatureItem::CFeatureItem(const CSeq_feat& feat, CBioseqContext& ctx, const CSeq_loc* loc, EMapped mapped) : CFeatureItemBase(feat, ctx, loc), m_Mapped(mapped){ x_GatherInfo(ctx);}void CFeatureItem::x_GatherInfo(CBioseqContext& ctx){ if ( s_SkipFeature(GetFeat(), ctx) ) { x_SetSkip(); return; } m_Type = m_Feat->GetData().GetSubtype(); //x_FixLocation(ctx); x_AddQuals(ctx);}void CFeatureItem::x_AddQuals(CBioseqContext& ctx){ if ( ctx.Config().IsFormatFTable() ) { x_AddFTableQuals(ctx); return; } CScope& scope = ctx.GetScope(); const CSeqFeatData& data = m_Feat->GetData(); const CSeq_loc& loc = GetLoc(); CSeqFeatData::E_Choice type = data.Which(); CSeqFeatData::ESubtype subtype = data.GetSubtype(); bool pseudo = m_Feat->CanGetPseudo() ? m_Feat->GetPseudo() : false; bool had_prot_desc = false; string precursor_comment; // add various common qualifiers... // partial if ( !(IsMappedFromCDNA() && ctx.IsProt()) && !ctx.Config().HideUnclassPartial() ) { if ( m_Feat->CanGetPartial() && m_Feat->GetPartial() ) { if ( !s_LocIsFuzz(*m_Feat, loc) ) { int partial = SeqLocPartialCheck(m_Feat->GetLocation(), &scope); if ( partial == eSeqlocPartial_Complete ) { x_AddQual(eFQ_partial, new CFlatBoolQVal(true)); } } } } // dbxref if (m_Feat->IsSetDbxref()) { x_AddQual(eFQ_db_xref, new CFlatXrefQVal(m_Feat->GetDbxref(), &m_Quals)); } // model_evidance and go quals if ( m_Feat->IsSetExt() ) { x_AddExtQuals(m_Feat->GetExt()); } // evidence if ( !ctx.IsProt() && m_Feat->IsSetExp_ev() ) { x_AddQual(eFQ_evidence, new CFlatExpEvQVal(m_Feat->GetExp_ev())); } // citation if (m_Feat->IsSetCit()) { x_AddQual(eFQ_citation, new CFlatPubSetQVal(m_Feat->GetCit())); } // exception x_AddExceptionQuals(ctx); if ( !data.IsGene() && (subtype != CSeqFeatData::eSubtype_operon) ) { const CGene_ref* grp = m_Feat->GetGeneXref(); CConstRef<CSeq_feat> overlap_gene; if ( grp != 0 && grp->CanGetDb() ) { x_AddQual(eFQ_gene_xref, new CFlatXrefQVal(grp->GetDb())); } if ( grp == 0 ) { const CSeq_loc& gene_loc = (ctx.IsProt() || !IsMapped()) ? m_Feat->GetLocation() : GetLoc(); overlap_gene = GetOverlappingGene(gene_loc, scope); if ( overlap_gene ) { if ( overlap_gene->CanGetComment() ) { x_AddQual(eFQ_gene_note, new CFlatStringQVal(overlap_gene->GetComment())); } if ( overlap_gene->CanGetPseudo() && overlap_gene->GetPseudo() ) { pseudo = true; } grp = &overlap_gene->GetData().GetGene(); if ( grp != 0 && grp->IsSetDb() ) { x_AddQual(eFQ_gene_xref, new CFlatXrefQVal(grp->GetDb())); } else if ( overlap_gene->IsSetDbxref() ) { x_AddQual(eFQ_gene_xref, new CFlatXrefQVal(overlap_gene->GetDbxref())); } } } if ( grp != 0 ) { if (grp->CanGetPseudo() && grp->GetPseudo() ) { pseudo = true; } if ( !grp->IsSuppressed() && (!overlap_gene || subtype != CSeqFeatData::eSubtype_repeat_region) ) { x_AddQuals(*grp); } if ( subtype != CSeqFeatData::eSubtype_variation ) { if ( grp->IsSetAllele() && !grp->GetAllele().empty() ) { // now propagating /allele x_AddQual(eFQ_gene_allele, new CFlatStringQVal(grp->GetAllele())); } } } if ( type != CSeqFeatData::e_Cdregion && type != CSeqFeatData::e_Rna ) { x_RemoveQuals(eFQ_gene_xref); } } // specific fields set here... switch ( type ) { case CSeqFeatData::e_Gene: x_AddGeneQuals(*m_Feat, scope); break; case CSeqFeatData::e_Cdregion: x_AddCdregionQuals(*m_Feat, ctx, pseudo, had_prot_desc); break; case CSeqFeatData::e_Rna: x_AddRnaQuals(*m_Feat, ctx, pseudo); break; case CSeqFeatData::e_Prot: x_AddProtQuals(*m_Feat, ctx, pseudo, had_prot_desc, precursor_comment); break; case CSeqFeatData::e_Region: x_AddRegionQuals(*m_Feat, ctx); break; // !!! case CSeqFeatData::e_XXX: default: break; } if ( pseudo ) { bool add_pseudo = true; // if RELEASE_MODE, check list of features that can have /pseudo if ( ctx.Config().DropIllegalQuals() && (data.IsRna() || data.IsImp()) ) { switch ( subtype ) { case CSeqFeatData::eSubtype_allele: case CSeqFeatData::eSubtype_attenuator: case CSeqFeatData::eSubtype_CAAT_signal: case CSeqFeatData::eSubtype_conflict: case CSeqFeatData::eSubtype_D_loop: case CSeqFeatData::eSubtype_enhancer: case CSeqFeatData::eSubtype_GC_signal: case CSeqFeatData::eSubtype_iDNA: case CSeqFeatData::eSubtype_intron: case CSeqFeatData::eSubtype_LTR: case CSeqFeatData::eSubtype_misc_binding: case CSeqFeatData::eSubtype_misc_difference: case CSeqFeatData::eSubtype_misc_recomb: case CSeqFeatData::eSubtype_misc_RNA: case CSeqFeatData::eSubtype_misc_signal: case CSeqFeatData::eSubtype_misc_structure: case CSeqFeatData::eSubtype_modified_base: case CSeqFeatData::eSubtype_mutation: case CSeqFeatData::eSubtype_old_sequence: case CSeqFeatData::eSubtype_polyA_signal: case CSeqFeatData::eSubtype_polyA_site: case CSeqFeatData::eSubtype_precursor_RNA: case CSeqFeatData::eSubtype_prim_transcript: case CSeqFeatData::eSubtype_primer_bind: case CSeqFeatData::eSubtype_protein_bind: case CSeqFeatData::eSubtype_RBS: case CSeqFeatData::eSubtype_repeat_region: case CSeqFeatData::eSubtype_repeat_unit: case CSeqFeatData::eSubtype_rep_origin: case CSeqFeatData::eSubtype_satellite: case CSeqFeatData::eSubtype_stem_loop: case CSeqFeatData::eSubtype_STS: case CSeqFeatData::eSubtype_TATA_signal: case CSeqFeatData::eSubtype_terminator: case CSeqFeatData::eSubtype_unsure: case CSeqFeatData::eSubtype_variation: case CSeqFeatData::eSubtype_3clip: case CSeqFeatData::eSubtype_3UTR: case CSeqFeatData::eSubtype_5clip: case CSeqFeatData::eSubtype_5UTR: case CSeqFeatData::eSubtype_10_signal: case CSeqFeatData::eSubtype_35_signal: add_pseudo = false; break; default: break; } } if ( add_pseudo ) { x_AddQual(eFQ_pseudo, new CFlatBoolQVal(true)); } } // comment if (m_Feat->IsSetComment()) { string comment = m_Feat->GetComment(); if ( had_prot_desc && NStr::EndsWith(m_Feat->GetComment(), ".") ) { comment.erase(comment.length() - 1); } if ( precursor_comment != comment ) { x_AddQual(eFQ_seqfeat_note, new CFlatStringQVal(comment)); } } // now go through gbqual list if (m_Feat->IsSetQual()) { x_ImportQuals(m_Feat->GetQual()); } // cleanup (drop illegal quals, duplicate information etc.) x_CleanQuals();}static const string s_TrnaList[] = { "tRNA-Gap", "tRNA-Ala", "tRNA-Asx", "tRNA-Cys", "tRNA-Asp", "tRNA-Glu", "tRNA-Phe",
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?