Difference between revisions of "Public:CharacterModelObjectModel"

From Phyloinformatics
Jump to: navigation, search
 
Line 1: Line 1:
 
<pre>
 
<pre>
typedef string IDString; // used for fields that identify unique objects (and is hashable)
+
typedef string ID; // used for fields that identify unique objects (and is hashable)
  
 
/* Describes the specific category of an alphabet or which general category it  
 
/* Describes the specific category of an alphabet or which general category it  
Line 26: Line 26:
 
{
 
{
 
DatatypeEnum datatypeEnum;
 
DatatypeEnum datatypeEnum;
IDString id; /*  unique identifier */
+
ID id; /*  unique identifier */
 
Sequence<string> stateNames;  /* state labels (or "0", "1"... if the type is generic)*/
 
Sequence<string> stateNames;  /* state labels (or "0", "1"... if the type is generic)*/
 
Sequence<DatatypeTransformationRule> transformationRules;
 
Sequence<DatatypeTransformationRule> transformationRules;
Line 38: Line 38:
 
enum ParamValueEnum
 
enum ParamValueEnum
 
{
 
{
MARGINALIZED, FIXED, ESTIMATE;  
+
MARGINALIZED, FIXED, TO_ESTIMATE, ESTIMATED;  
 
};
 
};
  
Line 54: Line 54:
 
struct Parameter
 
struct Parameter
 
{
 
{
ParamIDString id;
+
ParamID id;
 
string name;
 
string name;
 
ParamScopeEnum scope;
 
ParamScopeEnum scope;
+
ParamValueEnum valueMeaning;
 +
 
 
double value;
 
double value;
 
Bound  lower;
 
Bound  lower;

Revision as of 16:47, 12 December 2006

typedef string ID; // used for fields that identify unique objects (and is hashable)

/* Describes the specific category of an alphabet or which general category it 
	falls under.
*/
enum DatatypeEnum {
        DNA_DATATYPE, //ACGT
        RNA_DATATYPE, //ACGU
        AA_DATATYPE, 
        CODON_DATATYPE, // AAA, AAC, AAG, AAT, ...

        CATEGORICAL_DATATYPE, // the generic code for discrete characters ("Standard" in NEXUS) 
        CONTINUOUS_DATATYPE,
        DISTANCE_DATATYPE,   // used for taxon to taxon distances (distances block in NEXUS)
        RESTRICTION_FRAGMENT
    };

typedef Sequence<int> AmbiguityCode;
struct DatatypeTransformationRule
	{
		Sequence< AmbiguityCode > mapping; // -1 means "drop this state"
	};

struct Datatype
	{
		DatatypeEnum datatypeEnum;
		ID id; /*  unique identifier */
		Sequence<string> stateNames;  /* state labels (or "0", "1"... if the type is generic)*/
		Sequence<DatatypeTransformationRule> transformationRules;
	};

enum ParamScopeEnum
	{
		GLOBAL, SUBSET, EDGE, EDGE_SUBSET;
	};

enum ParamValueEnum
	{
		MARGINALIZED, FIXED, TO_ESTIMATE, ESTIMATED; 
	};

enum BoundTypeEnum
	{
		NONE, OPEN, CLOSED; 
	};
	
struct Bound
	{
		BoundTypeEnum   type;
		double			value;
	};
	
struct Parameter
	{
		ParamID id;
		string name;
		ParamScopeEnum scope;
		ParamValueEnum valueMeaning;

		double value;
		Bound  lower;
		Bound  upper; 
	};

enum OpCodeEnum 
	{
		PARAMETER, NEGATE, ADDITION, DIVISION, MULTIPLICATION, SUBTRACTION;
    };
    
struct ExpressionTerm
	{
		OpCodeEnum	opCode;
		IDString	paramRef; // id of the parameter 
	};
	
struct Expression
	{
		ExprIDString	id;
		Sequence<ExpressionTerm> expr; // reverse polish notation
	};

struct ProbabilityDensity
	{
		
	};

struct Prior
	{
		ProbabilityDensity dist;
		Sequence<ParamIDString> parameters;
	};

enum ParamConstraintEnum
	{
		SUM_EQUALS_VALUE, MEAN_EQUALS_VALUE;
	};
	
struct ParameterConstraint
	{
		ParamConstraintEnum paramConstraintEnum;
		double value;
		Sequence<ParamIDString> parameters;
	};

enum ModelDescriptionEnum
	{
		Q_MATRIX, //all expressions are in the QMatrix field of the DiscreteCharacterModel
		SYMM_COMPONENT_MATRIX, // 
		MIXTURE
		;
	};

struct DiscreteCharacterModel
	{
		IDString	datatypeReference; /* Describes the type of data that the model can be applied to.
											a datatype object can be one of the common types or a
											description of constraints (e.g. 4-state)  */
		boolean 	isReversible;
		
		Sequence<Expression> expressions; 
		Sequence<Parameter>	parameters;

		ModelDescriptionEnum descriptionType;
		

			/** used if descriptionType == Q_MATRIX */
		Sequence< Sequence<ExprIDString> > qMatrix; 

			/** used if descriptionType == SYMM_COMPONENT_MATRIX */
		Sequence< Sequence<ExprIDString> > 	symmComponentOfQMatrix; 
		Sequence<ExprIDString>				equilStateFreq;

		Sequence<ParameterConstraint> constraints;
		Sequence<Prior>	priors;
		
			/** used if descriptionType == MIXTURE */
		Sequence<DiscreteCharacterModel> subModels;
		Sequence<ParamIDString>	mixtureProportions;
		Prior	mixtureProportionPrior;
		
		ExprIDString rateMultiplier;
		
	};