de.jstacs.parameters
Class SequenceScoringParameterSet<T extends InstantiableFromParameterSet>

java.lang.Object
  extended by de.jstacs.parameters.ParameterSet
      extended by de.jstacs.parameters.InstanceParameterSet<T>
          extended by de.jstacs.parameters.SequenceScoringParameterSet<T>
Type Parameters:
T - the type of the SequenceScoringParameterSet
All Implemented Interfaces:
GalaxyConvertible, Storable, Cloneable
Direct Known Subclasses:
BayesianNetworkDiffSMParameterSet, DGTrainSMParameterSet, SamplingScoreBasedClassifierParameterSet, ScoreClassifierParameterSet

public abstract class SequenceScoringParameterSet<T extends InstantiableFromParameterSet>
extends InstanceParameterSet<T>

Abstract class for a ParameterSet containing all parameters necessary to construct an Object that implements InstantiableFromParameterSet. This parameter set handles the AlphabetContainer and if necessary the length of a sequence, so it is well suited as parameter set for AbstractTrainableStatisticalModel and AbstractClassifier.

Author:
Jan Grau, Jens Keilwagen
See Also:
InstantiableFromParameterSet, ParameterSet, AbstractTrainableStatisticalModel, AbstractClassifier

Nested Class Summary
 
Nested classes/interfaces inherited from class de.jstacs.parameters.ParameterSet
ParameterSet.ParameterList
 
Field Summary
protected  Parameter alphabet
          The alphabet the model works on
protected  Parameter length
          The length of sequences the model can work on or 0 for arbitrary length
 
Fields inherited from class de.jstacs.parameters.ParameterSet
errorMessage, parameters, parent
 
Constructor Summary
SequenceScoringParameterSet(Class<T> instanceClass, AlphabetContainer.AlphabetContainerType type, boolean simple)
          Constructs an InstanceParameterSet having empty parameter values.
SequenceScoringParameterSet(Class<T> instanceClass, AlphabetContainer.AlphabetContainerType type, boolean simple, boolean variableLength)
          Constructs a SequenceScoringParameterSet having empty parameter values.
SequenceScoringParameterSet(Class<T> instanceClass, AlphabetContainer alphabet)
          Constructs a SequenceScoringParameterSet for an object that can handle sequences of variable length and with the AlphabetContainer alphabet.
SequenceScoringParameterSet(Class<T> instanceClass, AlphabetContainer alphabet, int length, boolean variableLength)
          Constructs a SequenceScoringParameterSet from an AlphabetContainer and the length of a sequence.
SequenceScoringParameterSet(StringBuffer representation)
          The standard constructor for the interface Storable.
 
Method Summary
 SequenceScoringParameterSet<T> clone()
          Creates a full clone (deep copy) of this ParameterSet.
 boolean equals(Object o)
           
protected  void fromXML(StringBuffer representation)
          Parses the instance fields of a ParameterSet from the XML representation as returned by ParameterSet.toXML().
 AlphabetContainer getAlphabetContainer()
          Returns the AlphabetContainer of the current instance.
 int getLength()
          Returns the length of the sequences the model can work on.
 int getNumberOfParameters()
          Returns the number of parameters in the ParameterSet.
 Parameter getParameterAt(int i)
          Returns the Parameter at position i.
 boolean hasDefaultOrIsSet()
          Returns true if all parameters in this ParameterSet are either set by the user or have default values.
 void reset()
          Resets all Parameters in this ParameterSet to their default values or null if not default value was provided.
 StringBuffer toXML()
          This method returns an XML representation as StringBuffer of an instance of the implementing class.
 
Methods inherited from class de.jstacs.parameters.InstanceParameterSet
getInstance, getInstanceClass, getInstanceComment, getInstanceName
 
Methods inherited from class de.jstacs.parameters.ParameterSet
fromGalaxy, getAllParameterNames, getComment, getComment, getErrorMessage, getIndex, getName, getName, getParameterForName, getParent, initParameterList, initParameterList, isAtomic, isComparable, parametersLoaded, setParent, toGalaxy
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

alphabet

protected Parameter alphabet
The alphabet the model works on


length

protected Parameter length
The length of sequences the model can work on or 0 for arbitrary length

Constructor Detail

SequenceScoringParameterSet

public SequenceScoringParameterSet(Class<T> instanceClass,
                                   AlphabetContainer.AlphabetContainerType type,
                                   boolean simple)
Constructs an InstanceParameterSet having empty parameter values. This constructor should only be used if the object can handle sequences of fixed length.

Parameters:
instanceClass - the class of the instance
type - the type of the alphabet(s)
simple - determines whether the alphabet should be simple
See Also:
AlphabetContainer.AlphabetContainerType

SequenceScoringParameterSet

public SequenceScoringParameterSet(Class<T> instanceClass,
                                   AlphabetContainer.AlphabetContainerType type,
                                   boolean simple,
                                   boolean variableLength)
Constructs a SequenceScoringParameterSet having empty parameter values. The user can specify a-priori if the object can handle sequences of variable lengths. If that is the case the object is not queried from the user as it is 0 anyway.

Parameters:
instanceClass - the (sub-)class of the instance
type - the type of the alphabet(s)
simple - determines whether the alphabet should be simple
variableLength - true if the object can handle sequences of arbitrary length, false otherwise
See Also:
AlphabetContainer.AlphabetContainerType

SequenceScoringParameterSet

public SequenceScoringParameterSet(StringBuffer representation)
                            throws NonParsableException
The standard constructor for the interface Storable. Constructs a SequenceScoringParameterSet from its XML representation. Automatically calls the current implementation of fromXML(StringBuffer).

Parameters:
representation - the XML representation as StringBuffer
Throws:
NonParsableException - if the StringBuffer representation could not be parsed

SequenceScoringParameterSet

public SequenceScoringParameterSet(Class<T> instanceClass,
                                   AlphabetContainer alphabet,
                                   int length,
                                   boolean variableLength)
                            throws Exception
Constructs a SequenceScoringParameterSet from an AlphabetContainer and the length of a sequence. This constructor can be used to implement a SequenceScoringParameterSet that is already instantiated with known parameter values.

Parameters:
instanceClass - the class of the instance
alphabet - the AlphabetContainer for a sequence
length - the length of sequence
variableLength - true if the object can handle sequences of arbitrary length, false otherwise
Throws:
Exception - if the alphabets or the length are not in the expected range of values

SequenceScoringParameterSet

public SequenceScoringParameterSet(Class<T> instanceClass,
                                   AlphabetContainer alphabet)
                            throws Exception
Constructs a SequenceScoringParameterSet for an object that can handle sequences of variable length and with the AlphabetContainer alphabet. This constructor can be used to implement a SequenceScoringParameterSet that is already instantiated with known parameter values.
The length parameter is set to 0.

Parameters:
instanceClass - the (sub-)class of the instance
alphabet - the AlphabetContainer for a sequence
Throws:
Exception - if the alphabets or the length are not in the expected range of values
Method Detail

hasDefaultOrIsSet

public boolean hasDefaultOrIsSet()
Description copied from class: ParameterSet
Returns true if all parameters in this ParameterSet are either set by the user or have default values. If any additional constraints are required on your parameters you should either specify some ParameterValidator on these parameters or implement these constraints by overriding this method in your implementation of ParameterSet. It is recommended to specify a useful remark which constraint failed in the member-variable errorMessage, which will be displayed to the user. In the overriding method super.ParameterSet.hasDefaultOrIsSet() should be called prior to checking specific constraints.

Overrides:
hasDefaultOrIsSet in class ParameterSet
Returns:
true if all parameters have some allowed value set, false otherwise

reset

public void reset()
Description copied from class: ParameterSet
Resets all Parameters in this ParameterSet to their default values or null if not default value was provided.

Overrides:
reset in class ParameterSet
See Also:
Parameter.reset()

getAlphabetContainer

public AlphabetContainer getAlphabetContainer()
Returns the AlphabetContainer of the current instance.

Returns:
the AlphabetContainer

getLength

public int getLength()
              throws IllegalArgumentException
Returns the length of the sequences the model can work on.

Returns:
the length of the sequences the model can work on
Throws:
IllegalArgumentException - if the length is not correct, i.e. the length is not suitable for the chosen requirements

fromXML

protected void fromXML(StringBuffer representation)
                throws NonParsableException
Description copied from class: ParameterSet
Parses the instance fields of a ParameterSet from the XML representation as returned by ParameterSet.toXML().

Overrides:
fromXML in class InstanceParameterSet<T extends InstantiableFromParameterSet>
Parameters:
representation - the XML representation as StringBuffer
Throws:
NonParsableException - if the XML code could not be parsed
See Also:
ParameterSet.toXML()

getNumberOfParameters

public int getNumberOfParameters()
Description copied from class: ParameterSet
Returns the number of parameters in the ParameterSet.

Overrides:
getNumberOfParameters in class ParameterSet
Returns:
the number of parameters in the ParameterSet

getParameterAt

public Parameter getParameterAt(int i)
Description copied from class: ParameterSet
Returns the Parameter at position i.

Overrides:
getParameterAt in class ParameterSet
Parameters:
i - the position in the ParameterSet
Returns:
the Parameter at position i

toXML

public StringBuffer toXML()
Description copied from interface: Storable
This method returns an XML representation as StringBuffer of an instance of the implementing class.

Specified by:
toXML in interface Storable
Overrides:
toXML in class InstanceParameterSet<T extends InstantiableFromParameterSet>
Returns:
the XML representation

equals

public boolean equals(Object o)
Overrides:
equals in class Object

clone

public SequenceScoringParameterSet<T> clone()
                                                                          throws CloneNotSupportedException
Description copied from class: ParameterSet
Creates a full clone (deep copy) of this ParameterSet. As a convenience-method the user can use fillWithStandardFieldsForClone(ParameterSet) on a newly created instance of a subclass of ParameterSet to obtain a clone/copy of all standard member variables (those already defined in ParameterSet) in the passed ParameterSet. Using this method, the cloning process becomes merely three-step:
This method fulfills the conventions of Object's method Object.clone().

Overrides:
clone in class ParameterSet
Returns:
a deep clone/copy of this ParameterSet
Throws:
CloneNotSupportedException