/** * Returns the specification for the given keyword. * * @param keyword a keyword. * * @return the specification for the given keyword. */ public KeywordSpecification getKeywordSpecification(@NonNull final String keyword) { return getKeywordSpecification(getKeywordIndex(keyword)); }
/** * Sets the comparator for a given keyword. * * @param index a keyword index that is used in this Alignment. * @param comparator a fitting Comparator that defines a local normalized * distance on the values for the given keyword. */ public void setComparator(final int index, @NonNull final ValueComparator comparator) { if (nodeSpecification.getKeywordSpecification(getOriginalIndex(index)).getType() != comparator.getType()) { throw new RuntimeException("The given comparator has not the correct type!"); } comparators[index] = comparator; }
/** * Sets the value for the given keyword. * * @param index a keyword index. * @param value a value with the correct type. * * @throws UnsupportedOperationException is thrown if the given value has * the wrong type. * @throws ArrayIndexOutOfBoundsException is thrown if the given index is * too large or too small. */ public void setValue(final int index, final Value value) throws UnsupportedOperationException, ArrayIndexOutOfBoundsException { if (!sequence.getNodeSpecification().getKeywordSpecification(index).validate(value)) { throw new UnsupportedOperationException("The given value " + value + " does not meet the given specification for the keyword!"); } valueMap[index] = value; }
+ " is not contained in the given NodeSpecification!"); final KeywordSpecification keywordSpec = nodeSpecification.getKeywordSpecification( keywords[k]); if (keywordSpec.getType() != comparators[k].getType()) {
+ " is not contained in the given NodeSpecification!"); final KeywordSpecification keywordSpec = nodeSpecification.getKeywordSpecification( keywords[k]); if (keywordSpec.getType() != comparators[k].getType()) {
for (int k = 0; k < comparators.length; k++) { final VectorialKeywordSpecification keySpec = (VectorialKeywordSpecification) nodeSpec.getKeywordSpecification(k); comparators[k] = new DerivableVectorialComparatorWrapper(keySpec.getKeyword(), new L1NormComparator(keySpec.getLength()));
for (int k = 0; k < K; k++) { final KeywordSpecification keywordSpec = nodeSpec.getKeywordSpecification(k); switch (keywordSpec.getType()) { case SYMBOLIC: {
/** * Sets up an AlignmentSpecification for an array of vectorial sequences. * This uses a default comparator (L1 norm and hyperbolic normalization). * * @param dataSpace an array of sequences. * * @return an AlignmentSpecification. */ public static AlignmentSpecification setUpSpecification(Sequence[] dataSpace) { if (dataSpace == null || dataSpace.length == 0) { throw new IllegalArgumentException("The given data space is empty!"); } //construct an array of L1NormComparators. //check for NodeSpecification consistency. final NodeSpecification nodeSpec = dataSpace[0].getNodeSpecification(); for (int s = 1; s < dataSpace.length; s++) { if (!nodeSpec.equals(dataSpace[s].getNodeSpecification())) { throw new IllegalArgumentException("The NodeSpecifications in the given data space are not consistent!"); } } final ValueComparator[] comparators = new ValueComparator[nodeSpec.size()]; for (int k = 0; k < comparators.length; k++) { final VectorialKeywordSpecification keySpec = (VectorialKeywordSpecification) nodeSpec.getKeywordSpecification(k); comparators[k] = new DerivableVectorialComparatorWrapper(keySpec.getKeyword(), new L1NormComparator(keySpec.getLength())); } return setUpSpecification(dataSpace, comparators); }
getKeywordSpecification(0)).getAlphabet(); final DerivableSymbolicComparatorWrapper comp = new DerivableSymbolicComparatorWrapper( Sequence.DEFAULTKEYWORD,
getKeywordSpecification(Sequence.DEFAULTKEYWORD)).getAlphabet(); final DerivableSymbolicComparatorWrapper comp = new DerivableSymbolicComparatorWrapper( Sequence.DEFAULTKEYWORD,
getKeywordSpecification(Sequence.DEFAULTKEYWORD)).getAlphabet();
final KeywordSpecification keywordSpec = spec.getNodeSpecification(). getKeywordSpecification(origK); if (!(keywordSpec instanceof VectorialKeywordSpecification)) { throw new IllegalArgumentException("The specification for keyword "