feature_item.cpp
来自「ncbi源码」· C++ 代码 · 共 2,018 行 · 第 1/5 页
CPP
2,018 行
eOverlap_Simple, ctx.GetScope()); if ( (bool)prot && prot->CanGetComment() ) { precursor_comment = prot->GetComment(); } } if ( !pseudo && ctx.Config().ShowPeptides() ) { if ( processed == CProt_ref::eProcessed_mature || processed == CProt_ref::eProcessed_signal_peptide || processed == CProt_ref::eProcessed_transit_peptide ) { CSeqVector pep(m_Feat->GetLocation(), ctx.GetScope()); string peptide; pep.GetSeqData(pep.begin(), pep.end(), peptide); if ( !peptide.empty() ) { x_AddQual(eFQ_peptide, new CFlatStringQVal(peptide)); } } } // cleanup if ( processed == CProt_ref::eProcessed_signal_peptide || processed == CProt_ref::eProcessed_transit_peptide ) { if ( !ctx.IsRefSeq() ) { // Only RefSeq allows product on signal or transit peptide x_RemoveQuals(eFQ_product); } } if ( processed == CProt_ref::eProcessed_preprotein && !ctx.IsRefSeq() && !ctx.IsProt() && feat.GetData().GetSubtype() == CSeqFeatData::eSubtype_preprotein ) { TQI product = m_Quals.Find(eFQ_product); if ( product != m_Quals.end() ) { x_AddQual(eFQ_encodes, product->second); x_RemoveQuals(eFQ_product); } }}struct SLegalImport { const char* m_Name; EFeatureQualifier m_Value; operator string(void) const { return m_Name; }};void CFeatureItem::x_ImportQuals(const CSeq_feat::TQual& quals) const{ typedef pair<const char*, EFeatureQualifier> TLegalImport; static const TLegalImport kLegalImports[] = { // Must be in case-insensitive alphabetical order!#define DO_IMPORT(x) TLegalImport(#x, eFQ_##x) DO_IMPORT(allele), DO_IMPORT(bound_moiety), DO_IMPORT(clone), DO_IMPORT(codon), DO_IMPORT(cons_splice), DO_IMPORT(direction), DO_IMPORT(EC_number), DO_IMPORT(evidence), DO_IMPORT(frequency), DO_IMPORT(function), DO_IMPORT(insertion_seq), DO_IMPORT(label), DO_IMPORT(map), DO_IMPORT(mod_base), DO_IMPORT(number), DO_IMPORT(organism), DO_IMPORT(PCR_conditions), DO_IMPORT(phenotype), TLegalImport("product", eFQ_product_quals), DO_IMPORT(replace), DO_IMPORT(rpt_family), DO_IMPORT(rpt_type), DO_IMPORT(rpt_unit), DO_IMPORT(standard_name), DO_IMPORT(transposon), DO_IMPORT(usedin)#undef DO_IMPORT }; typedef const CStaticArrayMap<const char*, EFeatureQualifier, PNocase> TLegalImportMap; static TLegalImportMap kLegalImportMap(kLegalImports, sizeof(kLegalImports)); ITERATE (CSeq_feat::TQual, it, quals) { const char* name = (*it)->GetQual().c_str(); const TLegalImportMap::const_iterator li = kLegalImportMap.find(name); EFeatureQualifier slot = eFQ_illegal_qual; if ( li != kLegalImportMap.end() ) { slot = li->second; } switch (slot) { case eFQ_codon: case eFQ_cons_splice: case eFQ_direction: case eFQ_evidence: case eFQ_mod_base: case eFQ_number: case eFQ_rpt_type: case eFQ_rpt_unit: case eFQ_usedin: // XXX -- each of these should really get its own class // (to verify correct syntax) x_AddQual(slot, new CFlatStringQVal((*it)->GetVal(), CFormatQual::eUnquoted)); break; case eFQ_label: x_AddQual(slot, new CFlatLabelQVal((*it)->GetVal())); break; case eFQ_illegal_qual: x_AddQual(slot, new CFlatIllegalQVal(**it)); break; default: // XXX - should split off EC_number and replace // (to verify correct syntax) x_AddQual(slot, new CFlatStringQVal((*it)->GetVal())); break; } }}void CFeatureItem::x_FormatQuals(CFlatFeature& ff) const{ const CFlatFileConfig& cfg = GetContext()->Config(); if ( cfg.IsFormatFTable() ) { ff.SetQuals() = m_FTableQuals; return; } ff.SetQuals().reserve(m_Quals.Size()); CFlatFeature::TQuals& qvec = ff.SetQuals();#define DO_QUAL(x) x_FormatQual(eFQ_##x, #x, qvec) DO_QUAL(partial); DO_QUAL(gene); DO_QUAL(locus_tag); DO_QUAL(gene_syn_refseq); x_FormatQual(eFQ_gene_allele, "allele", qvec); DO_QUAL(operon); DO_QUAL(product); x_FormatQual(eFQ_prot_EC_number, "EC_number", qvec); x_FormatQual(eFQ_prot_activity, "function", qvec); DO_QUAL(standard_name); DO_QUAL(coded_by); DO_QUAL(derived_from); x_FormatQual(eFQ_prot_name, "name", qvec); DO_QUAL(region_name); DO_QUAL(bond_type); DO_QUAL(site_type); DO_QUAL(sec_str_type); DO_QUAL(heterogen); if ( !cfg.GoQualsToNote() ) { DO_QUAL(go_component); DO_QUAL(go_function); DO_QUAL(go_process); } x_FormatNoteQuals(ff); DO_QUAL(citation); DO_QUAL(number); DO_QUAL(pseudo); DO_QUAL(selenocysteine); DO_QUAL(codon_start); DO_QUAL(anticodon); DO_QUAL(bound_moiety); DO_QUAL(clone); DO_QUAL(cons_splice); DO_QUAL(direction); DO_QUAL(function); DO_QUAL(evidence); DO_QUAL(exception); DO_QUAL(frequency); DO_QUAL(EC_number); x_FormatQual(eFQ_gene_map, "map", qvec); DO_QUAL(allele); DO_QUAL(map); DO_QUAL(mod_base); DO_QUAL(PCR_conditions); DO_QUAL(phenotype); DO_QUAL(rpt_family); DO_QUAL(rpt_type); DO_QUAL(rpt_unit); DO_QUAL(insertion_seq); DO_QUAL(transposon); DO_QUAL(usedin); // extra imports, actually... x_FormatQual(eFQ_illegal_qual, "illegal", qvec); DO_QUAL(replace); DO_QUAL(transl_except); DO_QUAL(transl_table); DO_QUAL(codon); DO_QUAL(organism); DO_QUAL(label); x_FormatQual(eFQ_cds_product, "product", qvec); DO_QUAL(protein_id); DO_QUAL(transcript_id); DO_QUAL(db_xref); x_FormatQual(eFQ_gene_xref, "db_xref", qvec); DO_QUAL(translation); DO_QUAL(transcription); DO_QUAL(peptide);#undef DO_QUAL}void CFeatureItem::x_FormatNoteQuals(CFlatFeature& ff) const{ CFlatFeature::TQuals qvec;#define DO_NOTE(x) x_FormatNoteQual(eFQ_##x, #x, qvec) x_FormatNoteQual(eFQ_transcript_id_note, "tscpt_id_note", qvec); DO_NOTE(gene_desc); DO_NOTE(gene_syn); DO_NOTE(trna_codons); DO_NOTE(prot_desc); DO_NOTE(prot_note); DO_NOTE(prot_comment); DO_NOTE(prot_method); DO_NOTE(figure); DO_NOTE(maploc); DO_NOTE(prot_conflict); DO_NOTE(prot_missing); DO_NOTE(seqfeat_note); DO_NOTE(exception_note); DO_NOTE(region); DO_NOTE(selenocysteine_note); DO_NOTE(prot_names); DO_NOTE(bond); DO_NOTE(site); DO_NOTE(rrna_its); DO_NOTE(xtra_prod_quals); DO_NOTE(modelev); if ( GetContext()->Config().GoQualsToNote() ) { DO_NOTE(go_component); DO_NOTE(go_function); DO_NOTE(go_process); }#undef DO_NOTE string notestr; const string* suffix = &kEmptyStr; CFlatFeature::TQuals::const_iterator last = qvec.end(); CFlatFeature::TQuals::const_iterator end = last--; CFlatFeature::TQuals::const_iterator it = qvec.begin(); bool add_period = false; for ( ; it != end; ++it ) { add_period = false; string note = (*it)->GetValue(); if ( NStr::EndsWith(note, ".") && !NStr::EndsWith(note, "...") ) { note.erase(note.length() - 1); add_period = true; } const string& prefix = *suffix + (*it)->GetPrefix(); JoinNoRedund(notestr, prefix, note); suffix = &(*it)->GetSuffix(); } if ( !notestr.empty() ) { NStr::TruncateSpaces(notestr); if ( add_period && !NStr::EndsWith(notestr, ".") ) { notestr += "."; } CRef<CFormatQual> note(new CFormatQual("note", ExpandTildes(notestr, eTilde_newline))); ff.SetQuals().push_back(note); }}void CFeatureItem::x_FormatQual(EFeatureQualifier slot, const string& name, CFlatFeature::TQuals& qvec, IFlatQVal::TFlags flags) const{ pair<TQCI, TQCI> range = const_cast<const TQuals&>(m_Quals).GetQuals(slot); for (TQCI it = range.first; it != range.second; ++it) { it->second->Format(qvec, name, *GetContext(), flags); }}const CFlatStringQVal* CFeatureItem::x_GetStringQual(EFeatureQualifier slot) const{ const IFlatQVal* qual = 0; if ( x_HasQual(slot) ) { qual = m_Quals.Find(slot)->second; } return dynamic_cast<const CFlatStringQVal*>(qual);}void CFeatureItem::x_CleanQuals(void) const{ if ( GetContext()->Config().DropIllegalQuals() ) { x_DropIllegalQuals(); } const CFlatStringQVal* gene = x_GetStringQual(eFQ_gene); if ( gene != 0 ) { // /gene same as feature.comment will suppress /note if ( m_Feat->CanGetComment() ) { if ( NStr::Equal(gene->GetValue(), m_Feat->GetComment()) ) { x_RemoveQuals(eFQ_seqfeat_note); } } // remove protein description that equals the gene name, case sensitive const CFlatStringQVal* prod_desc = x_GetStringQual(eFQ_prot_desc); if ( prod_desc != 0 ) { if ( NStr::Equal(gene->GetValue(), prod_desc->GetValue()) ) { x_RemoveQuals(eFQ_prot_desc); } } }}typedef pair<EFeatureQualifier, CSeqFeatData::EQualifier> TQualPair;static const TQualPair sc_GbToFeatQualMap[] = { TQualPair(eFQ_none, CSeqFeatData::eQual_bad), TQualPair(eFQ_allele, CSeqFeatData::eQual_allele), TQualPair(eFQ_anticodon, CSeqFeatData::eQual_anticodon), TQualPair(eFQ_bond, CSeqFeatData::eQual_note), TQualPair(eFQ_bond_type, CSeqFeatData::eQual_bad), TQualPair(eFQ_bound_moiety, CSeqFeatData::eQual_bound_moiety), TQualPair(eFQ_cds_product, CSeqFeatData::eQual_product), TQualPair(eFQ_citation, CSeqFeatData::eQual_citation), TQualPair(eFQ_clone, CSeqFeatData::eQual_clone), TQualPair(eFQ_coded_by, CSeqFeatData::eQual_bad), TQualPair(eFQ_codon, CSeqFeatData::eQual_codon), TQualPair(eFQ_codon_start, CSeqFeatData::eQual_codon_start), TQualPair(eFQ_cons_splice, CSeqFeatData::eQual_cons_splice), TQualPair(eFQ_db_xref, CSeqFeatData::eQual_db_xref), TQualPair(eFQ_derived_from, CSeqFeatData::eQual_bad), TQualPair(eFQ_direction, CSeqFeatData::eQual_direction), TQualPair(eFQ_EC_number, CSeqFeatData::eQual_EC_number), TQualPair(eFQ_encodes, CSeqFeatData::eQual_note), TQualPair(eFQ_evidence, CSeqFeatData::eQual_evidence), TQualPair(eFQ_exception, CSeqFeatData::eQual_exception), TQualPair(eFQ_exception_note, CSeqFeatData::eQual_note), TQualPair(eFQ_figure, CSeqFeatData::eQual_note), TQualPair(eFQ_frequency, CSeqFeatData::eQual_frequency), TQualPair(eFQ_function, CSeqFeatData::eQual_function), TQualPair(eFQ_gene, CSeqFeatData::eQual_gene), TQualPair(eFQ_gene_desc, CSeqFeatData::eQual_note), TQualPair(eFQ_gene_allele, CSeqFeatData::eQual_allele), TQualPair(eFQ_gene_map, CSeqFeatData::eQual_bad), TQualPair(eFQ_gene_syn, CSeqFeatData::eQual_note), TQualPair(eFQ_gene_syn_refseq, CSeqFeatData::eQual_bad), TQualPair(eFQ_gene_note, CSeqFeatData::eQual_note), TQualPair(eFQ_gene_xref, CSeqFeatData::eQual_db_xref), TQualPair(eFQ_go_component, CSeqFeatData::eQual_note), TQualPair(eFQ_go_function, CSeqFeatData::eQual_note), TQualPair(eFQ_go_process, CSeqFeatData::eQual_note), TQualPair(eFQ_heterogen, CSeqFeatData::eQual_bad), TQualPair(eFQ_illegal_qual, CSeqFeatData::eQual_bad), TQualPair(eFQ_insertion_seq, CSeqFeatData::eQual_insertion_seq), TQualPair(eFQ_label, CSeqFeatData::eQual_label), TQualPair(eFQ_locus_tag, CSeqFeatData::eQual_locus_tag), TQualPair(eFQ_map, CSeqFeatData::eQual_map), TQualPair(eFQ_maploc, CSeqFeatData::eQual_note), TQualPair(eFQ_mod_base, CSeqFeatData::eQual_mod_base), TQualPair(eFQ_modelev, CSeqFeatData::eQual_note), TQualPair(eFQ_number, CSeqFeatData::eQual_number), TQualPair(eFQ_operon, CSeqFeatData::eQual_operon), TQualPair(eFQ_organism, CSeqFeatData::eQual_organism), TQualPair(eFQ_partial, CSeqFeatData::eQual_partial), TQualPair(eFQ_PCR_conditions, CSeqFeatData::eQual_PCR_conditions), TQualPair(eFQ_peptide, CSeqFeatData::eQual_bad), TQualPair(eFQ_phenotype, CSeqFeatData::eQual_phenotype), TQualPair(eFQ_product, CSeqFeatData::eQual_product), TQualPair(eFQ_product_quals, CSeqFeatData::eQual_product), TQualPair(eFQ_prot_activity, CSeqFeatData::eQual_bad), TQualPair(eFQ_prot_comment, CSeqFeatData::eQual_note), TQualPair(eFQ_prot_EC_number, CSeqFeatData::eQual_bad), TQualPair(eFQ_prot_note, CSeqFeatData::eQual_note), TQualPair(eFQ_prot_method, CSeqFeatData::eQual_note), TQualPair(eFQ_prot_conflict, CSeqFeatData::eQual_note), TQualPair(eFQ_prot_desc, CSeqFeatData::eQual_note), TQualPair(eFQ_prot_missing, CSeqFeatData::eQual_note), TQualPair(eFQ_prot_name, CSeqFeatData::eQual_bad), TQualPair(eFQ_prot_nam
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?