+ private List<List<Integer>> sortOrders(List<?> alorders)
+ {
+ List<List<Integer>> regions = new ArrayList<>();
+ for (int i = 0; i < alorders.size(); i++)
+ {
+ List<Integer> regs = new ArrayList<>();
+ regs.add(i);
+ int j = i + 1;
+ while (j < alorders.size())
+ {
+ if (alorders.get(i).equals(alorders.get(j)))
+ {
+ alorders.remove(j);
+ regs.add(j);
+ }
+ else
+ {
+ j++;
+ }
+ }
+ regions.add(regs);
+ }
+ return regions;
+ }
+ }
+
+ private static class JobInput
+ {
+ final List<SequenceI> inputSequences;
+
+ final List<SequenceI> emptySequences;
+
+ @SuppressWarnings("rawtypes")
+ final Map<String, ? extends Map> sequenceNames;
+
+ private JobInput(int numSequences, List<SequenceI> inputSequences,
+ List<SequenceI> emptySequences,
+ @SuppressWarnings("rawtypes") Map<String, ? extends Map> names)
+ {
+ this.inputSequences = Collections.unmodifiableList(inputSequences);
+ this.emptySequences = Collections.unmodifiableList(emptySequences);
+ this.sequenceNames = names;
+ }
+
+ boolean isInputValid()
+ {
+ return inputSequences.size() >= 2;
+ }
+
+ static JobInput create(SequenceI[] sequences, int minLength,
+ boolean submitGaps)
+ {
+ assert minLength >= 0 : MessageManager.getString(
+ "error.implementation_error_minlen_must_be_greater_zero");
+ int numSeq = 0;
+ for (SequenceI seq : sequences)
+ {
+ if (seq.getEnd() - seq.getStart() >= minLength)
+ {
+ numSeq++;
+ }
+ }
+
+ List<SequenceI> inputSequences = new ArrayList<>();
+ List<SequenceI> emptySequences = new ArrayList<>();
+ @SuppressWarnings("rawtypes")
+ Map<String, Hashtable> names = new LinkedHashMap<>();
+ for (int i = 0; i < sequences.length; i++)
+ {
+ SequenceI seq = sequences[i];
+ String newName = SeqsetUtils.unique_name(i);
+ @SuppressWarnings("rawtypes")
+ Hashtable hash = SeqsetUtils.SeqCharacterHash(seq);
+ names.put(newName, hash);
+ if (numSeq > 1 && seq.getEnd() - seq.getStart() >= minLength)
+ {
+ String seqString = seq.getSequenceAsString();
+ if (!submitGaps)
+ {
+ seqString = AlignSeq.extractGaps(
+ jalview.util.Comparison.GapChars, seqString);
+ }
+ inputSequences.add(new Sequence(newName, seqString));
+ }
+ else
+ {
+ String seqString = null;
+ if (seq.getEnd() >= seq.getStart()) // is it ever false?
+ {
+ seqString = seq.getSequenceAsString();
+ if (!submitGaps)
+ {
+ seqString = AlignSeq.extractGaps(
+ jalview.util.Comparison.GapChars, seqString);
+ }
+ }
+ emptySequences.add(new Sequence(newName, seqString));
+ }
+ }
+
+ return new JobInput(numSeq, inputSequences, emptySequences, names);
+ }