// ---------------------------------------------------------------------------- bool CGtfReader::x_MergeFeatureLocationSingleInterval( const CGff2Record& record, CRef< CSeq_feat > pFeature ) // ---------------------------------------------------------------------------- { const CSeq_interval& gene_int = pFeature->GetLocation().GetInt(); if ( gene_int.GetFrom() > record.SeqStart() -1 ) { pFeature->SetLocation().SetInt().SetFrom( record.SeqStart() ); } if ( gene_int.GetTo() < record.SeqStop() - 1 ) { pFeature->SetLocation().SetInt().SetTo( record.SeqStop() ); } if (record.Type() == "CDS" && pFeature->GetData().IsCdregion()) { return x_FeatureTrimQualifiers(record, pFeature); } return true; }
CRef<CBioseq_set> CMakeCdrProds::MakeCdrProds(CRef<CSeq_annot> annot, CBioseq_Handle handle) { CRef<CBioseq_set> bioseq_set(new CBioseq_set); if (!annot->GetData().IsFtable()) { // Is this the right thing to do? // Could throw, or could return null CRef instead. return bioseq_set; } list<CRef<CSeq_feat> >& ftable = annot->SetData().SetFtable(); NON_CONST_ITERATE (list<CRef<CSeq_feat> >, feat, ftable) { if (!(*feat)->GetData().IsCdregion()) { // not interested if not a Cdregion continue; } if ((*feat)->IsSetProduct()) { // already has a product; don't make new one continue; } string prot; CSeqTranslator::Translate(**feat, handle.GetScope(), prot); CRef<CSeq_data> seq_data(new CSeq_data(prot, CSeq_data::e_Iupacaa)); CRef<CSeq_inst> seq_inst(new CSeq_inst); seq_inst->SetSeq_data(*seq_data); seq_inst->SetRepr(CSeq_inst_Base::eRepr_raw); seq_inst->SetMol(CSeq_inst_Base::eMol_aa); seq_inst->SetLength(prot.size()); CRef<CBioseq> bio_seq(new CBioseq); string num = NStr::NumericToString(sm_Counter.Add(1)); // pad to five digits if (num.size() < 5) { num.insert(SIZE_TYPE(0), 5 - num.size(), '0'); } string acc = "tp" + num; string full_acc = "lcl|" + acc; CRef<CSeq_id> id(new CSeq_id(full_acc)); bio_seq->SetId().push_back(id); // a title CRef<CSeqdesc> title(new CSeqdesc); title->SetTitle(string("Translation product ") + acc); bio_seq->SetDescr().Set().push_back(title); // Mol_type CRef<CSeqdesc> mol_type(new CSeqdesc); mol_type->SetMol_type( eGIBB_mol_peptide); bio_seq->SetDescr().Set().push_back(mol_type); // set the instance bio_seq->SetInst(*seq_inst); // wrap this Bio_seq in an entry CRef<CSeq_entry> seq_entry(new CSeq_entry); seq_entry->SetSeq(*bio_seq); // add this entry to our Bioseq_set bioseq_set->SetSeq_set().push_back(seq_entry); // record it as product in the annot we're handed CRef<CSeq_loc> prod_loc(new CSeq_loc); prod_loc->SetWhole(*id); (*feat)->SetProduct(*prod_loc); } return bioseq_set; }