| 1 | // Copyright (C) 1999-2003 Paul O. Lewiscxx . . $ `<file>/ncl/nxsdiscretedatum.h`/ |
| 2 | // |
| 3 | // This file is part of NCL (Nexus Class Library) version 2.0. |
| 4 | // |
| 5 | // NCL is free software; you can redistribute it and/or modify |
| 6 | // it under the terms of the GNU General Public License as published by |
| 7 | // the Free Software Foundation; either version 2 of the License, or |
| 8 | // (at your option) any later version. |
| 9 | // |
| 10 | // NCL is distributed in the hope that it will be useful, |
| 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | // GNU General Public License for more details. |
| 14 | // |
| 15 | // You should have received a copy of the GNU General Public License |
| 16 | // along with NCL; if not, write to the Free Software Foundation, Inc., |
| 17 | // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 | // |
| 19 | |
| 20 | #ifndef NCL_NXSDISCRETEDATUM_H |
| 21 | #define NCL_NXSDISCRETEDATUM_Hcxx . . $ `ncl/nxsdiscretedatum.h:21:9`! |
| 22 | |
| 23 | /*---------------------------------------------------------------------------------------------------------------------- |
| 24 | | Class for holding discrete states in a matrix. Note that there is no way to access the variables of this class |
| 25 | | since they are all private and there are no public access functions. This class is designed to be manipulated by |
| 26 | | the class NxsDiscreteMatrix, which is the only class that has been designated a friend of NxsDiscreteDatum. |
| 27 | | The variable `states' is NULL if there is missing data, and non-NULL for any other state. If `states' is non-NULL, |
| 28 | | the first cell is used to store the number of states. This will be 0 if the state is the gap state, 1 if the state |
| 29 | | is unambiguous and nonpolymorphic (and not the gap state of course), and 2 or higher if there is either |
| 30 | | polymorphism or uncertainty. If polymorphism or uncertainty apply, it becomes necessary to store information about |
| 31 | | which of these two situations holds. Thus, the last cell in the array is set to either 1 (polymorphism) or 0 |
| 32 | | (uncertainty). While a little complicated, this scheme has the following benefits: |
| 33 | |~ |
| 34 | | o if the state is missing, the only memory allocated is for a pointer (`states') |
| 35 | | o if the state is unambiguous and not polymorphic, no storage is used for keeping track of whether polymorphism or |
| 36 | | uncertainty holds |
| 37 | | o it allows for a virtually unlimited number of states, which is important if it is to be general enough to store |
| 38 | | microsatellite data for a NxsAllelesBlock object, for example. |
| 39 | |~ |
| 40 | | Supposing the gap symbol is '-', the missing data symbol is '?', and the symbols list is "ACGT", the following |
| 41 | | table shows the status of the states variable under several different possible data matrix entries: |
| 42 | |> |
| 43 | | Matrix entry states array |
| 44 | | -------------------------------- |
| 45 | | ? NULL |
| 46 | | - [0] |
| 47 | | G [1][2] |
| 48 | | (AG) polymorphic [2][0][2][1] |
| 49 | | {AG} ambiguous [2][0][2][0] |
| 50 | | -------------------------------- |
| 51 | |> |
| 52 | */ |
| 53 | class NxsDiscreteDatumcxx . . $ NxsDiscreteDatum# |
| 54 | { |
| 55 | friend class NxsDiscreteMatrixcxx . . $ NxsDiscreteMatrix#; |
| 56 | |
| 57 | public: |
| 58 | |
| 59 | NxsDiscreteDatumcxx . . $ NxsDiscreteDatum#NxsDiscreteDatum(49f6e7a06ebc5aa8).(); |
| 60 | virtual ~cxx . . $ NxsDiscreteDatum#`~NxsDiscreteDatum`(49f6e7a06ebc5aa8).NxsDiscreteDatumcxx . . $ NxsDiscreteDatum#(); |
| 61 | |
| 62 | void CopyFromcxx . . $ NxsDiscreteDatum#CopyFrom(fe00b40239823368).(const NxsDiscreteDatumcxx . . $ NxsDiscreteDatum# &other); |
| 63 | |
| 64 | private: |
| 65 | |
| 66 | unsigned *statescxx . . $ NxsDiscreteDatum#states.; /* holds information about state for a single taxon-character combination */ |
| 67 | }; |
| 68 | |
| 69 | typedef NxsDiscreteDatumcxx . . $ NxsDiscreteDatum# DiscreteDatumcxx . . $ DiscreteDatum#; |
| 70 | |
| 71 | #endif |