# Copyright (c) 2005 by Mark T. Holder, Florida State University. (see end of file) '''This file contains some of basic data types that make it easy to communcicate with the CIPRES system.''' # CIPRES types are corba-enabled versions of the PIPRes datatypes. # The separation only exists so that users of PIPRes are not required # to have the corba portions of the PIPRes (and omniorbPy) installed # if they only want to use pure python portions of PIPRes. # The Cipres versions of the types have a method createCorbaVersion(self) # which returns of the corresponding CipresIDL_api1 type ready to be passed as an # argument to or a return value from a remote call. from PIPRes.corba.api2 import CipresIDL_api2 from PIPRes.util.io import cipresGetLogger _LOG = cipresGetLogger('pipres.cipres_model.py') def toIDLDiscreteCharacterModel(mod): if isinstance(mod, CipresIDL_api2.DiscreteCharacterModel): return mod try: return mod.toIDL() except: _LOG.debug('member based creation of DiscreteCharacterModel') return CipresIDL_api2.DiscreteCharacterModel( mod.datatypeReference#, # mod.isReversible, # mod.expressions, # mod.parameters, # mod.descriptionType, # mod.qMatrix, # mod.symmComponentOfQMatrix, # mod.equilStateFreq, # mod.constraints, # mod.priors, # mod.subModels, # mod.mixtureProportions, # mod.mixtureProportionPrior, # mod.rateMultiplier ) def toIDLProbabilityDensity(x): if isinstance(x, CipresIDL_api2.ProbabilityDensity): return x try: return x.toIDL() except: return CipresIDL_api2.ProbabilityDensity(x.densityParams) def toIDLPrior(x): if isinstance(x, CipresIDL_api2.Prior): return x try: return x.toIDL() except: return CipresIDL_api2.Prior(x.dist, x.parameters) class ProbabilityDensity(object): def __init__(self, distParams, **kwargs): self.densityParams = distParams def toIDL(self): return CipresIDL_api2.ProbabilityDensity(self.densityParams) class Prior(object): def __init__(self, **kwargs): self.dist = ProbabilityDensity(distParams=[]) self.parameters = [] def toIDL(self): return CipresIDL_api2.Prior(self.dist.toIDL(), self.parameters) class PipresDiscreteCharacterModel(object): def __init__(self, **kwargs): self.datatypeReference = kwargs.get("datatypeReference", long(-1)) self.isReversible = kwargs.get("isReversible", True) self.expressions = kwargs.get("expressions", []) self.parameters = kwargs.get("parameters", []) self.descriptionType = kwargs.get("descriptionType", CipresIDL_api2.ModelEncoding.SYMM_COMPONENT_MATRIX) self.qMatrix = kwargs.get("qMatrix", []) self.symmComponentOfQMatrix = kwargs.get("symmComponentOfQMatrix", []) self.equilStateFreq = kwargs.get("equilStateFreq", []) self.constraints = kwargs.get("constraints", []) self.priors = kwargs.get("priors", []) self.subModels = kwargs.get("subModels", []) self.mixtureProportions = kwargs.get("mixtureProportions", []) self.mixtureProportionPrior = kwargs.get("mixtureProportionPrior", Prior()) self.rateMultiplier = kwargs.get("rateMultiplier", -1) # This file is part of the PIPRes library # # The PIPRes library is free software; you can redistribute it # and/or modify it under the terms of the GNU Lesser General # Public License as published by the Free Software Foundation; # either version 2.1 of the License, or (at your option) any later # version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, # MA 02111-1307, USA