public Node(@NonNull Sequence sequence) { this.sequence = sequence; valueMap = new Value[sequence.getNodeSpecification().size()]; }
/** * Returns the value stored in this Node for the given keyword or null of no * value is stored for the given keyword in this node. * * @param keyword a keyword * * @return the value stored in this Node for the given keyword or null of no * value is stored for the given keyword in this node. * * @throws UnsupportedOperationException is thrown if the given keyword is * not supported by the NodeSpecification. */ public Value getValue(@NonNull final String keyword) throws UnsupportedOperationException { if (!sequence.getNodeSpecification().hasKeyword(keyword)) { throw new UnsupportedOperationException("The given keyword is not defined in the sequence!"); } return valueMap[sequence.getNodeSpecification().getKeywordIndex(keyword)]; }
/** * Sets the value for the given keyword. * * @param keyword a keyword. * @param value a value with the correct type. * * @throws UnsupportedOperationException is thrown if the given keyword is * not supported by the NodeSpecification or if the given value has the * wrong type. */ public void setValue(@NonNull final String keyword, final Value value) throws UnsupportedOperationException { if (!sequence.getNodeSpecification().hasKeyword(keyword)) { throw new UnsupportedOperationException("The given keyword is not defined in the sequence!"); } setValue(sequence.getNodeSpecification().getKeywordIndex(keyword), value); }
/** * Sets up an AlignmentSpecification for an array of vectorial sequences. * This uses the given comparators. * * @param dataSpace an array of sequences. * @param comparators a comparator for each dimension that works on * VectorialValues. * * @return an AlignmentSpecification. */ public static AlignmentSpecification setUpSpecification(Sequence[] dataSpace, @NonNull ValueComparator[] comparators) { if (dataSpace == null || dataSpace.length == 0) { throw new IllegalArgumentException("The given data space is empty!"); } //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 String[] keywords = nodeSpec.getKeywords(); return new AlignmentSpecification(nodeSpec, keywords, comparators); }
/** * Sets up an AlignmentSpecification for an array of vectorial sequences. * This uses the given comparator. * * @param dataSpace an array of sequences. * @param comparators an array of comparators that works on VectorialValues. * @param weights a weighting putting emphasis on certain properties. * * @return an AlignmentSpecification. */ public static AlignmentSpecification setUpSpecification(Sequence[] dataSpace, @NonNull ValueComparator[] comparators, @NonNull double[] weights) { if (dataSpace == null || dataSpace.length == 0) { throw new IllegalArgumentException("The given data space is empty!"); } //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 String[] keywords = nodeSpec.getKeywords(); return new AlignmentSpecification(nodeSpec, keywords, comparators, weights); }
/** * Sets up an AlignmentSpecification for an array of vectorial sequences. * This uses the given comparator. * * @param dataSpace an array of sequences. * @param comparator a comparator that works on VectorialValues. * @param weights a weighting putting emphasis on certain properties. * * @return an AlignmentSpecification. */ public static AlignmentSpecification setUpSpecification(Sequence[] dataSpace, @NonNull ValueComparator comparator, @NonNull double[] weights) { if (dataSpace == null || dataSpace.length == 0) { throw new IllegalArgumentException("The given data space is empty!"); } //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 String[] keywords = nodeSpec.getKeywords(); final ValueComparator[] comparators = new ValueComparator[keywords.length]; for (int k = 0; k < keywords.length; k++) { comparators[k] = comparator; } return new AlignmentSpecification(nodeSpec, keywords, comparators, weights); }
/** * Sets up an AlignmentSpecification for an array of vectorial sequences. * This uses the given comparator. * * @param dataSpace an array of sequences. * @param comparator a comparator that works on VectorialValues. * * @return an AlignmentSpecification. */ public static AlignmentSpecification setUpSpecification(Sequence[] dataSpace, ValueComparator comparator) { if (dataSpace == null || dataSpace.length == 0) { throw new IllegalArgumentException("The given data space is empty!"); } //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 String[] keywords = nodeSpec.getKeywords(); final ValueComparator[] comparators = new ValueComparator[keywords.length]; for (int k = 0; k < keywords.length; k++) { comparators[k] = comparator; } return new AlignmentSpecification(nodeSpec, keywords, comparators); }
/** * 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; }
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!");
/** * 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); }
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 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 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!");