flat_reference.cpp
来自「ncbi源码」· C++ 代码 · 共 711 行 · 第 1/2 页
CPP
711 行
} if (gen.IsSetSerial_number() && !m_Serial) { m_Serial = gen.GetSerial_number(); } if (gen.IsSetTitle() && m_Title.empty()) { m_Title = gen.GetTitle(); } if (gen.IsSetPmid()) { m_PMIDs.insert(gen.GetPmid()); }}void CFlatReference::x_Init(const CCit_sub& sub, const CFlatContext& /* ctx */){ m_Category = eSubmission; x_AddAuthors(sub.GetAuthors()); if (sub.GetAuthors().IsSetAffil()) { s_FormatAffil(sub.GetAuthors().GetAffil(), m_Journal); } if (sub.IsSetDate()) { m_Date = &sub.GetDate(); } else { // complain? if (sub.IsSetImp()) { m_Date = &sub.GetImp().GetDate(); } }}void CFlatReference::x_Init(const CMedline_entry& mle, const CFlatContext& ctx){ m_Category = ePublished; if (mle.IsSetUid()) { m_MUIDs.insert(mle.GetUid()); } m_Date = &mle.GetEm(); if (mle.IsSetPmid()) { m_PMIDs.insert(mle.GetPmid()); } x_Init(mle.GetCit(), ctx);}void CFlatReference::x_Init(const CCit_art& art, const CFlatContext& ctx){ if (art.IsSetTitle() && !art.GetTitle().Get().empty() ) { m_Title = art.GetTitle().GetTitle(); } if (art.IsSetAuthors()) { x_AddAuthors(art.GetAuthors()); } switch (art.GetFrom().Which()) { case CCit_art::C_From::e_Journal: x_Init(art.GetFrom().GetJournal(), ctx); break; case CCit_art::C_From::e_Book: x_Init(art.GetFrom().GetBook(), ctx); break; case CCit_art::C_From::e_Proc: x_Init(art.GetFrom().GetProc().GetBook(), ctx); break; default: break; } if (art.IsSetIds()) { ITERATE (CArticleIdSet::Tdata, it, art.GetIds().Get()) { switch ((*it)->Which()) { case CArticleId::e_Pubmed: m_PMIDs.insert((*it)->GetPubmed()); break; case CArticleId::e_Medline: m_MUIDs.insert((*it)->GetMedline()); break; default: break; } } }}void CFlatReference::x_Init(const CCit_jour& jour, const CFlatContext& ctx){ x_SetJournal(jour.GetTitle(), ctx); x_AddImprint(jour.GetImp(), ctx);}void CFlatReference::x_Init(const CCit_book& book, const CFlatContext& ctx){ // XXX -- should add more stuff to m_Journal (exactly what depends on // the format and whether this is for an article) if ( !book.GetTitle().Get().empty() ) { m_Journal = book.GetTitle().GetTitle(); } if (m_Authors.empty()) { x_AddAuthors(book.GetAuthors()); } x_AddImprint(book.GetImp(), ctx);}void CFlatReference::x_Init(const CCit_pat& pat, const CFlatContext& ctx){ m_Title = pat.GetTitle(); x_AddAuthors(pat.GetAuthors()); int seqid = 0; ITERATE (CBioseq::TId, it, ctx.GetHandle().GetBioseqCore()->GetId()) { if ((*it)->IsPatent()) { seqid = (*it)->GetPatent().GetSeqid(); } } // XXX - same for EMBL? if (pat.IsSetNumber()) { m_Category = ePublished; m_Journal = "Patent: " + pat.GetCountry() + ' ' + pat.GetNumber() + '-' + pat.GetDoc_type() + ' ' + NStr::IntToString(seqid); if (pat.IsSetDate_issue()) { ctx.GetFormatter().FormatDate(pat.GetDate_issue(), m_Journal); } m_Journal += ';'; } else { // ... }}void CFlatReference::x_Init(const CCit_let& man, const CFlatContext& ctx){ x_Init(man.GetCit(), ctx); if (man.IsSetType() && man.GetType() == CCit_let::eType_thesis) { const CImprint& imp = man.GetCit().GetImp(); m_Journal = "Thesis ("; imp.GetDate().GetDate(&m_Journal, "%Y"); m_Journal += ')'; if (imp.IsSetPrepub() && imp.GetPrepub() == CImprint::ePrepub_in_press) { m_Journal += ", In press"; } if (imp.IsSetPub()) { string affil; s_FormatAffil(imp.GetPub(), affil); replace(affil.begin(), affil.end(), '\"', '\''); m_Journal += ' ' + affil; } }}static string& s_FixMedlineName(string& s){ SIZE_TYPE space = s.find(' '); if (space) { s[space] = ','; for (SIZE_TYPE i = space + 1; i < s.size(); ++i) { if (s[i] == ' ') { break; } else if (isupper(s[i])) { s.insert(++i, 1, ','); } } } return s;}void CFlatReference::x_AddAuthors(const CAuth_list& auth){ typedef CAuth_list::C_Names TNames; const TNames& names = auth.GetNames(); switch (names.Which()) { case TNames::e_Std: ITERATE (TNames::TStd, it, names.GetStd()) { const CPerson_id& name = (*it)->GetName(); switch (name.Which()) { case CPerson_id::e_Name: { const CName_std& ns = name.GetName(); string s = ns.GetLast(); if (ns.IsSetInitials()) { s += ',' + ns.GetInitials(); } else if (ns.IsSetFirst()) { s += ',' + ns.GetFirst()[0] + '.'; if (ns.IsSetMiddle()) { s += ns.GetMiddle()[0] + '.'; } } // suffix? m_Authors.push_back(s); break; } case CPerson_id::e_Ml: { string s = name.GetMl(); m_Authors.push_back(s_FixMedlineName(s)); break; } case CPerson_id::e_Str: m_Authors.push_back(name.GetStr()); break; case CPerson_id::e_Consortium: m_Consortium = name.GetConsortium(); break; default: // complain? break; } } break; case TNames::e_Ml: ITERATE (TNames::TMl, it, names.GetMl()) { string s = *it; m_Authors.push_back(s_FixMedlineName(s)); } break; case TNames::e_Str: m_Authors.insert(m_Authors.end(), names.GetStr().begin(), names.GetStr().end()); break; default: break; }}void CFlatReference::x_SetJournal(const CTitle& title, const CFlatContext& ctx){ ITERATE (CTitle::Tdata, it, title.Get()) { if ((*it)->IsIso_jta()) { m_Journal = (*it)->GetIso_jta(); return; } } if (ctx.GetFormatter().GetMode() == IFlatFormatter::eMode_Release) { // complain } else if ( !title.Get().empty() ) { m_Journal = title.GetTitle(); }}void CFlatReference::x_AddImprint(const CImprint& imp, const CFlatContext& ctx){ if ( !m_Date ) { m_Date.Reset(&imp.GetDate()); } if (imp.IsSetVolume()) { // add part-sup? m_Volume = imp.GetVolume(); } if (imp.IsSetIssue()) { // add part-supi? m_Issue = imp.GetIssue(); } if (imp.IsSetPages()) { m_Pages = imp.GetPages(); // Restore redundant leading digits of the second number if needed SIZE_TYPE digits1 = m_Pages.find_first_not_of("0123456789"); if (digits1 != 0) { SIZE_TYPE hyphen = m_Pages.find('-', digits1); if (hyphen != NPOS) { SIZE_TYPE digits2 = m_Pages.find_first_not_of("0123456789", hyphen + 1); digits2 -= hyphen + 1; if (digits2 < digits1) { // lengths of the tail portions SIZE_TYPE len1 = hyphen + digits2 - digits1; SIZE_TYPE len2 = m_Pages.size() - hyphen - 1; int x = NStr::strncasecmp(&m_Pages[digits1 - digits2], &m_Pages[hyphen + 1], min(len1, len2)); if (x > 0 || (x == 0 && len1 >= len2)) { // complain? } else { m_Pages.insert(hyphen + 1, m_Pages, 0, digits1 - digits2); } } } } } if (imp.IsSetPrepub() && imp.GetPrepub() != CImprint::ePrepub_in_press) { m_Category = eUnpublished; } else { m_Category = ePublished; }}END_SCOPE(objects)END_NCBI_SCOPE/** ===========================================================================** $Log: flat_reference.cpp,v $* Revision 1000.2 2004/06/01 19:43:28 gouriano* PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.11** Revision 1.11 2004/05/21 21:42:53 gorelenk* Added PCH ncbi_pch.hpp** Revision 1.10 2003/12/02 19:22:17 ucko* Properly detect unpublished references, and give them a pseudo-journal* of Unpublished.** Revision 1.9 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.8 2003/04/24 16:15:58 vasilche* Added missing includes and forward class declarations.** Revision 1.7 2003/04/09 20:03:11 ucko* Fix unsafe assumptions in CFlatReference::Matches.** Revision 1.6 2003/03/28 17:46:21 dicuccio* Added missing include for CAnnotObject_Info because MSVC gets confused* otherwise....** Revision 1.5 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.4 2003/03/11 15:37:51 kuznets* iterate -> ITERATE** Revision 1.3 2003/03/10 22:06:04 ucko* Explicitly call NotEmpty to avoid a bogus MSVC error.* Fix a typo that interpreted some MUIDs as PMIDs.** Revision 1.2 2003/03/10 20:18:16 ucko* Fix broken call to string::insert (caught by Compaq's compiler).** 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 + -
显示快捷键?