locus_item.cpp

来自「ncbi源码」· C++ 代码 · 共 573 行 · 第 1/2 页

CPP
573
字号
         (ctx.IsDelta()  &&  !ctx.IsDeltaLitOnly()) ) {        m_Division = "CON";        return;    }    const CBioseq_Handle& bsh = ctx.GetHandle();    const CBioSource* bsrc = 0;    // Find the BioSource object for this sequnece.    CSeqdesc_CI src_desc(bsh, CSeqdesc::e_Source);    if ( src_desc ) {        bsrc = &(src_desc->GetSource());    } else {        CFeat_CI feat(bsh, 0, 0, CSeqFeatData::e_Biosrc);        if ( feat ) {            bsrc = &(feat->GetData().GetBiosrc());        } else if ( ctx.IsProt() ) {            // if protein with no sources, get sources applicable to             // DNA location of CDS            const CSeq_feat* cds = GetCDSForProduct(bsh);            if ( cds ) {                CConstRef<CSeq_feat> nuc_fsrc = GetBestOverlappingFeat(                    cds->GetLocation(),                    CSeqFeatData::e_Biosrc,                    eOverlap_Contains,                    bsh.GetScope());                if ( nuc_fsrc ) {                    bsrc = &(nuc_fsrc->GetData().GetBiosrc());                } else {                    CBioseq_Handle nuc =                         bsh.GetScope().GetBioseqHandle(cds->GetLocation());                    CSeqdesc_CI nuc_dsrc(nuc, CSeqdesc::e_Source);                    if ( nuc_dsrc ) {                        bsrc = &(nuc_dsrc->GetSource());                    }                }            }        }    }    bool is_transgenic = false;    if ( bsrc ) {        CBioSource::TOrigin origin = bsrc->GetOrigin();        if ( bsrc->CanGetOrg() ) {            const COrg_ref& org = bsrc->GetOrg();            if ( org.CanGetOrgname()  &&  org.GetOrgname().CanGetDiv() ) {                m_Division = org.GetOrgname().GetDiv();            }        }        ITERATE(CBioSource::TSubtype, subsource, bsrc->GetSubtype() ) {            if ( (*subsource)->CanGetSubtype()  &&                (*subsource)->GetSubtype() == CSubSource::eSubtype_transgenic ) {                is_transgenic = true;            }        }                switch ( ctx.GetTech() ) {        case CMolInfo::eTech_est:            m_Division = "EST";            break;        case CMolInfo::eTech_sts:            m_Division = "STS";            break;        case CMolInfo::eTech_survey:            m_Division = "GSS";            break;        case CMolInfo::eTech_htgs_0:        case CMolInfo::eTech_htgs_1:        case CMolInfo::eTech_htgs_2:            m_Division = "HTG";            break;        case CMolInfo::eTech_htc:            m_Division = "HTC";            break;        default:            break;        }        if ( origin == CBioSource::eOrigin_synthetic  ||  is_transgenic ) {            m_Division = "SYN";        }        ITERATE( CBioseq::TId, id, bsh.GetBioseqCore()->GetId() ) {            if ( (*id)->IdentifyAccession() == CSeq_id::eAcc_patent ) {                m_Division = "PAT";                break;            }        }        // more complicated code for division, if necessary, goes here                for ( CSeqdesc_CI gb_desc(bsh, CSeqdesc::e_Genbank); gb_desc; ++gb_desc ) {            const CGB_block& gb = gb_desc->GetGenbank();            if ( gb.CanGetDiv() ) {                if ( m_Division.empty()    ||                     gb.GetDiv() == "SYN"  ||                     gb.GetDiv() == "PAT" ) {                    m_Division = gb.GetDiv();                }            }        }        const CMolInfo* molinfo = dynamic_cast<const CMolInfo*>(GetObject());        if ( ctx.Config().IsFormatEMBL() ) {            for ( CSeqdesc_CI embl_desc(bsh, CSeqdesc::e_Embl);                   embl_desc;                   ++embl_desc ) {                const CEMBL_block& embl = embl_desc->GetEmbl();                if ( embl.CanGetDiv() ) {                    if ( embl.GetDiv() == CEMBL_block::eDiv_other  &&                         molinfo == 0 ) {                        m_Division = "HUM";                    } else {                        m_Division = embl.GetDiv();                    }                }            }        }    }    // Set a default value (3 spaces)    if ( m_Division.empty() ) {        m_Division = "   ";    }}// Datevoid CLocusItem::x_SetDate(CBioseqContext& ctx){    const CBioseq_Handle& bsh = ctx.GetHandle();    const CDate* date = x_GetDateForBioseq(bsh);    if ( date == 0 ) {        // if bioseq is product of CDS or mRNA feature, get         // date from parent bioseq.        CBioseq_Handle parent = GetNucleotideParent(bsh);        if ( parent ) {            date = x_GetDateForBioseq(parent);        }    }    if ( date ) {        m_Date.erase();        DateToString(*date, m_Date);    }}const CDate* CLocusItem::x_GetDateForBioseq(const CBioseq_Handle& bsh) const{    const CDate* result = 0;    {{        CSeqdesc_CI desc(bsh, CSeqdesc::e_Update_date);        if ( desc ) {            result = &(desc->GetUpdate_date());        }    }}    {{        // temporarily (???) also look at genbank block entry date         CSeqdesc_CI desc(bsh, CSeqdesc::e_Genbank);        if ( desc ) {            const CGB_block& gb = desc->GetGenbank();            if ( gb.CanGetEntry_date() ) {                result = x_GetLaterDate(result, &gb.GetEntry_date());            }        }    }}    {{        CSeqdesc_CI desc(bsh, CSeqdesc::e_Embl);        if ( desc ) {            const CEMBL_block& embl = desc->GetEmbl();            if ( embl.CanGetCreation_date() ) {                result = x_GetLaterDate(result, &embl.GetCreation_date());            }            if ( embl.CanGetUpdate_date() ) {                result = x_GetLaterDate(result, &embl.GetUpdate_date());            }        }    }}    {{        CSeqdesc_CI desc(bsh, CSeqdesc::e_Sp);        if ( desc ) {            const CSP_block& sp = desc->GetSp();            if ( sp.CanGetCreated()  &&  sp.GetCreated().IsStd() ) {                result = x_GetLaterDate(result, &sp.GetCreated());            }            if ( sp.CanGetSequpd()  &&  sp.GetSequpd().IsStd() ) {                result = x_GetLaterDate(result, &sp.GetSequpd());            }            if ( sp.CanGetAnnotupd()  &&  sp.GetAnnotupd().IsStd() ) {                result = x_GetLaterDate(result, &sp.GetAnnotupd());            }        }    }}    {{        CSeqdesc_CI desc(bsh, CSeqdesc::e_Pdb);        if ( desc ) {            const CPDB_block& pdb = desc->GetPdb();            if ( pdb.CanGetDeposition()  &&  pdb.GetDeposition().IsStd() ) {                result = x_GetLaterDate(result, &pdb.GetDeposition());            }            if ( pdb.CanGetReplace() ) {                const CPDB_replace& replace = pdb.GetReplace();                if ( replace.CanGetDate()  &&   replace.GetDate().IsStd() ) {                    result = x_GetLaterDate(result, &replace.GetDate());                }            }        }    }}    {{        CSeqdesc_CI desc(bsh, CSeqdesc::e_Create_date);        if ( desc ) {            result = x_GetLaterDate(result, &(desc->GetCreate_date()));        }    }}    return result;}const CDate* CLocusItem::x_GetLaterDate(const CDate* d1, const CDate* d2) const{    if ( d1 == 0 ) {        return d2;    }    if ( d2 == 0 ) {        return d1;    }    return (d1->Compare(*d2) == CDate::eCompare_after) ? d1 : d2;}END_SCOPE(objects)END_NCBI_SCOPE/** ===========================================================================** $Log: locus_item.cpp,v $* Revision 1000.2  2004/06/01 19:45:04  gouriano* PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.9** Revision 1.9  2004/05/21 21:42:54  gorelenk* Added PCH ncbi_pch.hpp** Revision 1.8  2004/04/22 15:58:51  shomrat* Changes in context** Revision 1.7  2004/04/13 16:49:01  shomrat* GBSeq format changes** Revision 1.6  2004/03/25 20:45:05  shomrat* Use handles** Revision 1.5  2004/03/05 18:41:14  shomrat* bug fix** Revision 1.4  2004/02/13 14:23:08  shomrat* force CON division for contig style and genome view** Revision 1.3  2004/02/11 22:55:12  shomrat* use IsFormatEMBL method** Revision 1.2  2003/12/18 17:43:35  shomrat* context.hpp moved** Revision 1.1  2003/12/17 20:23:35  shomrat* Initial Revision (adapted from flat lib)*** ===========================================================================*/

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?