root/trunk/FRII/gui/Feature.hh

Revision 10, 2.0 kB (checked in by t, 3 years ago)

Tailorization
Import of the upstream sources from

Repository: :pserver:anonymous@cvs.sf.net:/cvsroot/familyjewels

Kind: cvs

Module: FRII

Revision: 2005-12-09 09:00:54 by titus

Original author: tailor@vallista.idyll.org
Date: 2005-12-09 09:00:54

Line 
1 /*
2  * This file is part of the FamilyRelations II source distribution.
3  *
4  * FamilyRelations II is part of the FamilyJewels package for comparative
5  * sequence analysis: http://family.caltech.edu/.
6  *
7  * Contact author: C. Titus Brown, titus@caltech.edu.
8  *
9  * This program and all associated source code files are Copyright (C) 2003,
10  * 2004 the California Institute of Technology, Pasadena, CA, 91125 USA.  It
11  * is under the Lesser GNU Public License; please see the included
12  * LICENSE.txt file for more information, or contact Titus directly.
13  *
14  */
15
16 // Feature, on one sequence, possibly with a reference to another sequence
17 // and an attached alignment.
18
19 #ifndef FEATURE_HH // protect against multiple includes
20 #define FEATURE_HH
21
22 #include <string>
23
24 namespace gui {
25   class Feature {
26   protected:
27     Feature * _other;
28     std::string top_aln, bot_aln;
29     std::string _info;
30   public:
31     const unsigned int start, end;
32     const int orientation;
33     Feature(unsigned int s, unsigned int e, int o) :
34       _other(NULL), start(s), end(e), orientation(o)
35            { ; }
36
37     void other(int s, int e) {
38       _other = new Feature(s, e, 1);
39     }
40     const Feature * other() const { return _other; }
41
42     const std::string information() const { return _info; }
43     void add_information(std::string i) { _info += i; }
44     bool has_info() const { return (_info.length() > 0); }
45
46     void set_alignment(std::string top, std::string bot) {
47       top_aln = top;
48       bot_aln = bot;
49     }
50     void get_alignment(std::string &top, std::string &bot) const {
51       top = top_aln;
52       bot = bot_aln;
53     }
54
55     Feature * copy_me() const {
56       Feature * new_f = new Feature(start, end, orientation);
57       if (_other) {
58         new_f->_other = _other->copy_me();
59       }
60       new_f->set_alignment(top_aln, bot_aln);
61       new_f->_info = _info;
62
63       return new_f;
64     }
65
66     bool has_alignment() const {
67       if (_other && top_aln.length() && bot_aln.length()) {
68         return true;
69       }
70       return false;
71     }
72
73     virtual ~Feature() { if (_other) delete _other; }
74   };
75 }
76
77 #endif // FEATURE_HH
78
Note: See TracBrowser for help on using the browser.