@Override public String toString() { if (size() == 0) { return "<empty NodeSpecification>"; } final StringBuilder builder = new StringBuilder(); for (int k = 0; k < size(); k++) { builder.append(keywordSpecs[k].toString()); builder.append("\n"); } builder.delete(builder.length() - 1, builder.length()); return builder.toString(); }
public Node(@NonNull Sequence sequence) { this.sequence = sequence; valueMap = new Value[sequence.getNodeSpecification().size()]; }
@Override public String toString() { final StringBuilder builder = new StringBuilder(); final boolean labeling = nodeSpecification.size() > 1; for (final Node node : this) { //append all values for each node and label them if necessary for (int k = 0; k < nodeSpecification.size(); k++) { if (labeling) { builder.append(nodeSpecification.getKeyword(k)); builder.append("#"); } final Value value = node.getValue(k); if (value != null) { builder.append(value.toString()); } if (labeling) { builder.append(";"); } } if (labeling) { builder.delete(builder.length() - 1, builder.length()); } builder.append("|"); } if (builder.length() > 0) { builder.delete(builder.length() - 1, builder.length()); } return builder.toString(); }
final ValueComparator[] comparators = new ValueComparator[nodeSpec.size()]; for (int k = 0; k < comparators.length; k++) { final VectorialKeywordSpecification keySpec
final int K = nodeSpec.size(); final Sequence[] out = new Sequence[N]; final Random rand = new Random();
/** * 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); }