コード例 #1
0
ファイル: segmask.cpp プロジェクト: DmitrySigaev/ncbi
//------------------------------------------------------------------------------
CSegMasker::TMaskList*
CSegMasker::operator()(const objects::CSeqVector & data)
{
    if ( !data.IsProtein() ) {
        throw logic_error("SEG can only filter protein sequences");
    }

    if (data.GetCoding() != CSeq_data::e_Ncbistdaa ) {
        throw logic_error("SEG expects protein sequences in ncbistdaa format");
    }

    string sequence;
    BlastSeqLoc* seq_locs = NULL;
    data.GetSeqData(data.begin(), data.end(), sequence);

    Int2 status = SeqBufferSeg((Uint1*)(sequence.data()),
                               static_cast<Int4>(sequence.size()), 0,
                               m_SegParameters, &seq_locs);
    sequence.erase();
    if (status != 0) {
        seq_locs = BlastSeqLocFree(seq_locs);
        throw runtime_error("SEG internal error (check that input is protein) " + NStr::IntToString(status));
    }

    auto_ptr<TMaskList> retval(new TMaskList);
    for (BlastSeqLoc* itr = seq_locs; itr; itr = itr->next) {
        retval->push_back
            (TMaskList::value_type(itr->ssr->left, itr->ssr->right));
    }

    seq_locs = BlastSeqLocFree(seq_locs);

    return retval.release();
}
コード例 #2
0
ファイル: blast_filter.c プロジェクト: fast-project/mpifast
Int2
BlastSetUp_Filter(EBlastProgramType program_number, 
                  Uint1* sequence, 
                  Int4 length, 
                  Int4 offset, 
                  const SBlastFilterOptions* filter_options, 
                  BlastSeqLoc** seqloc_retval, 
                  Blast_Message* *blast_message)
{
	Int2 status=0;		/* return value. */

    ASSERT(filter_options);
    ASSERT(seqloc_retval);

    *seqloc_retval = NULL;

    status = SBlastFilterOptionsValidate(program_number, filter_options, 
                                         blast_message);
    if (status)
       return status;

	if (filter_options->segOptions)
	{
        SSegOptions* seg_options = filter_options->segOptions;
        SegParameters* sparamsp=NULL;

        sparamsp = SegParametersNewAa();
        sparamsp->overlaps = TRUE;
        if (seg_options->window > 0)
            sparamsp->window = seg_options->window;
        if (seg_options->locut > 0.0)
            sparamsp->locut = seg_options->locut;
        if (seg_options->hicut > 0.0)
            sparamsp->hicut = seg_options->hicut;

		status = SeqBufferSeg(sequence, length, offset, sparamsp, 
                              seqloc_retval);
		SegParametersFree(sparamsp);
		sparamsp = NULL;
	}

	return status;
}