// ---------------------------------------------------------------------------- bool CGffRecord::AssignType( const CSeq_feat& feature ) // ---------------------------------------------------------------------------- { m_strType = "region"; if ( feature.CanGetQual() ) { const vector< CRef< CGb_qual > >& quals = feature.GetQual(); vector< CRef< CGb_qual > >::const_iterator it = quals.begin(); while ( it != quals.end() ) { if ( (*it)->CanGetQual() && (*it)->CanGetVal() ) { if ( (*it)->GetQual() == "standard_name" ) { m_strType = (*it)->GetVal(); return true; } } ++it; } } if ( ! feature.CanGetData() ) { return true; } switch ( feature.GetData().GetSubtype() ) { default: m_strType = feature.GetData().GetKey(); break; case CSeq_feat::TData::eSubtype_gene: m_strType = "gene"; break; case CSeq_feat::TData::eSubtype_cdregion: m_strType = "CDS"; break; case CSeq_feat::TData::eSubtype_mRNA: m_strType = "mRNA"; break; case CSeq_feat::TData::eSubtype_scRNA: m_strType = "scRNA"; break; case CSeq_feat::TData::eSubtype_exon: m_strType = "exon"; break; } return true; }
// ---------------------------------------------------------------------------- bool CGffRecord::AssignScore( const CSeq_feat& feature ) // ---------------------------------------------------------------------------- { m_strScore = "."; if ( feature.CanGetQual() ) { const vector< CRef< CGb_qual > >& quals = feature.GetQual(); vector< CRef< CGb_qual > >::const_iterator it = quals.begin(); while ( it != quals.end() ) { if ( (*it)->CanGetQual() && (*it)->CanGetVal() ) { if ( (*it)->GetQual() == "score" ) { m_strScore = (*it)->GetVal(); return true; } } ++it; } } return true; }
// ---------------------------------------------------------------------------- bool CGffRecord::AssignAttributesCore( const CSeq_annot& annot, const CSeq_feat& feature ) // ---------------------------------------------------------------------------- { m_strAttributes = ""; // If feature ids are present then they are likely used to show parent/child // relationships, via corresponding xrefs. Thus, any feature ids override // gb ID tags (feature ids and ID tags should agree in the first place, but // if not, feature ids must trump ID tags). // bool bIdAssigned = false; if ( feature.CanGetId() ) { const CSeq_feat::TId& id = feature.GetId(); string value = CGffRecord::FeatIdString( id ); AddAttribute( "ID", value ); bIdAssigned = true; } if ( feature.CanGetXref() ) { const CSeq_feat::TXref& xref = feature.GetXref(); string value; for ( size_t i=0; i < xref.size(); ++i ) { // const CSeqFeatXref& ref = *xref[i]; if ( xref[i]->CanGetId() && xref[i]->CanGetData() ) { const CSeqFeatXref::TId& id = xref[i]->GetId(); CSeq_feat::TData::ESubtype other_type = GetSubtypeOf( annot, id ); if ( ! IsParentOf( other_type, feature.GetData().GetSubtype() ) ) { continue; } if ( ! value.empty() ) { value += ","; } value += CGffRecord::FeatIdString( id ); } } if ( ! value.empty() ) { AddAttribute( "Parent", value ); } } if ( feature.CanGetQual() ) { const vector< CRef< CGb_qual > >& quals = feature.GetQual(); vector< CRef< CGb_qual > >::const_iterator it = quals.begin(); while ( it != quals.end() ) { if ( (*it)->CanGetQual() && (*it)->CanGetVal() ) { if ( (*it)->GetQual() == "ID" ) { if ( ! bIdAssigned ) { AddAttribute( "ID", (*it)->GetVal() ); } } if ( (*it)->GetQual() == "Name" ) { AddAttribute( "Name", (*it)->GetVal() ); } if ( (*it)->GetQual() == "Var_type" ) { AddAttribute( "Var_type", (*it)->GetVal() ); } } ++it; } } return true; }