62 unsigned int uFlags ) :
65 m_bHeaderWritten(
false)
74 unsigned int uFlags ) :
77 m_bHeaderWritten(
false)
93 const string& strAssemblyName,
94 const string& strAssemblyAccession )
120 const string& strAssemblyName,
121 const string& strAssemblyAccession )
168 for (
CAnnot_CI aci(seh, sel); aci; ++aci) {
171 for ( ; fit; ++fit ) {
173 if (currentId != lastId) {
194 const string& strAssemblyName,
195 const string& strAssemblyAccession )
213 const auto& display_range =
GetRange();
214 CFeat_CI feat_iter(bsh, display_range, sel);
231 feature::CFeatTree& featTree =
fc.FeatTree();
232 vector<CMappedFeat> vChildren;
233 featTree.GetChildrenTo(mf, vChildren);
234 for (
auto cit = vChildren.begin(); cit != vChildren.end(); ++cit) {
248 const string& strAssemblyName,
249 const string& strAssemblyAccession )
281 for (; feat_iter; ++feat_iter) {
313 const string& strAssName,
314 const string& strAssAcc )
339 m_Os <<
"##gff-version 2" <<
'\n';
349 m_Os <<
"###" <<
'\n';
355 const string& strName,
356 const string& strAccession )
359 if ( !strName.empty() ) {
360 m_Os <<
"##assembly name=" << strName <<
'\n';
362 if ( !strAccession.empty() ) {
363 m_Os <<
"##assembly accession=" << strAccession <<
'\n';
437 const vector< CRef< CGb_qual > >& quals = mf.
GetQual();
438 vector< CRef< CGb_qual > >::const_iterator it = quals.begin();
439 for ( ; it != quals.end(); ++it ) {
440 if ( !(*it)->CanGetQual() || !(*it)->CanGetVal() ) {
443 if ( (*it)->GetQual() ==
"gff_score" ) {
504 unsigned int start(0);
505 unsigned int stop(0);
590 fc.AssignShouldInheritPseudo(
true);
593 if (
fc.ShouldInheritPseudo()) {
622 display_range.
GetTo() < feat_range.
GetTo())) {
645 if (
id != 1 &&
id != 255) {
685 if (!protein_id.empty()) {
718 if ( pProtRef && pProtRef->
IsSetName() ) {
759 if (
rna.IsSetExt() &&
rna.GetExt().IsTRNA()) {
763 rna.GetExt().GetTRNA() :
764 *sequence::CFeatTrim::Apply(
rna.GetExt().GetTRNA(), display_range);
782 if (
rna.IsSetExt() &&
rna.GetExt().IsName()) {
787 if (
rna.IsSetExt() &&
rna.GetExt().IsGen() &&
788 rna.GetExt().GetGen().IsSetProduct() ) {
797 for ( CSeq_feat::TQual::const_iterator cit = quals.begin();
798 cit != quals.end(); ++cit) {
799 if ((*cit)->IsSetQual() && (*cit)->IsSetVal() &&
800 (*cit)->GetQual() ==
"product") {
824 const list<CRef<CCode_break> >& code_breaks = cds.
GetCode_break();
827 if (!display_range.
IsWhole()) {
830 CRef<CCode_break> trimmed_cb = sequence::CFeatTrim::Apply(*code_break, display_range);
839 list<CRef<CCode_break> >::const_iterator it = code_breaks.begin();
840 for (; it != code_breaks.end(); ++it) {
876 if (geneRef.IsSetLocus()) {
879 if (geneRef.IsSetLocus_tag()) {
880 record.
SetAttribute(
"locus_tag", geneRef.GetLocus_tag());
883 if (geneRef.IsSetDesc()) {
886 if (geneRef.IsSetSyn()) {
887 const auto& syns = geneRef.GetSyn();
888 auto it = syns.begin();
889 while (it != syns.end()) {
911 string old_locus_tags;
912 vector<CRef<CGb_qual> > quals = mf.
GetQual();
914 it != quals.end(); ++it) {
915 if ((**it).IsSetQual() && (**it).IsSetVal()) {
916 string qual = (**it).GetQual();
917 if (qual !=
"old_locus_tag") {
920 if (!old_locus_tags.empty()) {
921 old_locus_tags +=
",";
923 old_locus_tags += (**it).GetVal();
926 if (!old_locus_tags.empty()) {
944 if (
fc.HasSequenceBioSource() && !
fc.IsSequenceGenomicRecord()) {
1002 vector<string> experiments;
1003 const auto& quals = mf.
GetQual();
1004 for (
const auto& qual: quals) {
1005 if (qual->GetQual() ==
"experiment") {
1006 experiments.push_back(qual->GetVal());
1009 if (!experiments.empty()) {
1022 string modelEvidence;
1026 if (!modelEvidence.empty()) {
1046 if (quals.empty()) {
1049 for (CSeq_feat::TQual::const_iterator cit = quals.begin();
1050 cit != quals.end(); ++cit) {
1051 if ((*cit)->GetQual() ==
"rpt_family") {
1069 if (!pseudoGene.empty()) {
1082 if (!pseudoGene.empty()) {
1110 if (!
function.
empty()) {
1118 if (
prot.CanGetActivity() && !
prot.GetActivity().empty()) {
1132 const string& go_component = mf.
GetNamedQual(
"go_component");
1133 if (!go_component.empty()) {
1141 const auto& ext = mf.
GetExt();
1142 if (!ext.IsSetType() || !ext.GetType().IsStr()) {
1145 if (ext.GetType().GetStr() ==
"GeneOntology") {
1147 const auto& goFields = ext.
GetData();
1148 for (
const auto& goField: goFields) {
1149 if (!goField->IsSetLabel() || !goField->GetLabel().IsStr()) {
1152 const auto& goLabel = goField->GetLabel().GetStr();
1153 if (goLabel ==
"Component" && goField->IsSetData()
1154 && goField->GetData().IsFields()) {
1155 const auto& fields = goField->GetData().GetFields();
1156 vector<string> goStrings;
1163 if (goLabel ==
"Process" && goField->IsSetData()
1164 && goField->GetData().IsFields()) {
1165 const auto& fields = goField->GetData().GetFields();
1166 vector<string> goStrings;
1173 if (goLabel ==
"Function" && goField->IsSetData()
1174 && goField->GetData().IsFields()) {
1175 const auto& fields = goField->GetData().GetFields();
1176 vector<string> goStrings;
1184 if (!goIds.empty()) {
1185 record.
SetAttributes(
"Ontology_term", vector<string>(goIds.begin(), goIds.end()));
1187 }
else if (ext.GetType().GetStr() ==
"CombinedFeatureUserObjects") {
1196 if (field_label.
IsStr() && field_label.
GetStr() ==
"GeneOntology") {
1200 for (
const auto& goField: goFields) {
1201 if (!goField->IsSetLabel() || !goField->GetLabel().IsStr()) {
1204 const auto& goLabel = goField->GetLabel().GetStr();
1205 if (goLabel ==
"Component" && goField->IsSetData()
1206 && goField->GetData().IsFields()) {
1207 const auto& fields = goField->GetData().GetFields();
1208 vector<string> goStrings;
1215 if (goLabel ==
"Process" && goField->IsSetData()
1216 && goField->GetData().IsFields()) {
1217 const auto& fields = goField->GetData().GetFields();
1218 vector<string> goStrings;
1225 if (goLabel ==
"Function" && goField->IsSetData()
1226 && goField->GetData().IsFields()) {
1227 const auto& fields = goField->GetData().GetFields();
1228 vector<string> goStrings;
1236 if (!goIds.empty()) {
1237 record.
SetAttributes(
"Ontology_term", vector<string>(goIds.begin(), goIds.end()));
1258 if (
prot.CanGetEc()) {
1259 const list<string> ec =
prot.GetEc();
1262 "ec_number", vector<string>(ec.begin(), ec.end()));
1280 for ( CSeq_feat::TQual::const_iterator cit = quals.begin();
1297 static list<CSeqFeatData::ESubtype> acceptableTranscriptTypes = {
1305 auto itType = std::find(
1306 acceptableTranscriptTypes.begin(), acceptableTranscriptTypes.end(),
1308 return (itType != acceptableTranscriptTypes.end());
1355 saeh.
AddFeat(*pMissingTranscript);
1367 if (sublocs.size() == 1) {
1371 const auto&
front = *sublocs.front();
1373 auto lastStart =
front.GetFrom();
1374 for (
auto itComp = sublocs.begin()++; itComp != sublocs.end(); itComp++) {
1375 const auto& comp = **itComp;
1379 auto compStart = comp.GetFrom();
1386 lastStart = compStart;
User-defined methods of the data storage class.
@ eExtreme_Positional
numerical value
User-defined methods of the data storage class.
@Gb_qual.hpp User-defined methods of the data storage class.
static CGenbankIdResolve & Get()
virtual bool xAssignFeatureAttributeProduct(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
static bool IsTranscriptType(const CMappedFeat &)
bool xAssignFeatureAttributeIsOrdered(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
bool WriteAlign(const CSeq_align &, const string &asmblyName="", const string &asmblyAccession="") override
Write a Seq-align object.
virtual bool xAssignFeatureAttributeNote(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
virtual bool xAssignFeatureType(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
bool xAssignFeatureAttributeFunction(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
virtual bool xAssignFeatureAttributeProteinId(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
bool xAssignFeatureAttributeMapLoc(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
virtual bool xAssignFeature(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
bool WriteFooter() override
Write a trailer marking the end of a parsing context.
bool xAssignFeatureAttributeRptFamily(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
bool xAssignFeatureAttributeCodeBreak(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
bool WriteAnnot(const CSeq_annot &annot, const string &asmblyName="", const string &asmblyAccession="") override
Convenience function to render a "naked" Seq-annot.
static bool HasAccaptableTranscriptParent(CGffFeatureContext &, const CMappedFeat &)
virtual bool xAssignFeatureAttributePseudo(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
virtual bool x_WriteAssemblyInfo(const string &, const string &)
virtual bool xAssignFeatureStrand(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
virtual bool xWriteAllChildren(CGffFeatureContext &, const CMappedFeat &)
virtual bool xAssignFeatureAttributesFormatIndependent(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
virtual bool x_WriteAnnot(const CSeq_annot &)
CGff2Writer(CScope &scope, CNcbiOstream &ostr, unsigned int flags=fNormal)
Constructor.
bool WriteBioseqHandle(CBioseq_Handle bsh, const string &asmblyName="", const string &asmblyAccession="") override
Write Bioseq contained in given handle Essentially, will write all features that live on the given Bi...
virtual bool x_WriteAlign(const CSeq_align &)
virtual bool xAssignFeatureAttributeDbxref(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
virtual bool xAssignFeatureAttributeRibosomalSlippage(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
bool xAssignFeatureAttributeGeneBiotype(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
virtual bool xGeneratingMissingTranscripts() const
virtual bool xWriteFeature(CGffFeatureContext &, const CMappedFeat &)
bool xAssignFeatureAttributePseudoGene(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
virtual bool x_WriteSeqAnnotHandle(CSeq_annot_Handle)
bool xAssignFeatureAttributeEcNumbers(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
bool xAssignFeatureAttributesGoMarkup(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
virtual bool x_WriteSeqEntryHandle(CSeq_entry_Handle)
virtual bool xAssignFeatureSeqId(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
bool xAssignFeatureAttributeModelEvidence(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
virtual bool xAssignFeatureEndpoints(CGffFeatureRecord &record, CGffFeatureContext &, const CMappedFeat &mapped_feat)
virtual bool xAssignFeatureAttributePartial(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
bool WriteSeqAnnotHandle(CSeq_annot_Handle sah, const string &asmblyName="", const string &asmblyAccession="") override
Write Seq-annot contained in given handle Essentially, write out embedded feature table.
virtual bool xAssignFeatureMethod(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
virtual bool xAssignFeatureAttributesQualifiers(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
bool WriteHeader() override
Write a file header identifying the file content as GFF version 2.
virtual bool xAssignFeatureAttributes(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
virtual bool xAssignFeatureAttributesFormatSpecific(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
bool WriteSeqEntryHandle(CSeq_entry_Handle seh, const string &asmblyName="", const string &asmblyAccession="") override
Write Seq-entry contained in a given handle.
virtual bool xAssignFeatureAttributesGene(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
bool xAssignFeatureAttributeOldLocusTag(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
virtual bool xAssignFeatureAttributeTranslationTable(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
virtual bool x_WriteBioseqHandle(CBioseq_Handle)
bool xAssignFeatureAttributeExonNumber(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
bool xAssignFeatureAttributeExperiment(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
virtual bool x_WriteSequenceHeader(CBioseq_Handle)
virtual bool xAssignFeatureBasic(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
virtual bool xAssignFeatureScore(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
virtual bool xAssignFeaturePhase(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
static bool xIntervalsNeedPartNumbers(const list< CRef< CSeq_interval >> &)
CMappedFeat xGenerateMissingTranscript(CGffFeatureContext &, const CMappedFeat &)
bool xAssignFeatureAttributeException(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
void SetSeqId(const string &)
void SetLocation(unsigned int, unsigned int, ENa_strand=objects::eNa_strand_unknown)
void SetType(const string &)
void SetMethod(const string &)
void SetStrand(ENa_strand)
bool SetAttribute(const string &, const string &)
void SetScore(const CScore &)
bool SetAttributes(const string &, const vector< string > &)
bool AddAttribute(const string &, const string &)
feature::CFeatTree & FeatTree()
void SetGbKeyFrom(CMappedFeat)
void SetEndpoints(unsigned int start, unsigned int stop, ENa_strand strand)
@RNA_ref.hpp User-defined methods of the data storage class.
bool IsLegalQualifier(EQualifier qual) const
Test wheather a certain qualifier is legal for the feature.
namespace ncbi::objects::
static bool IsTransspliced(const CSeq_feat &feature)
static bool GetTrnaAntiCodon(const CTrna_ext &, string &)
static bool GetStringsForGoMarkup(const vector< CRef< CUser_field > > &fields, vector< string > &goMarkup, bool relaxed=false)
static bool IsLocationOrdered(const CSeq_loc &)
static bool GetStringForModelEvidence(CMappedFeat mf, string &mestr)
static bool GetCodeBreak(const CCode_break &, string &)
static bool GetListOfGoIds(const vector< CRef< CUser_field > > &fields, list< std::string > &goIds, bool relaxed=false)
static ENa_strand GetEffectiveStrand(const CSeq_interval &)
static bool GetTranssplicedEndpoints(const CSeq_loc &loc, unsigned int &inPoint, unsigned int &outPoint)
static bool GetTrnaCodons(const CTrna_ext &, string &)
static bool GetTrnaProductName(const CTrna_ext &, string &)
Defines and provides stubs for a general interface to a variety of file formatters.
virtual const CRange< TSeqPos > & GetRange(void) const
virtual SAnnotSelector & SetAnnotSelector(void)
static const char location[]
static const struct name_t names[]
const CGene_ref & sGetClosestGeneRef(CGffFeatureContext &fc, const CMappedFeat &mf)
const TResidue codons[4][4]
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
string GetSeqIdString(bool with_version=false) const
Return seqid string with optional version for text seqid type.
ENa_strand GetStrand(void) const
Get the location's strand.
TRange GetTotalRange(void) const
TSeqPos GetStart(ESeqLocExtremes ext) const
Return start and stop positions of the seq-loc.
const CSeq_id * GetId(void) const
Get the id of the location return NULL if has multiple ids or no id at all.
TSeqPos GetStop(ESeqLocExtremes ext) const
bool GetFeatureGeneBiotypeFaster(feature::CFeatTree &ft, CMappedFeat mf, string &biotype)
void RemoveSeq_annot(const CSeq_annot_Handle &annot)
Revoke Seq-annot previously added using AddSeq_annot().
static CRef< CObjectManager > GetInstance(void)
Return the existing object manager or create one.
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
void AddDefaults(TPriority pri=kPriority_Default)
Add default data loaders from object manager.
CSeq_annot_Handle AddSeq_annot(CSeq_annot &annot, TPriority pri=kPriority_Default, EExist action=eExist_Throw)
Add Seq-annot, return its CSeq_annot_Handle.
CBioseq_Handle GetObjectHandle(const CBioseq &bioseq, EMissing action=eMissing_Default)
const string & GetNamedQual(const CTempString &qual_name) const
Return a named qualifier.
bool IsSetExcept(void) const
bool GetExcept(void) const
bool GetPseudo(void) const
TClass GetClass(void) const
const CSeq_annot_Handle & GetAnnot(void) const
Get handle to seq-annot for this feature.
const CSeqFeatData & GetData(void) const
const CProt_ref * GetProtXref(void) const
get protein (if present) from Seq-feat.xref list
bool IsSetExcept_text(void) const
CConstRef< CSeq_annot > GetCompleteSeq_annot(void) const
Complete and return const reference to the current seq-annot.
CSeq_feat_EditHandle AddFeat(const CSeq_feat &new_obj) const
bool IsSetProduct(void) const
const CUser_object & GetExt(void) const
const string & GetExcept_text(void) const
bool IsSetClass(void) const
CSeq_annot_EditHandle GetEditHandle(void) const
Get 'edit' version of handle.
CScope & GetScope(void) const
Get scope this handle belongs to.
bool IsSetQual(void) const
CSeqFeatData::ESubtype GetFeatSubtype(void) const
CSeqFeatData::E_Choice GetFeatType(void) const
bool IsSetPseudo(void) const
const CSeq_feat::TQual & GetQual(void) const
bool IsSetExt(void) const
bool IsSetData(void) const
CSeq_id_Handle GetProductId(void) const
bool IsSetPartial(void) const
const CSeq_loc & GetLocation(void) const
bool GetPartial(void) const
bool IsMapped(void) const
Fast way to check if mapped feature is different from the original one.
const CSeq_loc & GetProduct(void) const
SAnnotSelector & SetMaxSize(TMaxSize max_size)
Set maximum number of annotations to find.
SAnnotSelector & SetSortOrder(ESortOrder sort_order)
Set sort order of annotations.
CConstRef< CSeq_feat > GetSeq_feat(void) const
Get current seq-feat.
CSeq_id_Handle GetLocationId(void) const
@ eSortOrder_Normal
default - increasing start, decreasing length
void Reset(void)
Reset reference object.
bool NotEmpty(void) const THROWS_NONE
Check if CRef is not empty – pointing to an object and has a non-null value.
bool NotEmpty(void) const
TThisType IntersectionWith(const TThisType &r) const
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
TTo GetTo(void) const
Get the To member data.
TFrom GetFrom(void) const
Get the From member data.
bool IsSetMaploc(void) const
descriptive map location Check if a value has been assigned to Maploc data member.
const TMaploc & GetMaploc(void) const
Get the Maploc member data.
bool IsStr(void) const
Check if variant Str is selected.
const TData & GetData(void) const
Get the Data member data.
const TFields & GetFields(void) const
Get the variant data.
bool IsFields(void) const
Check if variant Fields is selected.
bool IsSetLabel(void) const
field label Check if a value has been assigned to Label data member.
const TStr & GetStr(void) const
Get the variant data.
const TData & GetData(void) const
Get the Data member data.
const TLabel & GetLabel(void) const
Get the Label member data.
bool IsSetData(void) const
Check if a value has been assigned to Data data member.
vector< CRef< CUser_field > > TData
const TName & GetName(void) const
Get the Name member data.
bool IsSetName(void) const
protein name Check if a value has been assigned to Name data member.
const TVal & GetVal(void) const
Get the Val member data.
void ResetPartial(void)
Reset Partial data member.
bool IsSetCode(void) const
genetic code used Check if a value has been assigned to Code data member.
void SetLocation(TLocation &value)
Assign a value to Location data member.
bool IsCdregion(void) const
Check if variant Cdregion is selected.
bool IsSetPartial(void) const
incomplete in some way? Check if a value has been assigned to Partial data member.
void SetExcept(TExcept value)
Assign a value to Except data member.
bool IsGene(void) const
Check if variant Gene is selected.
const TCode & GetCode(void) const
Get the Code member data.
void SetData(TData &value)
Assign a value to Data data member.
const TCdregion & GetCdregion(void) const
Get the variant data.
bool IsSetQual(void) const
Check if a value has been assigned to Qual data member.
const TGene & GetGene(void) const
Get the variant data.
TPartial GetPartial(void) const
Get the Partial member data.
void SetExcept_text(const TExcept_text &value)
Assign a value to Except_text data member.
const TProt & GetProt(void) const
Get the variant data.
vector< CRef< CGb_qual > > TQual
const TQual & GetQual(void) const
Get the Qual member data.
const TRna & GetRna(void) const
Get the variant data.
const TCode_break & GetCode_break(void) const
Get the Code_break member data.
bool IsSetCode_break(void) const
individual exceptions Check if a value has been assigned to Code_break data member.
@ eClass_nuc_prot
nuc acid and coded proteins
@ eClass_genbank
converted genbank
constexpr auto front(list< Head, As... >, T=T()) noexcept -> Head
constexpr bool empty(list< Ts... >) noexcept
CConstRef< CSeq_id > GetBestId(const CBioseq &bioseq)