CRef<CBioseq> CBlastBioseqMaker:: CreateBioseqFromId(CConstRef<CSeq_id> id, bool retrieve_seq_data) { _ASSERT(m_scope.NotEmpty()); // N.B.: this call fetches the Bioseq into the scope from its // data sources (should be BLAST DB first, then Genbank) TSeqPos len = sequence::GetLength(*id, m_scope); if (len == numeric_limits<TSeqPos>::max()) { NCBI_THROW(CInputException, eSeqIdNotFound, "Sequence ID not found: '" + id->AsFastaString() + "'"); } CBioseq_Handle bh = m_scope->GetBioseqHandle(*id); CRef<CBioseq> retval; if (retrieve_seq_data) { retval.Reset(const_cast<CBioseq*>(&*bh.GetCompleteBioseq())); } else { retval.Reset(new CBioseq()); CRef<CSeq_id> idToStore(new CSeq_id); idToStore->Assign(*id); retval->SetId().push_back(idToStore); retval->SetInst().SetRepr(CSeq_inst::eRepr_raw); retval->SetInst().SetMol(bh.IsProtein() ? CSeq_inst::eMol_aa : CSeq_inst::eMol_dna); retval->SetInst().SetLength(len); } return retval; }
/// Performs sanity checks to make sure that the sequence requested is of /// the expected type. If the tests fail, an exception is thrown. /// @param id Sequence id for this sequence [in] void x_ValidateMoleculeType(CConstRef<CSeq_id> id) { _ASSERT(m_BioseqMaker.NotEmpty()); if (id.Empty()) { NCBI_THROW(CInputException, eInvalidInput, "Empty SeqID passed to the molecule type validation"); } bool isProtein = m_BioseqMaker->IsProtein(id); if (!isProtein && m_ReadProteins) { NCBI_THROW(CInputException, eSequenceMismatch, "GI/accession/sequence mismatch: protein input required but nucleotide provided"); } if (isProtein && !m_ReadProteins) { NCBI_THROW(CInputException, eSequenceMismatch, "GI/accession/sequence mismatch: nucleotide input required but protein provided"); } if (!isProtein) // Never seen a virtual protein sequence. { if (m_BioseqMaker->HasSequence(id) == false) { string message = "No sequence available for " + id->AsFastaString(); NCBI_THROW(CInputException, eInvalidInput, message); } } }
bool CBlastBioseqMaker::IsProtein(CConstRef<CSeq_id> id) { _ASSERT(m_scope.NotEmpty()); CBioseq_Handle bh = m_scope->GetBioseqHandle(*id); if (!bh) { NCBI_THROW(CInputException, eSeqIdNotFound, "Sequence ID not found: '" + id->AsFastaString() + "'"); } return bh.IsProtein(); }