reference_item.cpp
来自「ncbi源码」· C++ 代码 · 共 1,302 行 · 第 1/3 页
CPP
1,302 行
} else if ( NStr::StartsWith(cit, "submitted", NStr::eNocase) || NStr::StartsWith(cit, "unpublished", NStr::eNocase) ) { if ( !ctx.Config().DropBadCitGens() || !result.empty() ) { in_press = cit; } else { in_press = "Unpublished"; } } else if ( NStr::StartsWith(cit, "Online Publication", NStr::eNocase) || NStr::StartsWith(cit, "Published Only in DataBase", NStr::eNocase) ) { in_press = cit; } else if ( !ctx.Config().DropBadCitGens() && result.empty() ) { result = cit; } } if ( !result.empty() ) { SIZE_TYPE pos = result.find_first_of("=\""); if ( pos != NPOS ) { result.erase(pos); } } m_Journal = result; if ( !in_press.empty() ) { m_Journal += ' '; m_Journal += in_press; }}void CReferenceItem::x_AddImprint(const CImprint& imp, CBioseqContext& ctx){ if ( !m_Date ) { m_Date.Reset(&imp.GetDate()); } if ( imp.IsSetVolume() && !imp.GetVolume().empty() ) { m_Volume = imp.GetVolume(); if ( imp.IsSetPart_sup() && !imp.GetPart_sup().empty() ) { m_Volume += " (" + imp.GetPart_sup() + ")"; } } if ( imp.IsSetIssue() && !imp.GetIssue().empty() ) { m_Issue = imp.GetIssue(); if ( imp.IsSetPart_supi() && !imp.GetPart_supi().empty() ) { m_Issue += " (" + imp.GetPart_supi() + ")"; } } if ( imp.IsSetPages() && !imp.GetPages().empty() ) { m_Pages = imp.GetPages(); s_FixPages(m_Pages); } if ( imp.IsSetPrepub() ) { m_Prepub = imp.GetPrepub(); m_Category = m_Prepub != CImprint::ePrepub_in_press ? eUnpublished : ePublished; } else { m_Category = ePublished; }}void CReferenceItem::GetAuthNames(list<string>& authors, const CAuth_list* alp){ authors.clear(); if ( alp == 0 ) { return; } const CAuth_list::TNames& names = alp->GetNames(); switch ( names.Which() ) { case CAuth_list::TNames::e_Std: ITERATE (CAuth_list::TNames::TStd, it, names.GetStd()) { if ( !(*it)->CanGetName() ) { continue; } const CPerson_id& pid = (*it)->GetName(); string name; pid.GetLabel(&name, CPerson_id::eGenbank); authors.push_back(name); } break; case CAuth_list::TNames::e_Ml: authors.insert(authors.end(), names.GetMl().begin(), names.GetMl().end()); break; case CAuth_list::TNames::e_Str: authors.insert(authors.end(), names.GetStr().begin(), names.GetStr().end()); break; default: break; }}string CReferenceItem::GetAuthString(const CAuth_list* alp){ list<string> authors; if ( alp == 0 ) { authors.push_back("."); } else { GetAuthNames(authors, alp); } CNcbiOstrstream auth_line; list<string>::const_iterator last = --(authors.end()); string separator = kEmptyStr; bool first = true; ITERATE(list<string>, it, authors) { if ( it == last ) { separator = " and "; } auth_line << (first ? kEmptyStr : separator) << *it; separator = ", "; first = false; } return CNcbiOstrstreamToString(auth_line);}void CReferenceItem::x_CleanData(void){ // !!! // remove spaces from title etc.}///////////////////////////////////////////////////////////////////////////////// Genbank Format Specific// these must be in "ASCIIbetical" order; beware of the fact that// closing quotes sort after spaces.static const string sc_RemarkText[] = { "full automatic", "full staff_entry", "full staff_review", "simple automatic", "simple staff_entry", "simple staff_review", "unannotated automatic", "unannotated staff_entry", "unannotated staff_review"};static const CStaticArraySet<string> sc_Remarks(sc_RemarkText, sizeof(sc_RemarkText));void CReferenceItem::x_GatherRemark(CBioseqContext& ctx){ list<string> l; // comment if ( m_Pubdesc->IsSetComment() && !m_Pubdesc->GetComment().empty() ) { const string& comment = m_Pubdesc->GetComment(); if ( sc_Remarks.find(comment) == sc_Remarks.end() ) { l.push_back(comment); } } // for GBSeq format collect remarks only from comments. if ( ctx.Config().IsFormatGBSeq() ) { if ( !l.empty() ) { m_Remark = l.front(); } return; } // GIBBSQ CSeq_id::TGibbsq gibbsq = 0; ITERATE (CBioseq::TId, it, ctx.GetBioseqIds()) { if ( (*it)->IsGibbsq() ) { gibbsq = (*it)->GetGibbsq(); } } if ( gibbsq > 0 ) { static const string str1 = "GenBank staff at the National Library of Medicine created this entry [NCBI gibbsq "; static const string str2 = "] from the original journal article."; l.push_back(str1 + NStr::IntToString(gibbsq) + str2); // Figure if ( m_Pubdesc->IsSetFig() && !m_Pubdesc->GetFig().empty()) { l.push_back("This sequence comes from " + m_Pubdesc->GetFig()); } // Poly_a if ( m_Pubdesc->IsSetPoly_a() && m_Pubdesc->GetPoly_a() ) { l.push_back("Polyadenylate residues occurring in the figure were \ omitted from the sequence."); } // Maploc if ( m_Pubdesc->IsSetMaploc() && !m_Pubdesc->GetMaploc().empty()) { l.push_back("Map location: " + m_Pubdesc->GetMaploc()); } } if ( m_Pubdesc->CanGetPub() ) { ITERATE (CPubdesc::TPub::Tdata, it, m_Pubdesc->GetPub().Get()) { if ( (*it)->IsArticle() ) { if ( (*it)->GetArticle().GetFrom().IsJournal() ) { const CCit_jour& jour = (*it)->GetArticle().GetFrom().GetJournal(); if ( jour.IsSetImp() ) { const CCit_jour::TImp& imp = jour.GetImp(); if ( imp.IsSetRetract() ) { const CCitRetract& ret = imp.GetRetract(); if ( ret.IsSetType() && ret.GetType() == CCitRetract::eType_in_error && ret.IsSetExp() && !ret.GetExp().empty() ) { l.push_back("Erratum:[" + ret.GetExp() + "]"); } } } } } else if ( (*it)->IsSub() ) { const CCit_sub& sub = (*it)->GetSub(); if ( sub.IsSetDescr() && !sub.GetDescr().empty() ) { l.push_back(sub.GetDescr()); } } } } m_Remark = NStr::Join(l, "\n");}///////////////////////////////////////////////////////////////////////////////// Reference Sortingstatic size_t s_CountFields(const CDate& date){ _ASSERT(date.IsStd()); const CDate::TStd& std = date.GetStd(); size_t count = 0; if ( std.IsSetYear() ) { ++count; } if ( std.IsSetMonth() ) { ++count; } if ( std.IsSetDay() ) { ++count; } if ( std.IsSetHour() ) { ++count; } if ( std.IsSetMinute() ) { ++count; } if ( std.IsSetSecond() ) { ++count; } return count;}LessEqual::LessEqual(bool serial_first, bool is_refseq) : m_SerialFirst(serial_first), m_IsRefSeq(is_refseq){}bool LessEqual::operator()(const CRef<CReferenceItem>& ref1, const CRef<CReferenceItem>& ref2){ if ( m_SerialFirst && ref1->GetSerial() != ref2->GetSerial() ) { return ref1->GetSerial() < ref2->GetSerial(); } // sort by category (published / unpublished / submission) if ( ref1->GetCategory() != ref2->GetCategory() ) { return ref1->GetCategory() < ref2->GetCategory(); } // sort by date: // - publications with date come before those without one. // - more specific dates come before less specific ones. // - older publication comes first (except RefSeq). const CDate* d1 = ref1->GetDate(); const CDate* d2 = ref2->GetDate(); if ( (d1 != 0) && (d2 == 0) ) { return true; } else if ( (d1 == 0) && (d2 != 0) ) { return false; } if ( (d1 != 0) && (d2 != 0) ) { CDate::ECompare status = ref1->GetDate()->Compare(*ref2->GetDate()); if ( status == CDate::eCompare_unknown && d1->IsStd() && d2->IsStd() ) { // one object is more specific than the other. size_t s1 = s_CountFields(*d1); size_t s2 = s_CountFields(*d2); return m_IsRefSeq ? s1 > s2 : s1 < s2; } else if ( status != CDate::eCompare_same ) { return m_IsRefSeq ? (status == CDate::eCompare_after) : (status == CDate::eCompare_before); } } // dates are the same, or both missing. // distinguish by uids (swap order for RefSeq) if ( ref1->GetPMID() != 0 && ref2->GetPMID() != 0 && !(ref1->GetPMID() == ref2->GetPMID()) ) { return m_IsRefSeq ? (ref1->GetPMID() > ref2->GetPMID()) : (ref1->GetPMID() < ref2->GetPMID()); } if ( ref1->GetMUID() != 0 && ref2->GetMUID() != 0 && !(ref1->GetMUID() == ref2->GetMUID()) ) { return m_IsRefSeq ? (ref1->GetMUID() > ref2->GetMUID()) : (ref1->GetMUID() < ref2->GetMUID()); } // just uids goes last if ( (ref1->GetPMID() != 0 && ref2->GetPMID() != 0) || (ref1->GetMUID() != 0 && ref2->GetMUID() != 0) ) { if ( ref1->JustUids() && !ref2->JustUids() ) { return true; } else if ( !ref1->JustUids() && ref2->JustUids() ) { return false; } } if ( ref1->GetReftype() != CPubdesc::eReftype_seq ) { return true; } else if ( ref2->GetReftype() != CPubdesc::eReftype_seq ) { return false; } // next use AUTHOR string string auth1 = CReferenceItem::GetAuthString(ref1->GetAuthors()); string auth2 = CReferenceItem::GetAuthString(ref2->GetAuthors()); int comp = NStr::CompareNocase(auth1, auth2); if ( comp != 0 ) { return comp < 0; } // !!! unique string ??? if ( !m_SerialFirst ) { return ref1->GetSerial() < ref2->GetSerial(); } return true;}END_SCOPE(objects)END_NCBI_SCOPE/** ===========================================================================** $Log: reference_item.cpp,v $* Revision 1000.2 2004/06/01 19:45:23 gouriano* PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.18** Revision 1.18 2004/05/21 21:42:54 gorelenk* Added PCH ncbi_pch.hpp** Revision 1.17 2004/05/20 17:11:45 ucko* Reset strings with erase() rather than clear(), which isn't 100% portable.** Revision 1.16 2004/05/20 13:47:54 shomrat* Fixed Pub-set match** Revision 1.15 2004/05/15 13:22:45 ucko* Sort sc_RemarkText, and note the requirement.** Revision 1.14 2004/05/14 13:15:25 shomrat* Fixed use of CStaticArraySet** Revision 1.13 2004/05/06 17:59:30 shomrat* Handle duplicate references** Revision 1.12 2004/04/27 15:14:04 shomrat* Added logic for partial range formatting** Revision 1.11 2004/04/22 15:56:30 shomrat* Changes in context** Revision 1.10 2004/04/13 16:49:36 shomrat* GBSeq format changes** Revision 1.9 2004/03/26 17:26:34 shomrat* Set category to unpublished where needed** Revision 1.8 2004/03/18 15:44:21 shomrat* Fixes to REFERENCE formatting** Revision 1.7 2004/03/10 16:21:17 shomrat* Fixed reference sorting, Added REMARK gathering** Revision 1.6 2004/03/05 18:42:59 shomrat* Set category to Published if title exist** Revision 1.5 2004/02/24 17:24:27 vasilche* Added missing include <Pub.hpp>** Revision 1.4 2004/02/11 22:55:44 shomrat* use IsModeRelease method** Revision 1.3 2004/02/11 17:00:46 shomrat* minor changes to Matches method** Revision 1.2 2003/12/18 17:43:36 shomrat* context.hpp moved** Revision 1.1 2003/12/17 20:24:12 shomrat* Initial Revision (adapted from flat lib)*** ===========================================================================*/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?