* @throws IOException
*/
public void exportStockholm(SequenceI[] seqs, File toFile,
- AnnotatedCollectionI annotated, boolean removeSS)
+ AnnotatedCollectionI annotated)
throws IOException
{
if (seqs == null)
for (SequenceI seq : newAl.getSequencesArray())
{
- if (removeSS && seq.getAnnotation() != null)
+ if (seq.getAnnotation() != null)
{
for (AlignmentAnnotation ann : seq.getAnnotation())
{
- // TODO investigate how to make hmmsearch and jackhmmer work with annotations
- /*
- if (ann.label.equals("Secondary Structure"))
- {
- seq.removeAlignmentAnnotation(ann);
- }
- */
seq.removeAlignmentAnnotation(ann);
}
}
}
}
- void renameDuplicates(SequenceI[] seqs)
+ /**
+ * Sets the names of any duplicates within the given sequences to include their
+ * respective lengths. Deletes any duplicates that have the same name after this
+ * step
+ *
+ * @param seqs
+ */
+ void renameDuplicates(AlignmentI al)
{
- // rename duplicate sequences, hmmsearch fails db contains duplicates
+
+ SequenceI[] seqs = al.getSequencesArray();
+ List<Boolean> wasRenamed = new ArrayList<>();
+
+ for (SequenceI seq : seqs)
+ {
+ wasRenamed.add(false);
+ }
+
for (int i = 0; i < seqs.length; i++)
{
- boolean renamed = false;
for (int j = 0; j < seqs.length; j++)
{
- renamed = true;
- if (seqs[i].getName().equals(seqs[j].getName()) && i != j)
+ if (seqs[i].getName().equals(seqs[j].getName()) && i != j
+ && !wasRenamed.get(j))
{
+
+ wasRenamed.set(i, true);
String range = "/" + seqs[j].getStart() + "-" + seqs[j].getEnd();
// setting sequence name to include range - to differentiate between
// sequences of the same name. Currently have to include the range twice
}
}
- if (renamed)
+ if (wasRenamed.get(i))
{
String range = "/" + seqs[i].getStart() + "-" + seqs[i].getEnd();
seqs[i].setName(seqs[i].getName() + range + range);
}
}
+
+ for (int i = 0; i < seqs.length; i++)
+ {
+ for (int j = 0; j < seqs.length; j++)
+ {
+ if (seqs[i].getName().equals(seqs[j].getName()) && i != j)
+ {
+ al.deleteSequence(j);
+ }
+ }
+ }
}
}