uFlags ) :
85 unsigned intuFlags ) :
104 const auto& display_range =
GetRange();
105 CFeat_CIfeat_iter(bsh, display_range, sel);
108vector<CMappedFeat> vRoots = fc.
FeatTree().GetRootFeatures();
110 for(
autopit = vRoots.begin(); pit != vRoots.end(); ++pit) {
127 m_Os<<
"#gtf-version 2.2"<<
'\n';
167 "Processing terminated by user");
210list<CRef<CGtfRecord>> records;
215 for(
const auto& record: records) {
227 const string& transcriptIdPreAssigned)
230 stringtranscriptId(transcriptIdPreAssigned);
239tf =
context.FeatTree().GetParent(mf);
244transcriptId = featIt->second;
247list<CRef<CGtfRecord>> records;
252 for(
const auto& record: records) {
264 const string& transcriptIdPreAssigned )
267 stringtranscriptId(transcriptIdPreAssigned);
269list<CRef<CGtfRecord>> records;
273 for(
const auto& record: records) {
293 boolneedsPartNumbers = (sublocs.size() > 1);
294 unsigned intpartNum = 1;
295 for(
autoit = sublocs.begin(); it != sublocs.end(); it++ ) {
303pRecord->SetEndpoints(intv.
GetFrom(), intv.
GetTo(), strand);
304 if(needsPartNumbers) {
305pRecord->SetPartNumber(partNum++);
307recordList.push_back(pRecord);
318 const string& transcriptId)
327 if(!transcriptId.empty()) {
328pRecord->SetTranscriptId(transcriptId);
340mfLocAsPackedInt.
Assign(mfLoc);
346 if(isTransSpliced) {
347 autornaStart = sublocs.front()->GetFrom();
348 autornaStop = sublocs.front()->GetTo();
349 for(
const auto& loc : sublocs) {
350 autostart = loc->GetFrom();
351 if(start < rnaStart) {
354 autostop = loc->GetTo();
355 if(stop > rnaStop) {
359pRecord->SetEndpoints(rnaStart, rnaStop, mfStrand);
362 TSeqPoslastFrom = sublocs.front()->GetFrom();
363 TSeqPoslastTo = sublocs.front()->GetTo();
364 autoit = sublocs.begin();
365 booliterationDone(
false);
366 for( it++; it != sublocs.end() && !iterationDone; it++ ) {
371 if(intv.
GetTo() <= lastFrom) {
375pRecord->SetEndpoints(lastFrom, lastTo, mfLoc.GetStrand());
376recordList.push_back(pRecord);
378 if(!transcriptId.empty()) {
379pRecord->SetTranscriptId(transcriptId);
385lastTo = intv.
GetTo();
393iterationDone =
true;
398 if(intv.
GetFrom() >= lastTo) {
399lastTo = intv.
GetTo();
402pRecord->SetEndpoints(lastFrom, lastTo, mfLoc.GetStrand());
403recordList.push_back(pRecord);
405 if(!transcriptId.empty()) {
406pRecord->SetTranscriptId(transcriptId);
412lastTo = intv.
GetTo();
418pRecord->SetEndpoints(lastFrom, lastTo, mfLoc.GetStrand());
420recordList.push_back(pRecord);
422 boolneedPartNumbers = (recordList.size() > 1);
423 unsigned intpartNum = 1;
424 for(
auto& record: recordList) {
425 if(needPartNumbers) {
426record->SetPartNumber(partNum++);
428record->SetType(
"transcript");
429record->SetGbKeyFrom(mf);
439 const string& parentTranscriptId)
442 stringtranscriptId(parentTranscriptId);
447mfLocAsPackedInt.
Assign(mfLoc);
455 if(cdsFeat.GetData().GetCdregion().IsSetFrame()) {
456phase =
max(cdsFeat.GetData().GetCdregion().GetFrame()-1, 0);
459 unsigned intpartNum = 1;
460 for(
autopInterval : sublocs) {
468pRecord->SetEndpoints(intv.
GetFrom(), intv.
GetTo(), strand);
469 if(needsPartNumbers) {
472 if(!transcriptId.empty()) {
473pRecord->SetTranscriptId(transcriptId);
476transcriptId = pRecord->TranscriptId();
478pRecord->SetCdsPhase(phase);
479recordList.push_back(pRecord);
480phase = (3 - ((intv.
GetLength()+3 - phase)%3))%3;
484 unsigned intbasesToLose = 3;
485 while(basesToLose > 0 && !recordList.empty()) {
486 autopLastRecord = recordList.back();
487 autolastSize = pLastRecord->SeqStop() - pLastRecord->SeqStart() + 1;
488 autolastStrand = pLastRecord->SeqStrand();
489 if(lastSize > basesToLose) {
491pLastRecord->SetEndpoints(
492pLastRecord->SeqStart() + basesToLose, pLastRecord->SeqStop(), lastStrand);
495pLastRecord->SetEndpoints(
496pLastRecord->SeqStart(), pLastRecord->SeqStop() - basesToLose, lastStrand);
501recordList.erase(--recordList.end());
502basesToLose -= lastSize;
508 intbasePairsNeeded = 3;
509 autocurrentIt = sublocs.begin();
510 unsigned intpartNumber = 1;
511 unsigned intbaseCount = 0;
513 while(basePairsNeeded > 0 && currentIt != sublocs.end()) {
515 autocurrentFrom = currentLoc.
GetFrom();
516 autocurrentTo = currentLoc.
GetTo();
524pRecord->SetType(
"start_codon");
526 if(currentTo >= currentFrom + basePairsNeeded -1) {
528pRecord->SetEndpoints(currentTo - basePairsNeeded + 1, currentTo, currentStrand);
531pRecord->SetEndpoints(currentFrom, currentFrom + basePairsNeeded -1, currentStrand);
536pRecord->SetEndpoints(currentFrom, currentTo, currentStrand);
537basePairsNeeded = basePairsNeeded - (currentTo - currentFrom + 1);
540 if(partNumber > 1 || basePairsNeeded > 0) {
541pRecord->SetPartNumber(partNumber++);
543 if(!transcriptId.empty()) {
544pRecord->SetTranscriptId(transcriptId);
547pRecord->SetCdsPhase((3-baseCount)%3);
548baseCount += pRecord->GetExtent();
549recordList.push_back(pRecord);
556list<CRef<CGtfRecord>> stopCodonParts;
557 intbasePairsNeeded = 3;
558 autocurrentIt = sublocs.rbegin();
559 while(basePairsNeeded > 0 && currentIt != sublocs.rend()) {
561 autocurrentFrom = currentLoc.
GetFrom();
562 autocurrentTo = currentLoc.
GetTo();
570pRecord->SetType(
"stop_codon");
572 if(currentTo >= currentFrom + basePairsNeeded - 1) {
574pRecord->SetEndpoints(currentFrom, currentFrom + basePairsNeeded - 1, currentStrand);
577pRecord->SetEndpoints(currentTo - basePairsNeeded + 1, currentTo, currentStrand);
582pRecord->SetEndpoints(currentFrom, currentTo, currentStrand);
583basePairsNeeded = basePairsNeeded - (currentTo - currentFrom + 1);
586 if(!transcriptId.empty()) {
587pRecord->SetTranscriptId(transcriptId);
589stopCodonParts.push_front(pRecord);
592 unsigned intpartNumber = 1;
593 boolneedPartNumbers = (stopCodonParts.size() > 1);
594 unsigned intbaseCount = 0;
595 for(
auto& pRecord: stopCodonParts) {
596 if(needPartNumbers) {
597pRecord->SetPartNumber(partNumber++);
600pRecord->SetCdsPhase((3-baseCount)%3);
601baseCount += pRecord->GetExtent();
602recordList.push_back(pRecord);
609 for(
auto& pRecord: recordList) {
621 const string& transcriptId)
625 if(!transcriptId.empty()) {
626pMrna->SetTranscriptId(transcriptId);
631pMrna->CorrectType(
"exon");
634 unsigned intuExonNumber = 1;
637pLocMrna->
Add( loc );
643 constlist<CRef<CSeq_interval>>& sublocs = pLocMrna->
GetPacked_int().
Get();
644 for(
autoit = sublocs.begin(); it != sublocs.end(); ++it) {
648pExon->MakeChildRecord(*pMrna, subint, uExonNumber++);
649pExon->DropAttributes(
"gbkey");
665 const auto& quals = mf.
GetQual();
666 autoit = quals.begin();
667 for( ; it != quals.end(); ++it) {
668 if(!(*it)->CanGetQual() || !(*it)->CanGetVal()) {
671 if((*it)->GetQual() ==
"standard_name") {
672record.
SetType((*it)->GetVal());
687record.
SetType(
"transcript");
713 const auto& quals = mf.
GetQual();
714 autoit = quals.begin();
715 for(; it != quals.end(); ++it) {
716 if(!(*it)->CanGetQual() || !(*it)->CanGetVal()) {
719 if((*it)->GetQual() ==
"gff_source") {
728mf.
GetExt(),
"ModelEvidence");
729 if(model_evidence) {
731 if(model_evidence->
HasField(
"Method") ) {
741mf.
GetExts(),
"ModelEvidence");
742 if(model_evidence) {
744 if(model_evidence->
HasField(
"Method")) {
756 if(!typeFromId.empty()) {
783 constvector<string> specialCases = {
793 for(
autoqual: quals) {
794 if(!qual->IsSetQual() || !qual->IsSetVal()) {
797 autospecialCase = std::find(
798specialCases.begin(), specialCases.end(), qual->GetQual());
799 if(specialCase != specialCases.end()) {
840 returnfeatIt->second;
843 autoparent =
context.FeatTree().GetParent(mf);
846 returnfeatIt->second;
849 autochildren =
context.FeatTree().GetChildren(mf);
850 for(
autochild : children) {
853 returnfeatIt->second;
877 staticlist<CSeqFeatData::ESubtype> nonRnaTranscripts = {
888nonRnaTranscripts.begin(), nonRnaTranscripts.end(), featSubtype);
889 if(it == nonRnaTranscripts.end()) {
922 switch(featSubtype) {
965 if(featId.empty()) {
969 if(featId.empty()) {
986 unsigned intsuffix = 1;
1009 if(!record.
GeneId().empty()) {
1017 const auto& geneIdQual = mf.
GetNamedQual(
"gene_id");
1018 if(!geneIdQual.empty()) {
1037 if(geneId.empty() && geneRef.IsSetLocus_tag()) {
1038geneId = geneRef.GetLocus_tag();
1040 if(geneId.empty() && geneRef.IsSetLocus()) {
1041geneId = geneRef.GetLocus();
1043 if(geneId.empty() && geneRef.IsSetSyn() ) {
1044geneId = geneRef.GetSyn().front();
1046 if(geneId.empty()) {
1064 unsigned intsuffix = 1;
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
@ eExtreme_Biological
5' and 3'
User-defined methods of the data storage class.
bool CdsNeedsExonNumbers() const
void AssignExonNumberTo(CGtfRecord >fRecord) const
CWriterBase implementation that formats Genbank objects as plain GFF files.
virtual bool xAssignFeatureAttributeDbxref(CGffFeatureRecord &, CGffFeatureContext &, const string &label, const CMappedFeat &)
virtual bool xAssignFeature(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
static bool HasAccaptableTranscriptParent(CGffFeatureContext &, const CMappedFeat &)
virtual bool xWriteAllChildren(CGffFeatureContext &, const CMappedFeat &)
static bool xIntervalsNeedPartNumbers(const list< CRef< CSeq_interval >> &)
CMappedFeat xGenerateMissingTranscript(CGffFeatureContext &, const CMappedFeat &)
virtual string StrType() const
virtual string StrSeqStop() const
virtual string StrAttributes() const
virtual string StrScore() const
void SetType(const string &)
virtual string StrPhase() const
void SetMethod(const string &)
bool SetAttribute(const string &, const string &)
virtual string StrSeqStart() const
virtual string StrSeqId() const
bool AddAttribute(const string &, const string &)
virtual string StrStrand() const
virtual string StrMethod() const
void AssignShouldInheritPseudo(bool shouldInheritPseudo)
feature::CFeatTree & FeatTree()
virtual string StrStructibutes() const
string NextId(const string prefix)
void SetGeneId(const std::string &geneId)
string TranscriptId() const
void SetTranscriptId(const std::string &transcriptId)
virtual bool xAssignFeatureAttributeTranscriptId(CGtfRecord &, CGffFeatureContext &, const CMappedFeat &)
map< CMappedFeat, string > mMapFeatToGeneId
virtual bool xAssignFeaturesGene(list< CRef< CGtfRecord >> &, CGffFeatureContext &, const CMappedFeat &)
bool xAssignFeatureMethod(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &) override
virtual bool xWriteRecordsGene(CGffFeatureContext &, const CMappedFeat &)
CGtfIdGenerator mIdGenerator
bool xWriteRecord(const CGffWriteRecord *)
virtual bool xAssignFeaturesCds(list< CRef< CGtfRecord >> &, CGffFeatureContext &, const CMappedFeat &, const string &="")
virtual bool xAssignFeatureAttributeTranscriptBiotype(CGtfRecord &, CGffFeatureContext &, const CMappedFeat &)
bool xAssignFeatureAttributeNote(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &) override
bool xWriteFeature(CGffFeatureContext &, const CMappedFeat &) override
bool x_WriteBioseqHandle(CBioseq_Handle) override
bool xAssignFeatureAttributesFormatSpecific(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &) override
virtual bool xWriteRecordsTranscript(CGffFeatureContext &, const CMappedFeat &, const string &="")
std::string xGenericTranscriptId(const CMappedFeat &)
bool WriteHeader() override
Write a file header identifying the file content as GFF version 2.
CGtfWriter(CScope &, CNcbiOstream &, unsigned int=0)
bool xAssignFeatureAttributesQualifiers(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &) override
bool xAssignFeatureAttributeDbxref(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &) override
virtual bool xWriteRecordsCds(CGffFeatureContext &, const CMappedFeat &, const string &="")
virtual bool xAssignFeatureAttributeGeneId(CGtfRecord &, CGffFeatureContext &, const CMappedFeat &)
bool xAssignFeatureType(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &) override
virtual bool xWriteFeatureExons(CGffFeatureContext &, const CMappedFeat &, const string &="")
std::string xGenericGeneId(const CMappedFeat &, CGffFeatureContext &)
virtual bool xAssignFeaturesTranscript(list< CRef< CGtfRecord >> &, CGffFeatureContext &, const CMappedFeat &, const string &)
TSeqPos GetLength(void) const
static bool FeatureToSoType(const CSeq_feat &, string &)
bool HasField(const string &str, const string &delim=".", NStr::ECase use_case=NStr::eCase) const
Verify that a named field exists.
const CUser_field & GetField(const string &str, const string &delim=".", NStr::ECase use_case=NStr::eCase) const
Access a named field in this user object.
static bool CompareFeatures(const CMappedFeat &lhs, const CMappedFeat &rhs)
static CConstRef< CUser_object > GetUserObjectByType(const CUser_object &uo, const string &strType)
static bool GetIdType(CBioseq_Handle, string &)
virtual const CRange< TSeqPos > & GetRange(void) const
bool GetBestId(CSeq_id_Handle idh, CScope &scope, string &best_id) const
virtual SAnnotSelector & SetAnnotSelector(void)
const_iterator end() const
const_iterator find(const key_type &key) const
const_iterator begin() const
const_iterator find(const key_type &key) const
const_iterator end() const
unsigned int TSeqPos
Type for sequence locations and lengths.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
void ChangeToPackedInt(void)
Works only if location is currently an interval, point, packed-int (handled trivially),...
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Override Assign() to incorporate cache invalidation.
void Add(const CSeq_loc &other)
Simple adding of seq-locs.
bool IsSetStrand(EIsSetStrand flag=eIsSetStrand_Any) const
Check if strand is set for any/all part(s) of the seq-loc depending on the flag.
CMappedFeat GetBestGeneForFeat(const CMappedFeat &feat, CFeatTree *feat_tree=0, const SAnnotSelector *base_sel=0, CFeatTree::EBestGeneType lookup_type=CFeatTree::eBestGene_TreeOnly)
CMappedFeat GetParentFeature(const CMappedFeat &feat)
CSeq_id_Handle GetIdHandle(const CSeq_loc &loc, CScope *scope)
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
const string & GetNamedQual(const CTempString &qual_name) const
Return a named qualifier.
bool IsSetExcept(void) const
bool GetExcept(void) const
bool IsSetComment(void) const
const CSeq_feat::TExts & GetExts(void) const
const CSeqFeatData & GetData(void) const
bool IsSetExcept_text(void) const
bool IsSetProduct(void) const
const string & GetComment(void) const
const CUser_object & GetExt(void) const
const string & GetExcept_text(void) const
CScope & GetScope(void) const
Get scope this handle belongs to.
bool IsSetExts(void) const
bool IsSetQual(void) const
CSeqFeatData::ESubtype GetFeatSubtype(void) const
CSeqFeatData::E_Choice GetFeatType(void) const
const CSeq_feat::TQual & GetQual(void) const
bool IsSetExt(void) const
CSeq_id_Handle GetProductId(void) const
const CSeq_loc & GetLocation(void) const
const CSeq_feat & GetOriginalFeature(void) const
Get original feature with unmapped location/product.
const CSeq_feat & GetMappedFeature(void) const
Feature mapped to the master sequence.
void Reset(void)
Reset reference object.
#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 SIZE_TYPE Find(const CTempString str, const CTempString pattern, ECase use_case=eCase, EDirection direction=eForwardSearch, SIZE_TYPE occurrence=0)
Find the pattern in the string.
static string UIntToString(unsigned int value, TNumToStringFlags flags=0, int base=10)
Convert UInt to string.
static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
const TStr & GetStr(void) const
Get the variant data.
const TData & GetData(void) const
Get the Data member data.
const TGene & GetGene(void) const
Get the variant data.
bool IsRna(void) const
Check if variant Rna is selected.
const Tdata & Get(void) const
Get the member data.
TFrom GetFrom(void) const
Get the From member data.
bool IsSetStrand(void) const
Check if a value has been assigned to Strand data member.
bool CanGet(void) const
Check if it is safe to call Get method.
TStrand GetStrand(void) const
Get the Strand member data.
TTo GetTo(void) const
Get the To member data.
const TPacked_int & GetPacked_int(void) const
Get the variant data.
constexpr auto sort(_Init &&init)
static CS_CONTEXT * context
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4