1 /* $Id: SeqFeatData.hpp 625152 2021-02-09 16:01:45Z ivanov $
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 * Author: .......
27 *
28 * File Description:
29 * .......
30 *
31 * Remark:
32 * This code was originally generated by application DATATOOL
33 * using specifications from the ASN data definition file
34 * 'seqfeat.asn'.
35 *
36 * NOTE TO DEVELOPERS:
37 * The Seq-feat structure in 'seqfeat.asn' is subtyped into various
38 * more specialized structures by the content of the Seqfeat::data
39 * item. Depending on what is in the data item, other fields in
40 * Seq-feat (the ones marked optional in the ASN) are allowed or
41 * prohibited from being present. This file lists the possible
42 * subtypes of Seq-feat, along with the qualifiers that can occur
43 * within the Seq-feat structure.
44 *
45 * WHEN EDITING THE LIST OF QUALIFIERS (i.e. the EQualifier enum):
46 * - add or remove the qualifier to the various lists that define which
47 * qualifiers are legal for a given subtype
48 * (in src/objects/seqfeat/SeqFeatData.cpp),
49 * - add or remove the qualifier to the list of qualifiers known by the
50 * flatfile generator
51 * (in include/objtools/format/items/flat_qual_slots.hpp),
52 * - add or remove processing code in the flat-file generator
53 * (src/objtools/format/feature_item.cpp). This may well necessitate
54 * the addition or removal of a class that knows how to format the
55 * new qualifier for display; look at the code for a similar
56 * established qualifier for an idea of what needs to be done
57 * (check WHEN EDITING THE LIST OF QUALIFIERS comment in that file
58 * for additional hints),
59 * - add or remove the qualifier to the list of qualifiers known to
60 * the feature table reader (in src/objtools/readers/readfeat.cpp);
61 * it's an independent project with its own book-keeping concerning
62 * qualifiers, but needs to be kept in sync,
63 * - make sure corresponding code gets added to the validator
64 * (in src/objtools/validator/...) which is another project with an
65 * independent qualifier list that nonetheless needs to stay in sync,
66 * - (additional subitems to be added as I become aware of them).
67 *
68 * FEATURE REPRESENTATION:
69 * Although GenBank allows numerous kinds of features, certain types
70 * (Gene, Coding Region, Protein, and RNA) directly model the central
71 * dogma of molecular biology, and are designed to be used in making
72 * connections between records and in discovering new information by
73 * computation. Other features are stored as Import features, where
74 * the feature key is taken directly from the GenBank name. There are
75 * a few cases where the names can be confusing, and in each case the
76 * structured feature is normally used instead of the Import feature:
77 *
78 * - CDS uses eSubtype_cdregion instead of eSubtype_Imp_CDS.
79 * - processed proteins use the "_aa" versions:
80 * eSubtype_mat_peptide_aa instead of eSubtype_mat_peptide.
81 * eSubtype_sig_peptide_aa instead of eSubtype_sig_peptide.
82 * eSubtype_transit_peptide_aa instead of eSubtype_transit_peptide.
83 * - misc_RNA uses eSubtype_otherRNA instead of eSubtype_misc_RNA.
84 * - precursor_RNA uses eSubtype_preRNA instead of eSubtype_precursor_RNA.
85 *
86 */
87
88 #ifndef OBJECTS_SEQFEAT_SEQFEATDATA_HPP
89 #define OBJECTS_SEQFEAT_SEQFEATDATA_HPP
90
91
92 // generated includes
93 #include <objects/seqfeat/SeqFeatData_.hpp>
94 #include <set>
95
96 #include <corelib/ncbistr.hpp>
97 #include <util/static_map.hpp>
98 #include <array>
99 #include <util/compile_time.hpp>
100
101 // generated classes
102
103 BEGIN_NCBI_SCOPE
104
105 BEGIN_objects_SCOPE // namespace ncbi::objects::
106
107 class CFeatList;
108 class CBondList;
109 class CSiteList;
110 class CGb_qual;
111
112 class NCBI_SEQFEAT_EXPORT CSeqFeatData : public CSeqFeatData_Base
113 {
114 typedef CSeqFeatData_Base Tparent;
115 public:
116 /// constructor
117 CSeqFeatData(void);
118 /// destructor
119 ~CSeqFeatData(void);
120
121 /// ASCII representation of subtype (GenBank feature key, e.g.)
122 enum EVocabulary {
123 eVocabulary_full,
124 eVocabulary_genbank
125 };
126 string GetKey(EVocabulary vocab = eVocabulary_full) const;
127
128 enum ESubtype {
129 /// These no longer need to match the FEATDEF values in the
130 /// C toolkit's objfdef.h
131 eSubtype_bad = 0,
132 eSubtype_gene = 1,
133 eSubtype_org = 2,
134 eSubtype_cdregion = 3,
135 eSubtype_prot = 4,
136 eSubtype_preprotein = 5,
137 eSubtype_mat_peptide_aa = 6, // Prot-ref mat_peptide
138 eSubtype_sig_peptide_aa = 7, // Prot-ref sig_peptide
139 eSubtype_transit_peptide_aa = 8, // Prot-ref transit_peptide
140 eSubtype_preRNA = 9, // RNA-ref precursor_RNA
141 eSubtype_mRNA = 10,
142 eSubtype_tRNA = 11,
143 eSubtype_rRNA = 12,
144 eSubtype_snRNA = 13,
145 eSubtype_scRNA = 14,
146 eSubtype_snoRNA = 15,
147 eSubtype_otherRNA = 16, // RNA-ref misc_RNA
148 eSubtype_pub = 17,
149 eSubtype_seq = 18,
150 eSubtype_imp = 19,
151 eSubtype_allele = 20,
152 eSubtype_attenuator = 21,
153 eSubtype_C_region = 22,
154 eSubtype_CAAT_signal = 23,
155 eSubtype_Imp_CDS = 24, // use eSubtype_cdregion for CDS
156 eSubtype_conflict = 25,
157 eSubtype_D_loop = 26,
158 eSubtype_D_segment = 27,
159 eSubtype_enhancer = 28,
160 eSubtype_exon = 29,
161 eSubtype_EC_number = 30,
162 eSubtype_GC_signal = 31,
163 eSubtype_iDNA = 32,
164 eSubtype_intron = 33,
165 eSubtype_J_segment = 34,
166 eSubtype_LTR = 35,
167 eSubtype_mat_peptide = 36, // use eSubtype_mat_peptide_aa
168 eSubtype_misc_binding = 37,
169 eSubtype_misc_difference = 38,
170 eSubtype_misc_feature = 39,
171 eSubtype_misc_recomb = 40,
172 eSubtype_misc_RNA = 41, // use eSubtype_otherRNA for misc_RNA
173 eSubtype_misc_signal = 42,
174 eSubtype_misc_structure = 43,
175 eSubtype_modified_base = 44,
176 eSubtype_mutation = 45,
177 eSubtype_N_region = 46,
178 eSubtype_old_sequence = 47,
179 eSubtype_polyA_signal = 48,
180 eSubtype_polyA_site = 49,
181 eSubtype_precursor_RNA = 50, // use eSubtype_preRNA for precursor_RNA
182 eSubtype_prim_transcript = 51,
183 eSubtype_primer_bind = 52,
184 eSubtype_promoter = 53,
185 eSubtype_protein_bind = 54,
186 eSubtype_RBS = 55,
187 eSubtype_repeat_region = 56,
188 eSubtype_repeat_unit = 57,
189 eSubtype_rep_origin = 58,
190 eSubtype_S_region = 59,
191 eSubtype_satellite = 60,
192 eSubtype_sig_peptide = 61, // use eSubtype_sig_peptide_aa
193 eSubtype_source = 62,
194 eSubtype_stem_loop = 63,
195 eSubtype_STS = 64,
196 eSubtype_TATA_signal = 65,
197 eSubtype_terminator = 66,
198 eSubtype_transit_peptide = 67, // use eSubtype_transit_peptide_aa
199 eSubtype_unsure = 68,
200 eSubtype_V_region = 69,
201 eSubtype_V_segment = 70,
202 eSubtype_variation = 71, //< old variation (data.imp)
203 eSubtype_virion = 72,
204 eSubtype_3clip = 73,
205 eSubtype_3UTR = 74,
206 eSubtype_5clip = 75,
207 eSubtype_5UTR = 76,
208 eSubtype_10_signal = 77,
209 eSubtype_35_signal = 78,
210 eSubtype_gap = 79,
211 eSubtype_operon = 80,
212 eSubtype_oriT = 81,
213 eSubtype_site_ref = 82,
214 eSubtype_region = 83,
215 eSubtype_comment = 84,
216 eSubtype_bond = 85,
217 eSubtype_site = 86,
218 eSubtype_rsite = 87,
219 eSubtype_user = 88,
220 eSubtype_txinit = 89,
221 eSubtype_num = 90,
222 eSubtype_psec_str = 91,
223 eSubtype_non_std_residue = 92,
224 eSubtype_het = 93,
225 eSubtype_biosrc = 94,
226 eSubtype_ncRNA = 95,
227 eSubtype_tmRNA = 96,
228 eSubtype_clone = 97,
229 eSubtype_variation_ref = 98, //< new variation (data.variant)
230 eSubtype_mobile_element = 99,
231 eSubtype_centromere = 100,
232 eSubtype_telomere = 101,
233 eSubtype_assembly_gap = 102,
234 eSubtype_regulatory = 103,
235 eSubtype_propeptide = 104, // use eSubtype_propeptide_aa
236 eSubtype_propeptide_aa = 105, // Prot-ref propeptide
237 eSubtype_max = 106,
238 eSubtype_any = 255
239 };
240 ESubtype GetSubtype(void) const;
241
242 /// Call after changes that could affect the subtype
243 void InvalidateSubtype(void) const;
244
245 /// Combine invalidation of all cached values
246 void InvalidateCache(void) const;
247
248 /// Override all setters to incorporate cache invalidation.
249 #define DEFINE_NCBI_SEQFEATDATA_VAL_SETTERS(x) \
250 void Set##x(const T##x& v) { \
251 InvalidateCache(); \
252 Tparent::Set##x(v); \
253 } \
254 T##x& Set##x(void) { \
255 InvalidateCache(); \
256 return Tparent::Set##x(); \
257 }
258 #define DEFINE_NCBI_SEQFEATDATA_SETTERS(x) \
259 void Set##x(T##x& v) { \
260 InvalidateCache(); \
261 Tparent::Set##x(v); \
262 } \
263 T##x& Set##x(void) { \
264 InvalidateCache(); \
265 return Tparent::Set##x(); \
266 }
267
268 DEFINE_NCBI_SEQFEATDATA_SETTERS(Gene)
DEFINE_NCBI_SEQFEATDATA_SETTERS(Org)269 DEFINE_NCBI_SEQFEATDATA_SETTERS(Org)
270 DEFINE_NCBI_SEQFEATDATA_SETTERS(Cdregion)
271 DEFINE_NCBI_SEQFEATDATA_SETTERS(Prot)
272 DEFINE_NCBI_SEQFEATDATA_SETTERS(Rna)
273 DEFINE_NCBI_SEQFEATDATA_SETTERS(Pub)
274 DEFINE_NCBI_SEQFEATDATA_SETTERS(Seq)
275 DEFINE_NCBI_SEQFEATDATA_SETTERS(Imp)
276 DEFINE_NCBI_SEQFEATDATA_VAL_SETTERS(Region)
277 void SetComment(void) {
278 InvalidateCache();
279 Tparent::SetComment();
280 }
281 DEFINE_NCBI_SEQFEATDATA_VAL_SETTERS(Bond)
282 DEFINE_NCBI_SEQFEATDATA_VAL_SETTERS(Site)
283 DEFINE_NCBI_SEQFEATDATA_SETTERS(Rsite)
284 DEFINE_NCBI_SEQFEATDATA_SETTERS(User)
285 DEFINE_NCBI_SEQFEATDATA_SETTERS(Txinit)
286 DEFINE_NCBI_SEQFEATDATA_SETTERS(Num)
287 DEFINE_NCBI_SEQFEATDATA_VAL_SETTERS(Psec_str)
288 DEFINE_NCBI_SEQFEATDATA_VAL_SETTERS(Non_std_residue)
289 DEFINE_NCBI_SEQFEATDATA_SETTERS(Het)
290 DEFINE_NCBI_SEQFEATDATA_SETTERS(Biosrc)
291 DEFINE_NCBI_SEQFEATDATA_SETTERS(Clone)
292 DEFINE_NCBI_SEQFEATDATA_SETTERS(Variation)
293
294 #undef DEFINE_NCBI_SEQFEATDATA_SETTERS
295 #undef DEFINE_NCBI_SEQFEATDATA_VAL_SETTERS
296
297 /// Override Assign() to incorporate cache invalidation.
298 virtual void Assign(const CSerialObject& source,
299 ESerialRecursionMode how = eRecursive);
300
301 /// Invalidate subtype cache after deserialization
302 void PostRead(void) const;
303
304 static E_Choice GetTypeFromSubtype (ESubtype subtype);
305 /// Turns a ESubtype into its string value which is NOT necessarily
306 /// related to the identifier of the enum.
307 ///
308 /// @return
309 /// empty string on bad input
310 static CTempString SubtypeValueToName(ESubtype eSubtype);
311 /// Turn a string into its ESubtype which is NOT necessarily
312 /// related to the identifier of the enum.
313 ///
314 /// @return
315 /// eSubtype_bad on bad input
316 static ESubtype SubtypeNameToValue(CTempString sName);
317
318
319 static bool CanHaveGene(ESubtype subtype);
320
321 /// List of available qualifiers for feature keys.
322 /// For more information see:
323 /// The DDBJ/EMBL/GenBank Feature Table: Definition
324 /// (http://www.ncbi.nlm.nih.gov/projects/collab/FT/index.html)
325 enum EQualifier
326 {
327 eQual_bad = 0,
328 eQual_allele,
329 eQual_altitude,
330 eQual_anticodon,
331 eQual_artificial_location,
332 eQual_bio_material,
333 eQual_bond_type,
334 eQual_bound_moiety,
335 eQual_calculated_mol_wt,
336 eQual_cell_line,
337 eQual_cell_type,
338 eQual_chloroplast,
339 eQual_chromoplast,
340 eQual_chromosome,
341 eQual_circular_RNA,
342 eQual_citation,
343 eQual_clone,
344 eQual_clone_lib,
345 eQual_coded_by,
346 eQual_codon,
347 eQual_codon_start,
348 eQual_collected_by,
349 eQual_collection_date,
350 eQual_compare,
351 eQual_cons_splice,
352 eQual_country,
353 eQual_cultivar,
354 eQual_culture_collection,
355 eQual_cyanelle,
356 eQual_db_xref,
357 eQual_derived_from,
358 eQual_dev_stage,
359 eQual_direction,
360 eQual_EC_number,
361 eQual_ecotype,
362 eQual_environmental_sample,
363 eQual_estimated_length,
364 eQual_evidence,
365 eQual_exception,
366 eQual_experiment,
367 eQual_focus,
368 eQual_frequency,
369 eQual_function,
370 eQual_gap_type,
371 eQual_gdb_xref,
372 eQual_gene,
373 eQual_gene_synonym,
374 eQual_germline,
375 eQual_haplogroup,
376 eQual_haplotype,
377 eQual_heterogen,
378 eQual_host,
379 eQual_identified_by,
380 eQual_inference,
381 eQual_insertion_seq,
382 eQual_isolate,
383 eQual_isolation_source,
384 eQual_kinetoplast,
385 eQual_lab_host,
386 eQual_label,
387 eQual_lat_lon,
388 eQual_linkage_evidence,
389 eQual_linkage_group,
390 eQual_locus_tag,
391 eQual_macronuclear,
392 eQual_map,
393 eQual_mating_type,
394 eQual_metagenome_source,
395 eQual_metagenomic,
396 eQual_mitochondrion,
397 eQual_mobile_element,
398 eQual_mobile_element_type,
399 eQual_mod_base,
400 eQual_mol_type,
401 eQual_name,
402 eQual_nomenclature,
403 eQual_non_std_residue,
404 eQual_ncRNA_class,
405 eQual_note,
406 eQual_number,
407 eQual_old_locus_tag,
408 eQual_operon,
409 eQual_organelle,
410 eQual_organism,
411 eQual_partial,
412 eQual_PCR_conditions,
413 eQual_PCR_primers,
414 eQual_phenotype,
415 eQual_plasmid,
416 eQual_pop_variant,
417 eQual_product,
418 eQual_protein_id,
419 eQual_proviral,
420 eQual_pseudo,
421 eQual_pseudogene,
422 eQual_rearranged,
423 eQual_recombination_class,
424 eQual_region_name,
425 eQual_regulatory_class,
426 eQual_replace,
427 eQual_ribosomal_slippage,
428 eQual_rpt_family,
429 eQual_rpt_type,
430 eQual_rpt_unit,
431 eQual_rpt_unit_range,
432 eQual_rpt_unit_seq,
433 eQual_satellite,
434 eQual_sec_str_type,
435 eQual_segment,
436 eQual_sequenced_mol,
437 eQual_serotype,
438 eQual_serovar,
439 eQual_sex,
440 eQual_site_type,
441 eQual_specimen_voucher,
442 eQual_standard_name,
443 eQual_strain,
444 eQual_submitter_seqid,
445 eQual_sub_clone,
446 eQual_sub_species,
447 eQual_sub_strain,
448 eQual_tag_peptide,
449 eQual_tissue_lib,
450 eQual_tissue_type,
451 eQual_trans_splicing,
452 eQual_transcript_id,
453 eQual_transgenic,
454 eQual_translation,
455 eQual_transl_except,
456 eQual_transl_table,
457 eQual_transposon,
458 eQual_type_material,
459 eQual_UniProtKB_evidence,
460 eQual_usedin,
461 eQual_variety,
462 eQual_virion,
463 eQual_whole_replicon
464 };
465
466 using TLegalQualifiers = ct::const_bitset<eQual_whole_replicon + 1, EQualifier>;
467 using TSubtypes = ct::const_bitset<eSubtype_max, ESubtype>;
468 using TQualifiers = TLegalQualifiers;
469 using TSubTypeQualifiersMap = ct::const_unordered_map<ESubtype, TQualifiers>;
470
471 /// Test wheather a certain qualifier is legal for the feature
472 bool IsLegalQualifier(EQualifier qual) const;
473 static bool IsLegalQualifier(ESubtype subtype, EQualifier qual);
474
475 /// Get a list of all the legal qualifiers for the feature.
476 const TLegalQualifiers& GetLegalQualifiers(void) const;
477 static const TLegalQualifiers& GetLegalQualifiers(ESubtype subtype);
478
479 /// Get the list of all mandatory qualifiers for the feature.
480 const TQualifiers& GetMandatoryQualifiers(void) const;
481 static const TQualifiers& GetMandatoryQualifiers(ESubtype subtype);
482
483 /// Convert a qualifier from an enumerated value to a string representation
484 /// or empty if not found.
485 static CTempString GetQualifierAsString(EQualifier qual);
486
487 /// convert qual string to enumerated value
488 static EQualifier GetQualifierType(CTempString qual);
489 static std::pair<EQualifier, CTempString> GetQualifierTypeAndValue(CTempString qual);
490
491 static const CFeatList* GetFeatList();
492 static const CBondList* GetBondList();
493 static const CSiteList* GetSiteList();
494
495 static bool IsRegulatory(ESubtype subtype);
496 static const string & GetRegulatoryClass(ESubtype subtype);
497 static ESubtype GetRegulatoryClass(const string & class_name );
498 static const vector<string>& GetRegulatoryClassList();
499 static bool FixRegulatoryClassValue(string& val);
500
501 static const vector<string>& GetRecombinationClassList();
502
503 static bool IsDiscouragedSubtype(ESubtype subtype);
504 static bool IsDiscouragedQual(EQualifier qual);
505
506 enum EFeatureLocationAllowed {
507 eFeatureLocationAllowed_Any = 0,
508 eFeatureLocationAllowed_Error,
509 eFeatureLocationAllowed_NucOnly,
510 eFeatureLocationAllowed_ProtOnly,
511 };
512
513 static EFeatureLocationAllowed AllowedFeatureLocation(ESubtype subtype);
514
515 static bool AllowStrandBoth(ESubtype subtype);
516 static bool RequireLocationIntervalsInBiologicalOrder(ESubtype subtype);
517 static bool AllowAdjacentIntervals(ESubtype subtype);
518
519 static bool ShouldRepresentAsGbqual (CSeqFeatData::ESubtype feat_subtype, const CGb_qual& qual);
520 static bool ShouldRepresentAsGbqual (CSeqFeatData::ESubtype feat_subtype, CSeqFeatData::EQualifier qual_type);
521
522 static void s_InitXrefAllowedSubtypesTable(void);
523 static void s_InitXrefProhibitedSubtypesTable(void);
524 static bool AllowXref(CSeqFeatData::ESubtype subtype1, CSeqFeatData::ESubtype subtype2);
525 static bool ProhibitXref(CSeqFeatData::ESubtype subtype1, CSeqFeatData::ESubtype subtype2);
526
527 static bool FixImportKey(string& key);
528
529 // Internal structure to hold additional info
530 struct SFeatDataInfo
531 {
532 CSeqFeatData::ESubtype m_Subtype;
533 const char* m_Key_full;
534 const char* m_Key_gb;
535 };
536
537 private:
538 void x_InitFeatDataInfo(void) const;
539
540 mutable SFeatDataInfo m_FeatDataInfo; // cached
541
542 static void s_InitSubtypesTable(void);
543 static const TSubTypeQualifiersMap& s_GetLegalQualMap() noexcept;
544
545 // Prohibit copy constructor and assignment operator
546 CSeqFeatData(const CSeqFeatData& value);
547 CSeqFeatData& operator=(const CSeqFeatData& value);
548
549 typedef CStaticArraySet<ESubtype> TSubtypeSet;
550 static const TSubtypeSet & GetSetOfRegulatorySubtypes();
551 };
552
553
554 /////////////////// CSeqFeatData inline methods
555
556 inline
InvalidateSubtype(void) const557 void CSeqFeatData::InvalidateSubtype(void) const
558 {
559 m_FeatDataInfo.m_Subtype = eSubtype_any;
560 }
561
562
563 inline
InvalidateCache(void) const564 void CSeqFeatData::InvalidateCache(void) const
565 {
566 InvalidateSubtype(); // it's enough to invalidate all cached values
567 }
568
569
570 inline
IsLegalQualifier(EQualifier qual) const571 bool CSeqFeatData::IsLegalQualifier(EQualifier qual) const
572 {
573 return IsLegalQualifier(GetSubtype(), qual);
574 }
575
576
577 inline
GetLegalQualifiers(void) const578 const CSeqFeatData::TLegalQualifiers& CSeqFeatData::GetLegalQualifiers(void) const
579 {
580 return GetLegalQualifiers(GetSubtype());
581 }
582
583
584 inline
GetMandatoryQualifiers(void) const585 const CSeqFeatData::TQualifiers& CSeqFeatData::GetMandatoryQualifiers(void) const
586 {
587 return GetMandatoryQualifiers(GetSubtype());
588 }
589
590 /////////////////// end of CSeqFeatData inline methods
591
592
593
594
595 /// CFeatListItem - basic configuration data for one "feature" type.
596 /// "feature" expanded to include things that are not SeqFeats.
597 class NCBI_SEQFEAT_EXPORT CFeatListItem
598 {
599 public:
CFeatListItem()600 CFeatListItem() {}
CFeatListItem(int type,int subtype,const char * desc,const char * key)601 CFeatListItem(int type, int subtype, const char* desc, const char* key)
602 : m_Type(type)
603 , m_Subtype(subtype)
604 , m_Description(desc)
605 , m_StorageKey(key) {}
606
607 bool operator<(const CFeatListItem& rhs) const;
608
609 int GetType() const;
610 int GetSubtype() const;
611 string GetDescription() const;
612 string GetStoragekey() const;
613
614 private:
615 int m_Type = 0; ///< Feature type, or e_not_set for default values.
616 int m_Subtype = 0; ///< Feature subtype or eSubtype_any for default values.
617 string m_Description; ///< a string for display purposes.
618 string m_StorageKey; ///< a short string to use as a key or part of a key
619 ///< when storing a value by key/value string pairs.
620 };
621
622
623 // Inline methods.
624
625 inline
GetType() const626 int CFeatListItem::GetType() const
627 { return m_Type; }
628
629 inline
GetSubtype() const630 int CFeatListItem::GetSubtype() const
631 { return m_Subtype; }
632
633 inline
GetDescription() const634 string CFeatListItem::GetDescription() const
635 { return m_Description; }
636
637 inline
GetStoragekey() const638 string CFeatListItem::GetStoragekey() const
639 { return m_StorageKey; }
640
641
642 /// CConfigurableItems - a static list of items that can be configured.
643 ///
644 /// One can iterate through all items. Iterators dereference to CFeatListItem.
645 /// One can also get an item by type and subtype.
646
647 class NCBI_SEQFEAT_EXPORT CFeatList
648 {
649 private:
650 typedef set<CFeatListItem> TFeatTypeContainer;
651
652 public:
653
654 CFeatList();
655 ~CFeatList();
656
657 bool TypeValid(int type, int subtype) const;
658
659 /// can get all static information for one type/subtype.
660 bool GetItem(int type, int subtype, CFeatListItem& config_item) const;
661 bool GetItemBySubtype(int subtype, CFeatListItem& config_item) const;
662
663 bool GetItemByDescription(const string& desc, CFeatListItem& config_item) const;
664 bool GetItemByKey(const string& key, CFeatListItem& config_item) const;
665
666 /// Get the displayable description of this type of feature.
667 string GetDescription(int type, int subtype) const;
668
669 /// Get the feature's type and subtype from its description.
670 /// return true on success, false if type and subtype are not valid.
671 bool GetTypeSubType(const string& desc, int& type, int& subtype) const;
672
673 /// Get the key used to store this type of feature.
674 string GetStoragekey(int type, int subtype) const;
675 /// Get the key used to store this type of feature by only subtype.
676 string GetStoragekey(int subtype) const;
677
678 /// Get hierarchy of keys above this subtype, starting with "Master"
679 /// example, eSubtype_gene, will return {"Master", "Gene"}
680 /// but eSubtype_allele will return {"Master", "Import", "allele"}
681 vector<string> GetStoragekeys(int subtype) const;
682
683 /// return a list of all the feature descriptions for a menu or other control.
684 /// if hierarchical is true use in an Fl_Menu_ descendant to make hierarchical menus.
685 void GetDescriptions(
686 vector<string> &descs, ///> output, list of description strings.
687 bool hierarchical = false ///> make descriptions hierachical, separated by '/'.
688 ) const;
689
690 // Iteratable list of key values (type/subtype).
691 // can iterate through all values including defaults or with only
692 // real Feature types/subtypes.
693 typedef TFeatTypeContainer::const_iterator const_iterator;
694
695 size_t size() const;
696 const_iterator begin() const;
697 const_iterator end() const;
698 private:
699 /// initialize our container of feature types and descriptions.
700 void x_Init(void);
701
702 TFeatTypeContainer m_FeatTypes; ///> all valid types and subtypes.
703
704 typedef map<int, CFeatListItem> TSubtypeMap;
705 TSubtypeMap m_FeatTypeMap; ///> indexed by subtype only.
706
707 };
708
709
710 inline
size() const711 size_t CFeatList::size() const
712 {
713 return m_FeatTypes.size();
714 }
715
716
717 inline
begin() const718 CFeatList::const_iterator CFeatList::begin() const
719 {
720 return m_FeatTypes.begin();
721 }
722
723
724 inline
end() const725 CFeatList::const_iterator CFeatList::end() const
726 {
727 return m_FeatTypes.end();
728 }
729
730
731 class NCBI_SEQFEAT_EXPORT CBondList
732 {
733 public:
734 typedef SStaticPair<const char *, CSeqFeatData::EBond> TBondKey;
735
736 private:
737 typedef CStaticPairArrayMap<const char*, CSeqFeatData::EBond, PNocase_CStr> TBondMap;
738
739 public:
740
741 CBondList();
742 ~CBondList();
743
744 bool IsBondName (string str) const;
745 bool IsBondName (string str, CSeqFeatData::EBond& bond_type) const;
746 CSeqFeatData::EBond GetBondType (string str) const;
747
748 // Iteratable list of key values (type/subtype).
749 // can iterate through all values including defaults or with only
750 // real Feature types/subtypes.
751 typedef TBondMap::const_iterator const_iterator;
752
753 size_t size() const;
754 const_iterator begin() const;
755 const_iterator end() const;
756 private:
757 /// initialize our container of feature types and descriptions.
758 void x_Init(void);
759
760 DECLARE_CLASS_STATIC_ARRAY_MAP(TBondMap, sm_BondKeys);
761
762 };
763
764
765 inline
size() const766 size_t CBondList::size() const
767 {
768 return sm_BondKeys.size();
769 }
770
771
772 inline
begin() const773 CBondList::const_iterator CBondList::begin() const
774 {
775 return sm_BondKeys.begin();
776 }
777
778
779 inline
end() const780 CBondList::const_iterator CBondList::end() const
781 {
782 return sm_BondKeys.end();
783 }
784
785
786 class NCBI_SEQFEAT_EXPORT CSiteList
787 {
788 public:
789 typedef SStaticPair<const char *, CSeqFeatData::ESite> TSiteKey;
790
791 private:
792 typedef CStaticPairArrayMap<const char*, CSeqFeatData::ESite, PNocase_CStr> TSiteMap;
793
794 public:
795
796 CSiteList();
797 ~CSiteList();
798
799 bool IsSiteName (string str) const;
800 bool IsSiteName (string str, CSeqFeatData::ESite& site_type) const;
801 CSeqFeatData::ESite GetSiteType (string str) const;
802
803 // Iteratable list of key values (type/subtype).
804 // can iterate through all values including defaults or with only
805 // real Feature types/subtypes.
806 typedef TSiteMap::const_iterator const_iterator;
807
808 size_t size() const;
809 const_iterator begin() const;
810 const_iterator end() const;
811 private:
812 /// initialize our container of feature types and descriptions.
813 void x_Init(void);
814
815 DECLARE_CLASS_STATIC_ARRAY_MAP(TSiteMap, sm_SiteKeys);
816
817 };
818
819
820 inline
size() const821 size_t CSiteList::size() const
822 {
823 return sm_SiteKeys.size();
824 }
825
826
827 inline
begin() const828 CSiteList::const_iterator CSiteList::begin() const
829 {
830 return sm_SiteKeys.begin();
831 }
832
833
834 inline
end() const835 CSiteList::const_iterator CSiteList::end() const
836 {
837 return sm_SiteKeys.end();
838 }
839
840 NCBISER_HAVE_POST_READ(CSeqFeatData)
841
842
843 END_objects_SCOPE // namespace ncbi::objects::
844
845 END_NCBI_SCOPE
846
847
848 #endif // OBJECTS_SEQFEAT_SEQFEATDATA_HPP
849
850 /* Original file checksum: lines: 90, chars: 2439, CRC32: 742431cc */
851