flat_text_formatter.cpp
来自「ncbi源码」· C++ 代码 · 共 489 行 · 第 1/2 页
CPP
489 行
ref.GetTitles(title, journal, *m_Context); Wrap(l, "TITLE", title, eSubp); Wrap(l, "JOURNAL", journal, eSubp); }} ITERATE (set<int>, it, ref.GetMUIDs()) { if (DoHTML()) { Wrap(l, "MEDLINE", "<a href=\"" + ref.GetMedlineURL(*it) + "\">" + NStr::IntToString(*it) + "</a>", eSubp); } else { Wrap(l, "MEDLINE", NStr::IntToString(*it), eSubp); } } ITERATE (set<int>, it, ref.GetPMIDs()) { if (DoHTML()) { Wrap(l, " PUBMED", "<a href=\"" + ref.GetPubMedURL(*it) + "\">" + NStr::IntToString(*it) + "</a>", eSubp); } else { Wrap(l, " PUBMED", NStr::IntToString(*it), eSubp); } } Wrap(l, "REMARK", ref.GetRemark(), eSubp); m_Stream->AddParagraph(l, &ref, &ref.GetPubdesc());}void CFlatTextFormatter::FormatComment(const CFlatComment& comment){ if (comment.GetComment().empty()) { return; } string comment2 = ExpandTildes(comment.GetComment(), eTilde_newline); if ( !NStr::EndsWith(comment2, ".") ) { comment2 += '.'; } list<string> l; Wrap(l, "COMMENT", comment2); m_Stream->AddParagraph(l, &comment);}void CFlatTextFormatter::FormatPrimary(const CFlatPrimary& primary){ list<string> l; Wrap(l, "PRIMARY", primary.GetHeader()); ITERATE (CFlatPrimary::TPieces, it, primary.GetPieces()) { string s; Wrap(l, kEmptyStr, it->Format(s)); } m_Stream->AddParagraph (l, &primary, &m_Context->GetHandle().GetBioseqCore()->GetInst().GetHist());}void CFlatTextFormatter::FormatFeatHeader(const CFlatFeatHeader& fh){ list<string> l; Wrap(l, "FEATURES", "Location/Qualifiers", eFeatHead); m_Stream->AddParagraph(l, &fh);}void CFlatTextFormatter::FormatFeature(const IFlattishFeature& f){ const CFlatFeature& feat = *f.Format(); list<string> l; Wrap(l, feat.GetKey(), feat.GetLoc().GetString(), eFeat); ITERATE (vector<CRef<CFlatQual> >, it, feat.GetQuals()) { string qual = '/' + (*it)->GetName(), value = (*it)->GetValue(); switch ((*it)->GetStyle()) { case CFlatQual::eEmpty: value.erase(); break; case CFlatQual::eQuoted: qual += "=\""; value += '"'; break; case CFlatQual::eUnquoted: qual += '='; break; } // Call NStr::Wrap directly to avoid unwanted line breaks right // before the start of the value (in /translation, e.g.) NStr::Wrap(value, m_Stream->GetWidth(), l, DoHTML() ? NStr::fWrap_HTMLPre : 0, m_FeatIndent, m_FeatIndent + qual); } m_Stream->AddParagraph(l, &f, &feat.GetFeat());}void CFlatTextFormatter::FormatDataHeader(const CFlatDataHeader& dh){ list<string> l; if ( !m_Context->IsProt() ) { TSeqPos a, c, g, t, other; dh.GetCounts(a, c, g, t, other); CNcbiOstrstream oss; oss << ' ' << setw(6) << a << " a " << setw(6) << c << " c " << setw(6) << g << " g " << setw(6) << t << " t"; if (other) { oss << ' ' << setw(6) << other << " other"; } Wrap(l, "BASE COUNT", CNcbiOstrstreamToString(oss)); } l.push_back("ORIGIN"); m_Stream->AddParagraph(l, &dh);}void CFlatTextFormatter::FormatData(const CFlatData& data){ static const TSeqPos kChunkSize = 1200; // 20 lines string buf; CSeqVector v = m_Context->GetHandle().GetSequenceView (data.GetLoc(), CBioseq_Handle::eViewConstructed, CBioseq_Handle::eCoding_Iupac); for (TSeqPos pos = 0; pos < v.size(); pos += kChunkSize) { list<string> lines; CNcbiOstrstream oss; TSeqPos l = min(kChunkSize, v.size() - pos); v.GetSeqData(pos, pos + l, buf); for (TSeqPos i = 0; i < l; ++i) { if (i % 60 == 0) { if (i > 0) { oss << '\n'; } oss << setw(9) << pos + i + 1; } if (i % 10 == 0) { oss << ' '; } oss.put(tolower(buf[i])); } NStr::Split(CNcbiOstrstreamToString(oss), "\n", lines); // should use narrower location m_Stream->AddParagraph(lines, &data, &data.GetLoc()); }}void CFlatTextFormatter::FormatContig(const CFlatContig& contig){ list<string> l; Wrap(l, "CONTIG", CFlatLoc(contig.GetLoc(), *m_Context).GetString()); m_Stream->AddParagraph (l, &contig, &m_Context->GetHandle().GetBioseqCore()->GetInst().GetExt());}void CFlatTextFormatter::FormatWGSRange(const CFlatWGSRange& range){ list<string> l; if (DoHTML()) { Wrap(l, "WGS", "<a href=\"http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?" "db=Nucleotide&cmd=Search&term=" + range.GetFirstID() + ':' + range.GetLastID() + "[ACCN]\">" + range.GetFirstID() + "-" + range.GetLastID() + "</a>"); } else { Wrap(l, "WGS", range.GetFirstID() + "-" + range.GetLastID()); } m_Stream->AddParagraph(l, &range, &range.GetUserObject());}void CFlatTextFormatter::FormatGenomeInfo(const CFlatGenomeInfo& g){ list<string> l; string s = g.GetAccession(); if ( !g.GetMoltype().empty()) { s += " (" + g.GetMoltype() + ')'; } Wrap(l, "GENOME", s); m_Stream->AddParagraph(l, &g, &g.GetUserObject());}void CFlatTextFormatter::EndSequence(void){ list<string> l; l.push_back("//"); m_Stream->AddParagraph(l);}string& CFlatTextFormatter::Pad(const string& s, string& out, EPadContext where){ switch (where) { case ePara: return Pad(s, out, 12); case eSubp: return Pad(s, out, 12, string(2, ' ')); case eFeatHead: return Pad(s, out, 21); case eFeat: return Pad(s, out, 21, string(5, ' ')); default: return out; // shouldn't happen, but some compilers whine }}END_SCOPE(objects)END_NCBI_SCOPE/** ===========================================================================** $Log: flat_text_formatter.cpp,v $* Revision 1000.1 2004/06/01 19:43:34 gouriano* PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.6** Revision 1.6 2004/05/21 21:42:54 gorelenk* Added PCH ncbi_pch.hpp** Revision 1.5 2003/06/02 16:06:42 dicuccio* Rearranged src/objects/ subtree. This includes the following shifts:* - src/objects/asn2asn --> arc/app/asn2asn* - src/objects/testmedline --> src/objects/ncbimime/test* - src/objects/objmgr --> src/objmgr* - src/objects/util --> src/objmgr/util* - src/objects/alnmgr --> src/objtools/alnmgr* - src/objects/flat --> src/objtools/flat* - src/objects/validator --> src/objtools/validator* - src/objects/cddalignview --> src/objtools/cddalignview* In addition, libseq now includes six of the objects/seq... libs, and libmmdb* replaces the three libmmdb? libs.** Revision 1.4 2003/04/10 20:08:22 ucko* Arrange to pass the item as an argument to IFlatTextOStream::AddParagraph** Revision 1.3 2003/03/21 18:49:17 ucko* Turn most structs into (accessor-requiring) classes; replace some* formerly copied fields with pointers to the original data.** Revision 1.2 2003/03/11 15:37:51 kuznets* iterate -> ITERATE** Revision 1.1 2003/03/10 16:39:09 ucko* Initial check-in of new flat-file generator*** ===========================================================================*/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?