NCBI C++ ToolKit
gff_writer.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: gff_writer.cpp 99065 2023-02-08 19:29:20Z ludwigf $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Frank Ludwig
27  *
28  * File Description: Write gff file
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 
40 
41 #include <objmgr/feat_ci.hpp>
42 #include <objmgr/align_ci.hpp>
43 #include <objmgr/annot_ci.hpp>
44 #include <objmgr/seqdesc_ci.hpp>
45 #include <objmgr/bioseq_ci.hpp>
46 #include <objmgr/mapped_feat.hpp>
47 #include <objmgr/util/feature.hpp>
48 #include <objmgr/util/sequence.hpp>
50 
54 
57 
58 // ----------------------------------------------------------------------------
60  CScope& scope,
61  CNcbiOstream& ostr,
62  unsigned int uFlags ) :
63 // ----------------------------------------------------------------------------
64  CWriterBase( ostr, uFlags ),
65  m_bHeaderWritten(false)
66 {
67  m_pScope.Reset( &scope );
68  //SetAnnotSelector();
69 };
70 
71 // ----------------------------------------------------------------------------
73  CNcbiOstream& ostr,
74  unsigned int uFlags ) :
75 // ----------------------------------------------------------------------------
76  CWriterBase( ostr, uFlags ),
77  m_bHeaderWritten(false)
78 {
81  //SetAnnotSelector();
82 };
83 
84 // ----------------------------------------------------------------------------
86 // ----------------------------------------------------------------------------
87 {
88 };
89 
90 // ----------------------------------------------------------------------------
92  const CSeq_annot& annot,
93  const string& strAssemblyName,
94  const string& strAssemblyAccession )
95 // ----------------------------------------------------------------------------
96 {
97  if ( ! x_WriteAssemblyInfo( strAssemblyName, strAssemblyAccession ) ) {
98  return false;
99  }
100  if ( ! x_WriteAnnot( annot ) ) {
101  return false;
102  }
103  return true;
104 }
105 
106 // ----------------------------------------------------------------------------
108  const CSeq_annot& annot )
109 // ----------------------------------------------------------------------------
110 {
111  CSeq_annot_Handle sah = m_pScope->AddSeq_annot( annot );
112  bool bWrite = x_WriteSeqAnnotHandle( sah );
113  m_pScope->RemoveSeq_annot( sah );
114  return bWrite;
115 }
116 
117 // ----------------------------------------------------------------------------
119  CSeq_entry_Handle seh,
120  const string& strAssemblyName,
121  const string& strAssemblyAccession )
122 // ----------------------------------------------------------------------------
123 {
124  if ( ! x_WriteAssemblyInfo( strAssemblyName, strAssemblyAccession ) ) {
125  return false;
126  }
127  if ( ! x_WriteSeqEntryHandle( seh ) ) {
128  return false;
129  }
130  return true;
131 }
132 
133 // ----------------------------------------------------------------------------
135  CSeq_entry_Handle seh )
136 // ----------------------------------------------------------------------------
137 {
138  bool isNucProtSet = (seh.IsSet() && seh.GetSet().IsSetClass() &&
140  if (isNucProtSet) {
141  for (CBioseq_CI bci(seh); bci; ++bci) {
142  if (!x_WriteBioseqHandle(*bci)) {
143  return false;
144  }
145  }
146  return true;
147  }
148 
149  bool isGenbankSet = (seh.IsSet() && seh.GetSet().IsSetClass() &&
151  if (isGenbankSet) {
152  for (CSeq_entry_CI seci(seh); seci; ++seci) {
153 
154  if (!x_WriteSeqEntryHandle(*seci)) {
155  return false;
156  }
157  }
158  return true;
159  }
160 
161  if (seh.IsSeq()) {
162  CBioseq_Handle bsh = seh.GetSeq();
163  return x_WriteBioseqHandle(bsh);
164  }
165 
166  SAnnotSelector sel;
167  sel.SetMaxSize(1);
168  for (CAnnot_CI aci(seh, sel); aci; ++aci) {
169  CFeat_CI fit(*aci, SetAnnotSelector());
170  CSeq_id_Handle lastId;
171  for ( /*0*/; fit; ++fit ) {
172  CSeq_id_Handle currentId =fit->GetLocationId();
173  if (currentId != lastId) {
174  x_WriteSequenceHeader(currentId);
175  lastId = currentId;
176  }
177  if (!xWriteFeature(fit)) {
178  return false;
179  }
180  }
181  }
182 
183  for (CSeq_entry_CI eci(seh); eci; ++eci) {
184  if (!x_WriteSeqEntryHandle(*eci)) {
185  return false;
186  }
187  }
188  return true;
189 }
190 
191 // ----------------------------------------------------------------------------
193  CBioseq_Handle bsh,
194  const string& strAssemblyName,
195  const string& strAssemblyAccession )
196 // ----------------------------------------------------------------------------
197 {
198  if ( ! x_WriteAssemblyInfo( strAssemblyName, strAssemblyAccession ) ) {
199  return false;
200  }
201  if ( ! x_WriteBioseqHandle( bsh ) ) {
202  return false;
203  }
204  return true;
205 }
206 
207 // ----------------------------------------------------------------------------
209  CBioseq_Handle bsh )
210 // ----------------------------------------------------------------------------
211 {
213  const auto& display_range = GetRange();
214  CFeat_CI feat_iter(bsh, display_range, sel);
215  CGffFeatureContext fc(feat_iter, bsh);
216 
217  while (feat_iter) {
218  CMappedFeat mf = *feat_iter;
219  xWriteFeature(feat_iter);
220  ++feat_iter;
221  }
222  return true;
223 }
224 
225 // ----------------------------------------------------------------------------
228  const CMappedFeat& mf)
229 // ----------------------------------------------------------------------------
230 {
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) {
235  CMappedFeat mChild = *cit;
236  if (!xWriteFeature(fc, mChild)) {
237  //error - but should have been handled elsewhere
238  continue;
239  }
240  xWriteAllChildren(fc, mChild);
241  }
242  return true;
243 }
244 
245 // ----------------------------------------------------------------------------
247  CSeq_annot_Handle sah,
248  const string& strAssemblyName,
249  const string& strAssemblyAccession )
250 // ----------------------------------------------------------------------------
251 {
252  if ( ! x_WriteAssemblyInfo( strAssemblyName, strAssemblyAccession ) ) {
253  return false;
254  }
255  if ( ! x_WriteSeqAnnotHandle( sah ) ) {
256  return false;
257  }
258  return true;
259 }
260 
261 // ----------------------------------------------------------------------------
263  CSeq_annot_Handle sah )
264 // ----------------------------------------------------------------------------
265 {
267 
268  if ( pAnnot->IsAlign() ) {
269  for ( CAlign_CI it( sah ); it; ++it ) {
270  if ( ! x_WriteAlign( *it ) ) {
271  return false;
272  }
273  }
274  return true;
275  }
276 
278  CFeat_CI feat_iter(sah, sel);
279  CGffFeatureContext fc(feat_iter, CBioseq_Handle(), sah);
280 
281  for (/*0*/; feat_iter; ++feat_iter) {
282  if (!xWriteFeature(fc,*feat_iter)) {
283  return false;
284  }
285  }
286  return true;
287 }
288 
289 // ----------------------------------------------------------------------------
291  CGffFeatureContext& context,
292  const CMappedFeat& mf )
293 // ----------------------------------------------------------------------------
294 {
295  return false;
296 }
297 
298 // ----------------------------------------------------------------------------
300  CFeat_CI feat_it)
301 // ----------------------------------------------------------------------------
302 {
303  if (!feat_it) {
304  return false;
305  }
306  CGffFeatureContext fc(feat_it, CBioseq_Handle(), feat_it->GetAnnot());
307  return xWriteFeature(fc, *feat_it);
308 }
309 
310 // ----------------------------------------------------------------------------
312  const CSeq_align& align,
313  const string& strAssName,
314  const string& strAssAcc )
315 // ----------------------------------------------------------------------------
316 {
317  if ( ! x_WriteAssemblyInfo( strAssName, strAssAcc ) ) {
318  return false;
319  }
320  if ( ! x_WriteAlign( align ) ) {
321  return false;
322  }
323  return true;
324 }
325 
326 // ----------------------------------------------------------------------------
328  const CSeq_align& align)
329 // ----------------------------------------------------------------------------
330 {
331  return false;
332 }
333 
334 // ----------------------------------------------------------------------------
336 // ----------------------------------------------------------------------------
337 {
338  if (!m_bHeaderWritten) {
339  m_Os << "##gff-version 2" << '\n';
340  m_bHeaderWritten = true;
341  }
342  return true;
343 }
344 
345 // ----------------------------------------------------------------------------
347 // ----------------------------------------------------------------------------
348 {
349  m_Os << "###" << '\n';
350  return true;
351 }
352 
353 // ----------------------------------------------------------------------------
355  const string& strName,
356  const string& strAccession )
357 // ----------------------------------------------------------------------------
358 {
359  if ( !strName.empty() ) {
360  m_Os << "##assembly name=" << strName << '\n';
361  }
362  if ( !strAccession.empty() ) {
363  m_Os << "##assembly accession=" << strAccession << '\n';
364  }
365  return true;
366 }
367 
368 // ----------------------------------------------------------------------------
370  CGffFeatureRecord& record,
372  const CMappedFeat& mf )
373  // ----------------------------------------------------------------------------
374 {
375  return xAssignFeatureBasic(record, fc, mf);
376 }
377 
378 // ----------------------------------------------------------------------------
380  CGffFeatureRecord& record,
382  const CMappedFeat& mf )
383  // ----------------------------------------------------------------------------
384 {
385  if (!xAssignFeatureType(record, fc, mf)) {
386  return false;
387  }
388  if (!xAssignFeatureSeqId(record, fc, mf)) {
389  return false;
390  }
391  if (!xAssignFeatureMethod(record, fc, mf)) {
392  return false;
393  }
394  if (!xAssignFeatureEndpoints(record, fc, mf)) {
395  return false;
396  }
397  if (!xAssignFeatureScore(record, fc, mf)) {
398  return false;
399  }
400  if (!xAssignFeatureStrand(record, fc, mf)) {
401  return false;
402  }
403  if (!xAssignFeaturePhase(record, fc, mf)) {
404  return false;
405  }
406  if (!xAssignFeatureAttributes(record, fc, mf)) {
407  return false;
408  }
409  return true;
410 }
411 
412 // ----------------------------------------------------------------------------
414  CGffFeatureRecord& record,
416  const CMappedFeat& mf )
417  // ----------------------------------------------------------------------------
418 {
419  string bestId;
420  if (!CGenbankIdResolve::Get().GetBestId(mf, bestId)) {
421  bestId = ".";
422  }
423  record.SetSeqId(bestId);
424  return true;
425 }
426 
427 // ----------------------------------------------------------------------------
429  CGffFeatureRecord& record,
431  const CMappedFeat& mf )
432  // ----------------------------------------------------------------------------
433 {
434  if ( !mf.IsSetQual() ) {
435  return true;
436  }
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() ) {
441  continue;
442  }
443  if ( (*it)->GetQual() == "gff_score" ) {
444  record.SetScore((*it)->GetVal());
445  return true;
446  }
447  }
448  return true;
449  return true;
450 }
451 
452 // ----------------------------------------------------------------------------
454  CGffFeatureRecord& record,
456  const CMappedFeat& mf )
457  // ----------------------------------------------------------------------------
458 {
459  return true;
460 }
461 
462 // ----------------------------------------------------------------------------
464  CGffFeatureRecord& record,
466  const CMappedFeat& mf )
467  // ----------------------------------------------------------------------------
468 {
469  record.SetType(".");
470  return true;
471 }
472 
473 // ----------------------------------------------------------------------------
475  CGffFeatureRecord& record,
477  const CMappedFeat& mf )
478  // ----------------------------------------------------------------------------
479 {
480  const auto& location = mf.GetLocation();
481  record.SetStrand(
482  location.IsSetStrand() ? location.GetStrand() : eNa_strand_plus);
483  return true;
484 }
485 
486 // ----------------------------------------------------------------------------
488  CGffFeatureRecord& record,
490  const CMappedFeat& mf )
491  // ----------------------------------------------------------------------------
492 {
493  record.SetMethod(".");
494  return true;
495 }
496 
497 // ----------------------------------------------------------------------------
499  CGffFeatureRecord& record,
501  const CMappedFeat& mf )
502  // ----------------------------------------------------------------------------
503 {
504  unsigned int start(0);
505  unsigned int stop(0);
506  auto strand = mf.GetLocation().GetStrand();
507 
508  if (CWriteUtil::IsTransspliced(mf)) {
510  start, stop)) {
511  return false;
512  }
513  CGffBaseRecord& baseRecord = record;
514  baseRecord.SetLocation(start, stop, strand);
515  return true;
516  }
519  record.SetEndpoints(start, stop, strand);
520  return true;
521 }
522 
523 // ----------------------------------------------------------------------------
525  CGffFeatureRecord& record,
527  const CMappedFeat& mf )
528 // ----------------------------------------------------------------------------
529 {
530  if (!xAssignFeatureAttributesFormatIndependent(record, fc, mf)) {
531  return false;
532  }
533  return xAssignFeatureAttributesFormatSpecific(record, fc, mf);
534 }
535 
536 // ----------------------------------------------------------------------------
538  CGffFeatureRecord& record,
540  const CMappedFeat& mf )
541 // ----------------------------------------------------------------------------
542 {
543  record.SetGbKeyFrom(mf);
544  return(
545  xAssignFeatureAttributesQualifiers(record, fc, mf) &&
546  xAssignFeatureAttributeDbxref(record, fc, mf) &&
547  xAssignFeatureAttributeNote(record, fc, mf) &&
548  xAssignFeatureAttributeException(record, fc, mf) &&
549  xAssignFeatureAttributeExperiment(record, fc, mf) &&
550  xAssignFeatureAttributeProduct(record, fc, mf) &&
551  xAssignFeatureAttributesGene(record, fc, mf) &&
552  xAssignFeatureAttributeOldLocusTag(record, fc, mf) &&
553  xAssignFeatureAttributeGeneBiotype(record, fc, mf) &&
554  xAssignFeatureAttributeMapLoc(record, fc, mf) &&
555  //xAssignFeatureAttributeRibosomalSlippage(record, fc, mf) &&
556  xAssignFeatureAttributePseudoGene(record, fc, mf) &&
557  xAssignFeatureAttributeFunction(record, fc, mf) &&
558  xAssignFeatureAttributesGoMarkup(record, fc, mf) &&
559  xAssignFeatureAttributeProteinId(record, fc, mf) &&
561  xAssignFeatureAttributeCodeBreak(record, fc, mf) &&
563  xAssignFeatureAttributeRptFamily(record, fc, mf) &&
564  xAssignFeatureAttributeIsOrdered(record, fc, mf) &&
565  xAssignFeatureAttributeEcNumbers(record, fc, mf) &&
566  xAssignFeatureAttributeExonNumber(record, fc, mf) &&
567  xAssignFeatureAttributePartial(record, fc, mf) &&
568  xAssignFeatureAttributePseudo(record, fc, mf));
569 }
570 
571 // ----------------------------------------------------------------------------
573  CGffFeatureRecord& record,
575  const CMappedFeat& mf )
576 // ----------------------------------------------------------------------------
577 {
578  return true;
579 }
580 
581 // ----------------------------------------------------------------------------
583  CGffFeatureRecord& record,
585  const CMappedFeat& mf )
586  // ----------------------------------------------------------------------------
587 {
588  if (mf.IsSetPseudo() && mf.GetPseudo()) {
589  record.SetAttribute("pseudo", "true");
590  fc.AssignShouldInheritPseudo(true);
591  return true;
592  }
593  if (fc.ShouldInheritPseudo()) {
594  record.SetAttribute("pseudo", "true");
595  return true;
596  }
597  return true;
598 }
599 
600 // ----------------------------------------------------------------------------
602  CGffFeatureRecord& record,
604  const CMappedFeat& mf )
605 // ----------------------------------------------------------------------------
606 {
607  if (mf.IsMapped() && mf.IsSetPartial() && mf.GetPartial()) {
608  record.SetAttribute("partial", "true");
609  return true;
610  }
611 
612  if (!mf.IsMapped() && mf.GetSeq_feat()->IsSetPartial() &&
613  mf.GetSeq_feat()->GetPartial()) {
614  record.SetAttribute("partial", "true");
615  return true;
616  }
617 
618  const CRange<TSeqPos>& display_range = GetRange();
619  const CRange<TSeqPos>& feat_range = mf.GetLocation().GetTotalRange();
620  if (display_range.IntersectionWith(feat_range).NotEmpty() &&
621  (display_range.GetFrom() > feat_range.GetFrom() ||
622  display_range.GetTo() < feat_range.GetTo())) {
623  record.SetAttribute("partial", "true");
624  return true;
625  }
626  return true;
627 }
628 
629 // ----------------------------------------------------------------------------
631  CGffFeatureRecord& record,
633  const CMappedFeat& mf )
634 // ----------------------------------------------------------------------------
635 {
636  if (!mf.IsSetData() || !mf.GetData().IsCdregion()) {
637 
638  return true;
639  }
640  const CSeqFeatData::TCdregion& cds = mf.GetData().GetCdregion();
641  if (!cds.IsSetCode()) {
642  return true;
643  }
644  int id = cds.GetCode().GetId();
645  if (id != 1 && id != 255) {//former gff3 version
646  //if (true) {//former gtf version
647  record.SetAttribute("transl_table", NStr::IntToString(id));
648  return true;
649  }
650  return true;
651 }
652 
653 // ----------------------------------------------------------------------------
655  CGffFeatureRecord& record,
657  const CMappedFeat& mf )
658 // ----------------------------------------------------------------------------
659 {
660  auto featSubtype = mf.GetFeatSubtype();
661  if (featSubtype != CSeq_feat::TData::eSubtype_cdregion) {
662  return true;
663  }
664  if (mf.IsSetExcept_text()) {
665  if (mf.GetExcept_text() == "ribosomal slippage") {
666  record.AddAttribute("ribosomal_slippage", "");
667  }
668  }
669  return true;
670 }
671 
672 // ----------------------------------------------------------------------------
674  CGffFeatureRecord& record,
676  const CMappedFeat& mf )
677 // ----------------------------------------------------------------------------
678 {
679  auto featSubtype = mf.GetFeatSubtype();
680  if (featSubtype != CSeq_feat::TData::eSubtype_cdregion) {
681  return true;
682  }
683 
684  auto protein_id = mf.GetNamedQual("protein_id");
685  if (!protein_id.empty()) {
686  record.AddAttribute("protein_id", protein_id);
687  return true;
688  }
689  if (mf.IsSetProduct()) {
690  string product;
692  mf.GetProductId(), mf.GetScope(), product)) {
693  record.AddAttribute("protein_id", product);
694  return true;
695  }
696  record.AddAttribute(
697  "protein_id", mf.GetProduct().GetId()->GetSeqIdString(true));
698  return true;
699  }
700  return true;
701 }
702 
703 // ----------------------------------------------------------------------------
705  CGffFeatureRecord& record,
707  const CMappedFeat& mf )
708 // ----------------------------------------------------------------------------
709 {
710 
711  CSeqFeatData::ESubtype subtype = mf.GetFeatSubtype();
712  if (subtype == CSeqFeatData::eSubtype_cdregion) {
713 
714  // Possibility 1:
715  // Product name comes from a prot-ref which stored in the seqfeat's
716  // xrefs:
717  const CProt_ref* pProtRef = mf.GetProtXref();
718  if ( pProtRef && pProtRef->IsSetName() ) {
719  const list<string>& names = pProtRef->GetName();
720  record.SetAttribute("product", names.front());
721  return true;
722  }
723 
724  // Possibility 2:
725  // Product name is from the prot-ref refered to by the seqfeat's
726  // data.product:
727  if (mf.IsSetProduct()) {
728  const CSeq_id* pId = mf.GetProduct().GetId();
729  if (pId) {
730  CBioseq_Handle bsh = mf.GetScope().GetBioseqHandle(*pId);
731  if (bsh) {
734  CFeat_CI it(bsh, sel);
735  if (it && it->IsSetData()
736  && it->GetData().GetProt().IsSetName()
737  && !it->GetData().GetProt().GetName().empty()) {
738  record.SetAttribute("product",
739  it->GetData().GetProt().GetName().front());
740  return true;
741  }
742  }
743  }
744 
745  string product;
747  mf.GetProductId(), mf.GetScope(), product)) {
748  record.SetAttribute("product", product);
749  return true;
750  }
751  }
752  }
753 
755  if (type == CSeqFeatData::e_Rna) {
756  const CRNA_ref& rna = mf.GetData().GetRna();
757 
758  if (subtype == CSeqFeatData::eSubtype_tRNA) {
759  if (rna.IsSetExt() && rna.GetExt().IsTRNA()) {
760 
761  const CRange<TSeqPos>& display_range = GetRange();
762  const CTrna_ext& trna = display_range.IsWhole() ?
763  rna.GetExt().GetTRNA() :
764  *sequence::CFeatTrim::Apply(rna.GetExt().GetTRNA(), display_range);
765 
766  string anticodon;
767  if (CWriteUtil::GetTrnaAntiCodon(trna, anticodon)) {
768  record.SetAttribute("anticodon", anticodon);
769  }
770  string codons;
771  if (CWriteUtil::GetTrnaCodons(trna, codons)) {
772  record.SetAttribute("codons", codons);
773  }
774  string aa;
775  if (CWriteUtil::GetTrnaProductName(trna, aa)) {
776  record.SetAttribute("product", aa);
777  return true;
778  }
779  }
780  }
781 
782  if (rna.IsSetExt() && rna.GetExt().IsName()) {
783  record.SetAttribute("product", rna.GetExt().GetName());
784  return true;
785  }
786 
787  if (rna.IsSetExt() && rna.GetExt().IsGen() &&
788  rna.GetExt().GetGen().IsSetProduct() ) {
789  record.SetAttribute("product", rna.GetExt().GetGen().GetProduct());
790  return true;
791  }
792  }
793 
794  // finally, look for gb_qual
795  if (mf.IsSetQual()) {
796  const CSeq_feat::TQual& quals = mf.GetQual();
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") {
801  record.SetAttribute("product", (*cit)->GetVal());
802  return true;
803  }
804  }
805  }
806  return true;
807 }
808 
809 // ----------------------------------------------------------------------------
811  CGffFeatureRecord& record,
813  const CMappedFeat& mf )
814 // ----------------------------------------------------------------------------
815 {
816  if (!mf.IsSetData() || !mf.GetData().IsCdregion()) {
817  return true;
818  }
819  const CSeqFeatData::TCdregion& cds = mf.GetData().GetCdregion();
820  if (!cds.IsSetCode_break()) {
821  return true;
822  }
823 
824  const list<CRef<CCode_break> >& code_breaks = cds.GetCode_break();
825 
826  const CRange<TSeqPos>& display_range = GetRange();
827  if (!display_range.IsWhole()) { // Trim the code breaks before writing
828  for (CRef<CCode_break> code_break : code_breaks) {
829  string cbString;
830  CRef<CCode_break> trimmed_cb = sequence::CFeatTrim::Apply(*code_break, display_range);
831  if (trimmed_cb.NotEmpty() &&
832  CWriteUtil::GetCodeBreak(*trimmed_cb, cbString)) {
833  record.AddAttribute("transl_except", cbString);
834  }
835  }
836  return true;
837  }
838 
839  list<CRef<CCode_break> >::const_iterator it = code_breaks.begin();
840  for (; it != code_breaks.end(); ++it) {
841  string cbString;
842  if (CWriteUtil::GetCodeBreak(**it, cbString)) {
843  record.AddAttribute("transl_except", cbString);
844  }
845  }
846  return true;
847 }
848 
849 // ----------------------------------------------------------------------------
850 const CGene_ref&
853  const CMappedFeat& mf)
854 // ----------------------------------------------------------------------------
855 {
856  static const CGene_ref noRef;
857  if (mf.GetData().IsGene()) {
858  return mf.GetData().GetGene();
859  }
860  // do not use xref gene ref directly !!!
861  CMappedFeat gene = fc.FindBestGeneParent(mf);
862  if (gene && gene.IsSetData() && gene.GetData().IsGene()) {
863  return gene.GetData().GetGene();
864  }
865  return noRef;
866 }
867 
868 // ----------------------------------------------------------------------------
870  CGffFeatureRecord& record,
872  const CMappedFeat& mf )
873 // ----------------------------------------------------------------------------
874 {
875  const auto& geneRef = sGetClosestGeneRef(fc, mf);
876  if (geneRef.IsSetLocus()) {
877  record.SetAttribute("gene", geneRef.GetLocus());
878  }
879  if (geneRef.IsSetLocus_tag()) {
880  record.SetAttribute("locus_tag", geneRef.GetLocus_tag());
881  }
882  if (mf.GetData().IsGene()) {
883  if (geneRef.IsSetDesc()) {
884  record.SetAttribute("description", geneRef.GetDesc());
885  }
886  if (geneRef.IsSetSyn()) {
887  const auto& syns = geneRef.GetSyn();
888  auto it = syns.begin();
889  while (it != syns.end()) {
890  record.AddAttribute("gene_synonym", *(it++));
891  }
892  }
893  }
894  return true;
895 
896 }
897 
898 // ----------------------------------------------------------------------------
900  CGffFeatureRecord& record,
902  const CMappedFeat& mf)
903 // ----------------------------------------------------------------------------
904 {
905  if (!mf.GetData().IsGene()) {
906  return true;
907  }
908  if (!mf.IsSetQual()) {
909  return true;
910  }
911  string old_locus_tags;
912  vector<CRef<CGb_qual> > quals = mf.GetQual();
913  for (vector<CRef<CGb_qual> >::const_iterator it = quals.begin();
914  it != quals.end(); ++it) {
915  if ((**it).IsSetQual() && (**it).IsSetVal()) {
916  string qual = (**it).GetQual();
917  if (qual != "old_locus_tag") {
918  continue;
919  }
920  if (!old_locus_tags.empty()) {
921  old_locus_tags += ",";
922  }
923  old_locus_tags += (**it).GetVal();
924  }
925  }
926  if (!old_locus_tags.empty()) {
927  record.SetAttribute("old_locus_tag", old_locus_tags);
928  }
929  return true;
930 }
931 
932 // ----------------------------------------------------------------------------
934  CGffFeatureRecord& record,
936  const CMappedFeat& mf)
937 // ----------------------------------------------------------------------------
938 {
939  // if a biosource is present then only compute if also is genomic record
940  // if a biosource is not present then always compute
941  if (!mf.GetData().IsGene()) {
942  return true;
943  }
944  if (fc.HasSequenceBioSource() && !fc.IsSequenceGenomicRecord()) {
945  return true;
946  }
947 
948  string biotype;
949  if (!feature::GetFeatureGeneBiotypeFaster(fc.FeatTree(), mf, biotype)) {
950  return true;
951  }
952  record.SetAttribute("gene_biotype", biotype);
953  return true;
954 }
955 
956 
957 // ----------------------------------------------------------------------------
959  CGffFeatureRecord& record,
961  const CMappedFeat& mf )
962 // ----------------------------------------------------------------------------
963 {
964  if (!mf.GetData().IsGene()) {
965  return true;
966  }
967  const CGene_ref& gene_ref = mf.GetData().GetGene();
968  if (!gene_ref.IsSetMaploc()) {
969  return true;
970  }
971  record.SetAttribute("map", gene_ref.GetMaploc());
972  return true;
973 }
974 
975 
976 // ----------------------------------------------------------------------------
978  CGffFeatureRecord& record,
980  const CMappedFeat& mf )
981 // ----------------------------------------------------------------------------
982 {
983  if (mf.IsSetExcept_text()) {
984  record.SetAttribute("exception", mf.GetExcept_text());
985  return true;
986  }
987  if (mf.IsSetExcept()) {
988  // what should I do?
989  return true;
990  }
991  return true;
992 }
993 
994 
995 // ----------------------------------------------------------------------------
997  CGffFeatureRecord& record,
999  const CMappedFeat& mf )
1000 // ----------------------------------------------------------------------------
1001 {
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());
1007  }
1008  }
1009  if (!experiments.empty()) {
1010  record.SetAttributes("experiment", experiments);
1011  }
1012  return true;
1013 }
1014 
1015 // ----------------------------------------------------------------------------
1017  CGffFeatureRecord& record,
1019  const CMappedFeat& mf)
1020 // ----------------------------------------------------------------------------
1021 {
1022  string modelEvidence;
1023  if (!CWriteUtil::GetStringForModelEvidence(mf, modelEvidence)) {
1024  return true;
1025  }
1026  if (!modelEvidence.empty()) {
1027  record.SetAttribute("model_evidence", modelEvidence);
1028  }
1029  return true;
1030 }
1031 
1032 // ----------------------------------------------------------------------------
1034  CGffFeatureRecord& record,
1036  const CMappedFeat& mf)
1037 // -----------------------------------------------------------------------------
1038 {
1040  switch (s) {
1041  default:
1042  return true;
1045  const CSeq_feat::TQual& quals = mf.GetQual();
1046  if (quals.empty()) {
1047  return true;
1048  }
1049  for (CSeq_feat::TQual::const_iterator cit = quals.begin();
1050  cit != quals.end(); ++cit) {
1051  if ((*cit)->GetQual() == "rpt_family") {
1052  record.SetAttribute("rpt_family", (*cit)->GetVal());
1053  return true;
1054  }
1055  }
1056  }
1057  }
1058  return true;
1059 }
1060 
1061 // ----------------------------------------------------------------------------
1063  CGffFeatureRecord& record,
1065  const CMappedFeat& mf )
1066 // ----------------------------------------------------------------------------
1067 {
1068  string pseudoGene = mf.GetNamedQual("pseudogene");
1069  if (!pseudoGene.empty()) {
1070  record.SetAttribute("pseudogene", pseudoGene);
1071  return true;
1072  }
1075  return true;
1076  }
1077  CMappedFeat gene = fc.FindBestGeneParent(mf);
1078  if (!gene) {
1079  return true;
1080  }
1081  pseudoGene = gene.GetNamedQual("pseudogene");
1082  if (!pseudoGene.empty()) {
1083  record.SetAttribute("pseudogene", pseudoGene);
1084  return true;
1085  }
1086  return true;
1087 }
1088 
1089 // ----------------------------------------------------------------------------
1091  CGffFeatureRecord& record,
1093  const CMappedFeat& mf )
1094 // ----------------------------------------------------------------------------
1095 {
1097  record.SetAttribute("is_ordered", "true");
1098  }
1099  return true;
1100 }
1101 
1102 // ----------------------------------------------------------------------------
1104  CGffFeatureRecord& record,
1106  const CMappedFeat& mf )
1107 // ----------------------------------------------------------------------------
1108 {
1109  const string& function = mf.GetNamedQual("function");
1110  if (!function.empty()) {
1111  record.SetAttribute("function", function);
1112  return true;
1113  }
1114  if (CSeqFeatData::e_Prot != mf.GetFeatType()) {
1115  return true;
1116  }
1117  const CProt_ref& prot = mf.GetData().GetProt();
1118  if (prot.CanGetActivity() && !prot.GetActivity().empty()) {
1119  record.SetAttribute("function", prot.GetActivity().front());
1120  return true;
1121  }
1122  return true;
1123 }
1124 
1125 // ----------------------------------------------------------------------------
1127  CGffFeatureRecord& record,
1129  const CMappedFeat& mf )
1130 // ----------------------------------------------------------------------------
1131 {
1132  const string& go_component = mf.GetNamedQual("go_component");
1133  if (!go_component.empty()) {
1134  record.SetAttribute("go_component", go_component);
1135  return true;
1136  }
1137  if (!mf.IsSetExt()) {
1138  return true;
1139  }
1140 
1141  const auto& ext = mf.GetExt();
1142  if (!ext.IsSetType() || !ext.GetType().IsStr()) {
1143  return true;
1144  }
1145  if (ext.GetType().GetStr() == "GeneOntology") {
1146  list<string> goIds;
1147  const auto& goFields = ext.GetData();
1148  for (const auto& goField: goFields) {
1149  if (!goField->IsSetLabel() || !goField->GetLabel().IsStr()) {
1150  continue;
1151  }
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;
1157  if (CWriteUtil::GetStringsForGoMarkup(fields, goStrings)) {
1158  record.SetAttributes("go_component", goStrings);
1159  }
1160  CWriteUtil::GetListOfGoIds(fields, goIds);
1161  continue;
1162  }
1163  if (goLabel == "Process" && goField->IsSetData()
1164  && goField->GetData().IsFields()) {
1165  const auto& fields = goField->GetData().GetFields();
1166  vector<string> goStrings;
1167  if (CWriteUtil::GetStringsForGoMarkup(fields, goStrings)) {
1168  record.SetAttributes("go_process", goStrings);
1169  }
1170  CWriteUtil::GetListOfGoIds(fields, goIds);
1171  continue;
1172  }
1173  if (goLabel == "Function" && goField->IsSetData()
1174  && goField->GetData().IsFields()) {
1175  const auto& fields = goField->GetData().GetFields();
1176  vector<string> goStrings;
1177  if (CWriteUtil::GetStringsForGoMarkup(fields, goStrings)) {
1178  record.SetAttributes("go_function", goStrings);
1179  }
1180  CWriteUtil::GetListOfGoIds(fields, goIds);
1181  continue;
1182  }
1183  }
1184  if (!goIds.empty()) {
1185  record.SetAttributes("Ontology_term", vector<string>(goIds.begin(), goIds.end()));
1186  }
1187  } else if (ext.GetType().GetStr() == "CombinedFeatureUserObjects") {
1188  const CUser_object::TData & ext_data = ext.GetData();
1189  ITERATE (CSeq_feat::TExt::TData, it, ext_data) {
1190  const CUser_field & field = **it;
1191  if( ! field.IsSetLabel() || ! field.IsSetData() ) {
1192  continue;
1193  }
1194  const CUser_field::TLabel & field_label = field.GetLabel();
1195  const CUser_field::TData & field_data = field.GetData();
1196  if (field_label.IsStr() && field_label.GetStr() == "GeneOntology") {
1197  if (field_data.IsFields()) {
1198  list<string> goIds;
1199  const auto& goFields = field.GetData().GetFields();
1200  for (const auto& goField: goFields) {
1201  if (!goField->IsSetLabel() || !goField->GetLabel().IsStr()) {
1202  continue;
1203  }
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;
1209  if (CWriteUtil::GetStringsForGoMarkup(fields, goStrings, true)) {
1210  record.SetAttributes("go_component", goStrings);
1211  }
1212  CWriteUtil::GetListOfGoIds(fields, goIds, true);
1213  continue;
1214  }
1215  if (goLabel == "Process" && goField->IsSetData()
1216  && goField->GetData().IsFields()) {
1217  const auto& fields = goField->GetData().GetFields();
1218  vector<string> goStrings;
1219  if (CWriteUtil::GetStringsForGoMarkup(fields, goStrings, true)) {
1220  record.SetAttributes("go_process", goStrings);
1221  }
1222  CWriteUtil::GetListOfGoIds(fields, goIds, true);
1223  continue;
1224  }
1225  if (goLabel == "Function" && goField->IsSetData()
1226  && goField->GetData().IsFields()) {
1227  const auto& fields = goField->GetData().GetFields();
1228  vector<string> goStrings;
1229  if (CWriteUtil::GetStringsForGoMarkup(fields, goStrings, true)) {
1230  record.SetAttributes("go_function", goStrings);
1231  }
1232  CWriteUtil::GetListOfGoIds(fields, goIds, true);
1233  continue;
1234  }
1235  }
1236  if (!goIds.empty()) {
1237  record.SetAttributes("Ontology_term", vector<string>(goIds.begin(), goIds.end()));
1238  }
1239  }
1240  }
1241  }
1242  }
1243 
1244  return true;
1245 }
1246 
1247 // ----------------------------------------------------------------------------
1249  CGffFeatureRecord& record,
1251  const CMappedFeat& mf )
1252 // ----------------------------------------------------------------------------
1253 {
1254  if (CSeqFeatData::e_Prot != mf.GetFeatType()) {
1255  return true;
1256  }
1257  const CProt_ref& prot = mf.GetData().GetProt();
1258  if (prot.CanGetEc()) {
1259  const list<string> ec = prot.GetEc();
1260  if (!ec.empty()) {
1261  record.SetAttributes(
1262  "ec_number", vector<string>(ec.begin(), ec.end()));
1263  }
1264  return true;
1265  }
1266  return true;
1267 }
1268 
1269 // ----------------------------------------------------------------------------
1271  CGffFeatureRecord& record,
1273  const CMappedFeat& mf )
1274 // ----------------------------------------------------------------------------
1275 {
1276  if (!mf.IsSetQual()) {
1277  return true;
1278  }
1279  const CSeq_feat::TQual& quals = mf.GetQual();
1280  for ( CSeq_feat::TQual::const_iterator cit = quals.begin();
1281  cit != quals.end();
1282  ++cit ) {
1283  const CGb_qual& qual = **cit;
1284  if (qual.IsSetQual() && qual.GetQual() == "number") {
1285  record.SetAttribute("exon_number", qual.GetVal());
1286  return true;
1287  }
1288  }
1289  return true;
1290 }
1291 
1292 // ----------------------------------------------------------------------------
1294  const CMappedFeat& mf)
1295 // ----------------------------------------------------------------------------
1296 {
1297  static list<CSeqFeatData::ESubtype> acceptableTranscriptTypes = {
1304  };
1305  auto itType = std::find(
1306  acceptableTranscriptTypes.begin(), acceptableTranscriptTypes.end(),
1307  mf.GetFeatSubtype());
1308  return (itType != acceptableTranscriptTypes.end());
1309 }
1310 
1311 // ----------------------------------------------------------------------------
1313  CGffFeatureContext& context,
1314  const CMappedFeat& mf)
1315 // ----------------------------------------------------------------------------
1316 {
1317  CMappedFeat parent = context.FeatTree().GetParent(mf);
1318  if (!parent) {
1319  return false;
1320  }
1321  return IsTranscriptType(parent);
1322 }
1323 
1324 // ----------------------------------------------------------------------------
1326  CGffFeatureContext& context,
1327  const CMappedFeat& mf )
1328 // ----------------------------------------------------------------------------
1329 {
1331  return CMappedFeat();
1332  }
1333  if (HasAccaptableTranscriptParent(context, mf)) {
1334  return CMappedFeat();
1335  }
1336 
1337  CRef<CSeq_feat> pMissingTranscript(new CSeq_feat);
1338  pMissingTranscript.Reset(new CSeq_feat);
1339  pMissingTranscript->SetData().SetRna().SetType(CRNA_ref::eType_mRNA);
1340  pMissingTranscript->SetLocation().Assign(mf.GetLocation());
1341  pMissingTranscript->SetLocation().SetPartialStart(false, eExtreme_Positional);
1342  pMissingTranscript->SetLocation().SetPartialStop(false, eExtreme_Positional);
1343  pMissingTranscript->ResetPartial();
1344 
1345  // rw-1921
1346  if (mf.IsSetExcept() && mf.GetExcept()) {
1347  pMissingTranscript->SetExcept(true);
1348  if (mf.IsSetExcept_text()) {
1349  pMissingTranscript->SetExcept_text(mf.GetExcept_text());
1350  }
1351  }
1352  CScope& scope = mf.GetScope();
1353  CSeq_annot_Handle sah = mf.GetAnnot();
1354  CSeq_annot_EditHandle saeh = sah.GetEditHandle();
1355  saeh.AddFeat(*pMissingTranscript);
1356  CMappedFeat tf = scope.GetObjectHandle(*pMissingTranscript);
1357  context.FeatTree().AddFeature(tf);
1358  return tf;
1359 }
1360 
1361 // ----------------------------------------------------------------------------
1363  const list<CRef<CSeq_interval>>& sublocs)
1364 // ----------------------------------------------------------------------------
1365 {
1366  _ASSERT(sublocs.size());
1367  if (sublocs.size() == 1) { // most common
1368  return false;
1369  }
1370 
1371  const auto& front = *sublocs.front();
1372  auto frontStrand = CWriteUtil::GetEffectiveStrand(front);
1373  auto lastStart = front.GetFrom();
1374  for (auto itComp = sublocs.begin()++; itComp != sublocs.end(); itComp++) {
1375  const auto& comp = **itComp;
1376  if (frontStrand != CWriteUtil::GetEffectiveStrand(comp)) {
1377  return true;
1378  }
1379  auto compStart = comp.GetFrom();
1380  if (frontStrand == eNa_strand_plus && lastStart > compStart) {
1381  return true;
1382  }
1383  if (frontStrand == eNa_strand_minus && lastStart < compStart) {
1384  return true;
1385  }
1386  lastStart = compStart;
1387  }
1388  return false;
1389 }
1390 
1391 
User-defined methods of the data storage class.
@ eExtreme_Positional
numerical value
Definition: Na_strand.hpp:63
User-defined methods of the data storage class.
#define false
Definition: bool.h:36
CAlign_CI –.
Definition: align_ci.hpp:63
CAnnot_CI –.
Definition: annot_ci.hpp:59
CBioseq_CI –.
Definition: bioseq_ci.hpp:69
CBioseq_Handle –.
CCdregion –.
Definition: Cdregion.hpp:66
CFeat_CI –.
Definition: feat_ci.hpp:64
@Gb_qual.hpp User-defined methods of the data storage class.
Definition: Gb_qual.hpp:61
static CGenbankIdResolve & Get()
int GetId(void) const
virtual bool xAssignFeatureAttributeProduct(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
Definition: gff_writer.cpp:704
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.
Definition: gff_writer.cpp:311
virtual bool xAssignFeatureAttributeNote(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
Definition: gff_writer.hpp:259
virtual bool xAssignFeatureType(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
Definition: gff_writer.cpp:463
bool xAssignFeatureAttributeFunction(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
virtual bool xAssignFeatureAttributeProteinId(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
Definition: gff_writer.cpp:673
bool xAssignFeatureAttributeMapLoc(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
Definition: gff_writer.cpp:958
virtual bool xAssignFeature(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
Definition: gff_writer.cpp:369
bool WriteFooter() override
Write a trailer marking the end of a parsing context.
Definition: gff_writer.cpp:346
bool m_bHeaderWritten
Definition: gff_writer.hpp:398
bool xAssignFeatureAttributeRptFamily(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
bool xAssignFeatureAttributeCodeBreak(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
Definition: gff_writer.cpp:810
bool WriteAnnot(const CSeq_annot &annot, const string &asmblyName="", const string &asmblyAccession="") override
Convenience function to render a "naked" Seq-annot.
Definition: gff_writer.cpp:91
static bool HasAccaptableTranscriptParent(CGffFeatureContext &, const CMappedFeat &)
virtual ~CGff2Writer()
Definition: gff_writer.cpp:85
virtual bool xAssignFeatureAttributePseudo(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
Definition: gff_writer.cpp:582
virtual bool x_WriteAssemblyInfo(const string &, const string &)
Definition: gff_writer.cpp:354
virtual bool xAssignFeatureStrand(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
Definition: gff_writer.cpp:474
virtual bool xWriteAllChildren(CGffFeatureContext &, const CMappedFeat &)
Definition: gff_writer.cpp:226
virtual bool xAssignFeatureAttributesFormatIndependent(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
Definition: gff_writer.cpp:537
virtual bool x_WriteAnnot(const CSeq_annot &)
Definition: gff_writer.cpp:107
CGff2Writer(CScope &scope, CNcbiOstream &ostr, unsigned int flags=fNormal)
Constructor.
Definition: gff_writer.cpp:59
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...
Definition: gff_writer.cpp:192
virtual bool x_WriteAlign(const CSeq_align &)
Definition: gff_writer.cpp:327
virtual bool xAssignFeatureAttributeDbxref(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
Definition: gff_writer.hpp:255
CRef< CScope > m_pScope
Definition: gff_writer.hpp:397
virtual bool xAssignFeatureAttributeRibosomalSlippage(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
Definition: gff_writer.cpp:654
bool xAssignFeatureAttributeGeneBiotype(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
Definition: gff_writer.cpp:933
virtual bool xGeneratingMissingTranscripts() const
Definition: gff_writer.hpp:378
virtual bool xWriteFeature(CGffFeatureContext &, const CMappedFeat &)
Definition: gff_writer.cpp:290
bool xAssignFeatureAttributePseudoGene(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
virtual bool x_WriteSeqAnnotHandle(CSeq_annot_Handle)
Definition: gff_writer.cpp:262
bool xAssignFeatureAttributeEcNumbers(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
bool xAssignFeatureAttributesGoMarkup(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
virtual bool x_WriteSeqEntryHandle(CSeq_entry_Handle)
Definition: gff_writer.cpp:134
virtual bool xAssignFeatureSeqId(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
Definition: gff_writer.cpp:413
bool xAssignFeatureAttributeModelEvidence(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
virtual bool xAssignFeatureEndpoints(CGffFeatureRecord &record, CGffFeatureContext &, const CMappedFeat &mapped_feat)
Definition: gff_writer.cpp:498
virtual bool xAssignFeatureAttributePartial(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
Definition: gff_writer.cpp:601
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.
Definition: gff_writer.cpp:246
virtual bool xAssignFeatureMethod(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
Definition: gff_writer.cpp:487
virtual bool xAssignFeatureAttributesQualifiers(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
Definition: gff_writer.hpp:247
bool WriteHeader() override
Write a file header identifying the file content as GFF version 2.
Definition: gff_writer.cpp:335
virtual bool xAssignFeatureAttributes(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
Definition: gff_writer.cpp:524
virtual bool xAssignFeatureAttributesFormatSpecific(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
Definition: gff_writer.cpp:572
bool WriteSeqEntryHandle(CSeq_entry_Handle seh, const string &asmblyName="", const string &asmblyAccession="") override
Write Seq-entry contained in a given handle.
Definition: gff_writer.cpp:118
virtual bool xAssignFeatureAttributesGene(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
Definition: gff_writer.cpp:869
bool xAssignFeatureAttributeOldLocusTag(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
Definition: gff_writer.cpp:899
virtual bool xAssignFeatureAttributeTranslationTable(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
Definition: gff_writer.cpp:630
virtual bool x_WriteBioseqHandle(CBioseq_Handle)
Definition: gff_writer.cpp:208
bool xAssignFeatureAttributeExonNumber(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
bool xAssignFeatureAttributeExperiment(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
Definition: gff_writer.cpp:996
virtual bool x_WriteSequenceHeader(CBioseq_Handle)
Definition: gff_writer.hpp:344
virtual bool xAssignFeatureBasic(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
Definition: gff_writer.cpp:379
virtual bool xAssignFeatureScore(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
Definition: gff_writer.cpp:428
virtual bool xAssignFeaturePhase(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
Definition: gff_writer.cpp:453
static bool xIntervalsNeedPartNumbers(const list< CRef< CSeq_interval >> &)
CMappedFeat xGenerateMissingTranscript(CGffFeatureContext &, const CMappedFeat &)
bool xAssignFeatureAttributeException(CGffFeatureRecord &, CGffFeatureContext &, const CMappedFeat &)
Definition: gff_writer.cpp:977
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)
CMappedFeat –.
Definition: mapped_feat.hpp:59
@RNA_ref.hpp User-defined methods of the data storage class.
Definition: RNA_ref.hpp:54
CScope –.
Definition: scope.hpp:92
bool IsLegalQualifier(EQualifier qual) const
Test wheather a certain qualifier is legal for the feature.
CSeq_annot_Handle –.
bool IsAlign(void) const
Definition: Seq_annot.cpp:182
CSeq_entry_CI –.
CSeq_entry_Handle –.
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
static bool IsTransspliced(const CSeq_feat &feature)
static bool GetTrnaAntiCodon(const CTrna_ext &, string &)
Definition: write_util.cpp:428
static bool GetStringsForGoMarkup(const vector< CRef< CUser_field > > &fields, vector< string > &goMarkup, bool relaxed=false)
static bool IsLocationOrdered(const CSeq_loc &)
Definition: write_util.cpp:569
static bool GetStringForModelEvidence(CMappedFeat mf, string &mestr)
Definition: write_util.cpp:889
static bool GetCodeBreak(const CCode_break &, string &)
Definition: write_util.cpp:266
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 &)
Definition: write_util.cpp:374
static bool GetTrnaProductName(const CTrna_ext &, string &)
Definition: write_util.cpp:404
Defines and provides stubs for a general interface to a variety of file formatters.
Definition: writer.hpp:81
virtual const CRange< TSeqPos > & GetRange(void) const
Definition: writer.hpp:262
virtual SAnnotSelector & SetAnnotSelector(void)
Definition: writer.hpp:246
CNcbiOstream & m_Os
Definition: writer.hpp:267
static const char location[]
Definition: config.c:97
static const struct name_t names[]
USING_SCOPE(objects)
const CGene_ref & sGetClosestGeneRef(CGffFeatureContext &fc, const CMappedFeat &mf)
Definition: gff_writer.cpp:851
const TResidue codons[4][4]
Definition: gnomon_seq.cpp:76
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
string GetSeqIdString(bool with_version=false) const
Return seqid string with optional version for text seqid type.
Definition: Seq_id.cpp:2144
ENa_strand GetStrand(void) const
Get the location's strand.
Definition: Seq_loc.cpp:882
TRange GetTotalRange(void) const
Definition: Seq_loc.hpp:913
TSeqPos GetStart(ESeqLocExtremes ext) const
Return start and stop positions of the seq-loc.
Definition: Seq_loc.cpp:915
const CSeq_id * GetId(void) const
Get the id of the location return NULL if has multiple ids or no id at all.
Definition: Seq_loc.hpp:941
TSeqPos GetStop(ESeqLocExtremes ext) const
Definition: Seq_loc.cpp:963
bool GetFeatureGeneBiotypeFaster(feature::CFeatTree &ft, CMappedFeat mf, string &biotype)
Definition: feature.cpp:4485
void RemoveSeq_annot(const CSeq_annot_Handle &annot)
Revoke Seq-annot previously added using AddSeq_annot().
Definition: scope.cpp:388
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.
Definition: scope.cpp:95
void AddDefaults(TPriority pri=kPriority_Default)
Add default data loaders from object manager.
Definition: scope.cpp:504
CSeq_annot_Handle AddSeq_annot(CSeq_annot &annot, TPriority pri=kPriority_Default, EExist action=eExist_Throw)
Add Seq-annot, return its CSeq_annot_Handle.
Definition: scope.cpp:538
CBioseq_Handle GetObjectHandle(const CBioseq &bioseq, EMissing action=eMissing_Default)
Definition: scope.hpp:715
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
TSet GetSet(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
TSeq GetSeq(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 IsSet(void) const
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
bool IsSeq(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.
Definition: mapped_feat.hpp:75
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.
Definition: ncbiobj.hpp:773
bool NotEmpty(void) const THROWS_NONE
Check if CRef is not empty – pointing to an object and has a non-null value.
Definition: ncbiobj.hpp:726
bool NotEmpty(void) const
Definition: range.hpp:152
TThisType IntersectionWith(const TThisType &r) const
Definition: range.hpp:312
bool IsWhole(void) const
Definition: range.hpp:284
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
Definition: ncbistre.hpp:149
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
Definition: ncbistr.hpp:5083
TTo GetTo(void) const
Get the To member data.
Definition: Range_.hpp:269
TFrom GetFrom(void) const
Get the From member data.
Definition: Range_.hpp:222
bool IsSetMaploc(void) const
descriptive map location Check if a value has been assigned to Maploc data member.
Definition: Gene_ref_.hpp:634
const TMaploc & GetMaploc(void) const
Get the Maploc member data.
Definition: Gene_ref_.hpp:646
bool IsStr(void) const
Check if variant Str is selected.
Definition: Object_id_.hpp:291
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.
Definition: Object_id_.hpp:297
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.
Definition: Prot_ref_.hpp:378
bool IsSetName(void) const
protein name Check if a value has been assigned to Name data member.
Definition: Prot_ref_.hpp:366
const TVal & GetVal(void) const
Get the Val member data.
Definition: Gb_qual_.hpp:259
void ResetPartial(void)
Reset Partial data member.
Definition: Seq_feat_.hpp:955
bool IsSetCode(void) const
genetic code used Check if a value has been assigned to Code data member.
Definition: Cdregion_.hpp:700
void SetLocation(TLocation &value)
Assign a value to Location data member.
Definition: Seq_feat_.cpp:131
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.
Definition: Seq_feat_.hpp:943
E_Choice
Choice variants.
void SetExcept(TExcept value)
Assign a value to Except data member.
Definition: Seq_feat_.hpp:1018
bool IsGene(void) const
Check if variant Gene is selected.
const TCode & GetCode(void) const
Get the Code member data.
Definition: Cdregion_.hpp:712
void SetData(TData &value)
Assign a value to Data data member.
Definition: Seq_feat_.cpp:94
const TCdregion & GetCdregion(void) const
Get the variant data.
bool IsSetQual(void) const
Check if a value has been assigned to Qual data member.
Definition: Gb_qual_.hpp:200
const TGene & GetGene(void) const
Get the variant data.
TPartial GetPartial(void) const
Get the Partial member data.
Definition: Seq_feat_.hpp:962
void SetExcept_text(const TExcept_text &value)
Assign a value to Except_text data member.
Definition: Seq_feat_.hpp:1414
const TProt & GetProt(void) const
Get the variant data.
vector< CRef< CGb_qual > > TQual
Definition: Seq_feat_.hpp:117
const TQual & GetQual(void) const
Get the Qual member data.
Definition: Gb_qual_.hpp:212
const TRna & GetRna(void) const
Get the variant data.
const TCode_break & GetCode_break(void) const
Get the Code_break member data.
Definition: Cdregion_.hpp:733
bool IsSetCode_break(void) const
individual exceptions Check if a value has been assigned to Code_break data member.
Definition: Cdregion_.hpp:721
@ eNa_strand_plus
Definition: Na_strand_.hpp:66
@ eNa_strand_minus
Definition: Na_strand_.hpp:67
@ eClass_nuc_prot
nuc acid and coded proteins
Definition: Bioseq_set_.hpp:99
@ eClass_genbank
converted genbank
constexpr auto front(list< Head, As... >, T=T()) noexcept -> Head
constexpr bool empty(list< Ts... >) noexcept
#define fc
CConstRef< CSeq_id > GetBestId(const CBioseq &bioseq)
SAnnotSelector –.
Definition: type.c:6
#define _ASSERT
Modified on Mon Sep 25 00:50:50 2023 by modify_doxy.py rev. 669887