import java.io.BufferedReader;
import java.io.File;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
* @throws IOException
*/
public void exportStockholm(SequenceI[] seqs, File toFile,
- AnnotatedCollectionI annotated) throws IOException
+ AnnotatedCollectionI annotated, boolean removeSS)
+ throws IOException
{
if (seqs == null)
{
return;
}
AlignmentI newAl = new Alignment(seqs);
+
if (!newAl.isAligned())
{
newAl.padGaps();
}
}
+ for (SequenceI seq : newAl.getSequencesArray())
+ {
+ if (removeSS && 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);
+ }
+ }
+ }
+
StockholmFile file = new StockholmFile(newAl);
String output = file.print(seqs, false);
PrintWriter writer = new PrintWriter(toFile);
}
/**
- * Exports the given alignment withotu any anotations to a fasta file
- *
- * @param seqs
- * @param toFile
- */
- public void exportFasta(AlignmentI al, File toFile)
- {
- FastaFile file = new FastaFile();
-
- String output = file.print(al.getSequencesArray(), false);
- PrintWriter writer;
- try
- {
- writer = new PrintWriter(toFile);
- writer.println(output);
- writer.close();
- } catch (FileNotFoundException e)
- {
- e.printStackTrace();
- }
-
- }
-
- /**
* Answers the full path to the given hmmer executable, or null if file cannot
* be found or is not executable
*
}
}
}
+
+ void renameDuplicates(SequenceI[] seqs)
+ {
+ // rename duplicate sequences, hmmsearch fails db contains duplicates
+ 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)
+ {
+ 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
+ // because the range is removed (once) when setting the name
+ // TODO come up with a better way of doing this
+ seqs[j].setName(seqs[j].getName() + range + range);
+ }
+
+ }
+ if (renamed)
+ {
+ String range = "/" + seqs[i].getStart() + "-" + seqs[i].getEnd();
+ seqs[i].setName(seqs[i].getName() + range + range);
+ }
+ }
+ }
+
}