1 // $Id: phenotypes.h,v 1.4 2011/03/07 06:08:49 bobgian Exp $
2 
3 /*
4   Copyright 2006  Lucian Smith, 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 #ifndef PHENOTYPES_H
12 #define PHENOTYPES_H
13 
14 #include "haplotypes.h"
15 #include <string>
16 #include <vector>
17 #include <set>
18 #include <map>
19 
20 class Phenotypes
21 {
22   private:
23     Phenotypes(); //undefined
24     //The parent.  Needed to give to the haplotypes to make DLCells.
25     long m_regionnum;
26     string m_locusname;
27 
28     // m_phenomap is a map of a set of alleles (as strings) to a vector of
29     //  phenotype names and a vector of phenotype penetrances.  This is stored
30     //  as a pair of vectors instead of a vector of pairs so that we can take
31     //  the vector of penetrances and scale it to sum to one before using it
32     //  to create actual haplotypes.
33     //
34     // So, to sum up:  map<alleles, pair<NameVector, PenetranceVector> >
35     std::map<std::multiset<std::string>, std::pair<std::vector<std::string>, std::vector<double> > > m_phenomap;
36 
37     // m_hapsmap is a map of phenotype names to a Haplotypes object.  When we
38     // find out that an individual has a particular phenotype, we give it
39     // the Haplotypes object (this will normally happen due to simulation)
40     std::map<std::string, Haplotypes> m_hapsmap;
41 
42     //Private function to convert the m_phenomap into m_hapsmap.
43     void MakeHaplotypes();
44     std::multiset<std::string> VecToSet(StringVec1d vec);
45 
46   public:
47     Phenotypes(long regionnum, string lname);
48     Phenotypes(string lname); //A blank copy.
~Phenotypes()49     ~Phenotypes() {};
50     //We accept the default for:
51     //Phenotypes& operator=(const Phenotypes& src);
52     //Phenotypes(const Phenotypes& src);
53 
54     void AddPhenotype(const StringVec1d& alleles, string name, double penetrance);
55     Haplotypes ChooseHaplotypes(const StringVec1d& alleles);
56     Haplotypes GetHaplotypes(string phenotypeName);
57     StringVec1d GetPhenotypesXML(long nspaces) const;
AnyDefinedPhenotypes()58     bool AnyDefinedPhenotypes() const {return (m_phenomap.size()>0);};
59 };
60 
61 #endif // PHENOTYPES_H
62 
63 //____________________________________________________________________________________
64