int CSeq_id_Handle::CompareOrdered(const CSeq_id_Handle& id) const { // small optimization to avoid creation of temporary CSeq_id objects if ( int diff = Which() - id.Which() ) { return diff; } if ( IsGi() && id.IsGi() ) { return GetGi() - id.GetGi(); } return GetSeqId()->CompareOrdered(*id.GetSeqId()); }
static TReadId sx_GetReadId(const CSeq_id_Handle& idh) { if ( idh.Which() != CSeq_id::e_General ) { return TReadId(); } CConstRef<CSeq_id> id = idh.GetSeqId(); const CDbtag& general = id->GetGeneral(); if ( general.GetDb() != "SRA") { return TReadId(); } return sx_GetReadId(general.GetTag().GetStr(), true); }
void CGenbankGatherer::x_DoSingleSection(CBioseqContext& ctx) const { CConstRef<IFlatItem> item; const CFlatFileConfig& cfg = ctx.Config(); // these macros make the code easier to read and less repetitive #define GATHER_BLOCK(BlockType, ItemClassName) \ if( cfg.IsShownGenbankBlock(CFlatFileConfig::fGenbankBlocks_##BlockType) ) { \ item.Reset( new ItemClassName(ctx) ); \ ItemOS() << item; \ } #define GATHER_ANCHOR(BlockType, block_str) \ if( cfg.IsShownGenbankBlock(CFlatFileConfig::fGenbankBlocks_##BlockType) ) { \ item.Reset( new CHtmlAnchorItem(ctx, (block_str) ) ); \ ItemOS() << item; \ } #define GATHER_VIA_FUNC(BlockType, FuncName) \ if( cfg.IsShownGenbankBlock(CFlatFileConfig::fGenbankBlocks_##BlockType) ) { \ FuncName(); \ } // if there's a callback, let it know we've entered another bioseq if( cfg.GetGenbankBlockCallback() ) { CFlatFileConfig::CGenbankBlockCallback::EBioseqSkip eBioseqSkip = cfg.GetGenbankBlockCallback()->notify_bioseq( ctx ); if( eBioseqSkip == CFlatFileConfig::CGenbankBlockCallback::eBioseqSkip_Yes ) { return; } } // gather needed blocks GATHER_BLOCK(Head, CStartSectionItem); GATHER_ANCHOR(Locus, "locus"); GATHER_BLOCK(Locus, CLocusItem); GATHER_BLOCK(Defline, CDeflineItem); GATHER_BLOCK(Accession, CAccessionItem); GATHER_BLOCK(Version, CVersionItem); GATHER_BLOCK(Project, CGenomeProjectItem); if ( ctx.IsProt() ) { bool show_dbsource = true; CBioseq_Handle& bsh = ctx.GetHandle(); FOR_EACH_SEQID_ON_BIOSEQ_HANDLE (sid_itr, bsh) { CSeq_id_Handle sid = *sid_itr; switch (sid.Which()) { case NCBI_SEQID(Other): { CConstRef<CSeq_id> id = sid.GetSeqId(); const CTextseq_id& tsid = *id->GetTextseq_Id (); if (tsid.IsSetAccession()) { const string& acc = tsid.GetAccession (); if (NStr::StartsWith (acc, "WP_")) { show_dbsource = false; } } break; } default: break; } }