1 // $Id: ui_vars_traitmodels.h,v 1.10 2012/01/05 01:28:42 ewalkup Exp $
2 
3 /*
4  *  Copyright 2004  Peter Beerli, Mary Kuhner, Jon Yamato and Joseph Felsenstein
5  *
6  *  This software is distributed free of charge for non-commercial use
7  *  and is copyrighted.  Of course, we do not guarantee that the software
8  *  works, and are not responsible for any damage you may cause or have.
9  *
10  */
11 
12 #ifndef UI_VARS_TRAITMODELS_H
13 #define UI_VARS_TRAITMODELS_H
14 
15 #include "datatype.h"           // for data_type
16 #include "phenotypes.h"
17 #include "rangex.h"
18 #include "ui_vars_component.h"
19 
20 class UIRegId;
21 
22 enum mloc_type {mloc_data, mloc_mapjump, mloc_mapfloat, mloc_partition};
23 
24 string ToString(mloc_type);
25 string ToXMLString(mloc_type);
26 mloc_type ProduceMlocTypeOrBarf(const string& in);
27 
28 class UIVarsSingleTraitModel
29 {
30   private:
31     UIVarsSingleTraitModel();    // undefined
32     long m_region;
33     long m_locus;
34     data_type m_datatype;
35     mloc_type m_type;
36     rangeset m_range;
37     rangepair m_fullrange;
38     string m_name;
39     Phenotypes m_phenotypes;
40     long m_multihapnum;
41 
42   public:
43     UIVarsSingleTraitModel(UIRegId regionId, string name, rangeset mrange,
44                            rangepair fullrange, const Locus* locus,
45                            long multihapnum);
46     virtual ~UIVarsSingleTraitModel();
47     //Setters
48     void SetAnalysisType(mloc_type type);
49     void SetRange(rangeset range);
50     void AddPhenotype(StringVec1d& alleles, string name, double penetrance);
51 
52     //Getters
GetAnalysisType()53     mloc_type GetAnalysisType() const {return m_type;};
GetRange()54     rangeset  GetRange() const {return m_range;};
GetFullRange()55     rangepair GetFullRange() const {return m_fullrange;};
GetName()56     string    GetName()  const {return m_name;};
GetPhenotypes()57     Phenotypes GetPhenotypes() const {return m_phenotypes;};
GetMultiHapNum()58     long      GetMultiHapNum() const {return m_multihapnum;};
59 };
60 
61 class UIVarsTraitModels : public UIVarsComponent
62 {
63   private:
64     UIVarsTraitModels();  // undefined
65     UIVarsTraitModels(const UIVarsTraitModels&); // undefined
66     std::map<UIRegId, UIVarsSingleTraitModel>   m_individualModels;
67 
68   public:
69     UIVarsTraitModels(UIVars*);
70     UIVarsTraitModels(UIVars*, const UIVarsTraitModels&);
71     virtual ~UIVarsTraitModels();
72 
73     void AddTraitModel(UIRegId regID);
74 
75     //Setters
76     void SetAnalysisType(UIRegId regID, mloc_type type);
77     void AddRange(UIRegId regID, rangepair addpart);
78     void RemoveRange(UIRegId regID, rangepair removepart);
79     void SetRangeToPoint(UIRegId regID, long site);
80     void AddPhenotype(UIRegId regID, StringVec1d& alleles, string name, double penetrance);
81     //Note:  AddPhenotype is currently only called from the XML.
82 
83     //Getters
84     long GetNumMovableLoci() const;
85     mloc_type GetAnalysisType(UIRegId regID) const;
86     rangeset GetRange(UIRegId regID) const;
87     long GetInitialMapPosition(UIRegId regID) const;
88     string   GetName(UIRegId regID) const;
89     Phenotypes GetPhenotypes(UIRegId regID) const;
90     vector<UIRegId> GetRegIDs() const;
91     bool AnyJumpingAnalyses() const;
92     bool AnyMappingAnalyses() const;
93     void SetRange(UIRegId regID, rangeset rset);
94 
95   private:
96     bool OneSite(rangeset rset);
97 };
98 
99 #endif  // UI_VARS_TRAITMODELS_H
100 
101 //____________________________________________________________________________________
102