import java.io.File;
import java.io.FileReader;
import java.io.IOException;
-import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
if (!dbFound || MessageManager.getString("label.this_alignment")
.equals(dbPath))
{
- AlignmentI alignment = af.getViewport().getAlignment();
- AlignmentI copy = new Alignment(alignment);
+ /*
+ * no external database specified for search, so
+ * export current alignment as 'database' to search
+ */
+ databaseFile = createTempFile("database", ".sto");
+ AlignmentI al = af.getViewport().getAlignment();
+ AlignmentI copy = new Alignment(al);
SequenceI hmms = copy.getHmmConsensus();
if (hmms != null)
{
copy.deleteSequence(hmms);
}
- StockholmFile stoFile = new StockholmFile(copy);
- stoFile.setSeqs(copy.getSequencesArray());
- String alignmentString = stoFile.print();
- databaseFile = createTempFile("database", ".sto");
- PrintWriter writer = new PrintWriter(databaseFile);
- writer.print(alignmentString);
- writer.close();
+ exportStockholm(copy.getSequencesArray(), databaseFile, null);
+ // StockholmFile stoFile = new StockholmFile(copy);
+ // stoFile.setSeqs(copy.getSequencesArray());
+ // String alignmentString = stoFile.print();
+ // PrintWriter writer = new PrintWriter(databaseFile);
+ // writer.print(alignmentString);
+ // writer.close();
}
args.add(hmmFile.getAbsolutePath());
* @throws IOException
*/
public void exportStockholm(SequenceI[] seqs, File toFile,
- AnnotatedCollectionI annotated)
- throws IOException
+ AnnotatedCollectionI annotated) throws IOException
{
- if (seqs != null)
+ if (seqs == null)
+ {
+ return;
+ }
+ AlignmentI newAl = new Alignment(seqs);
+ if (!newAl.isAligned())
+ {
+ newAl.padGaps();
+ }
+
+ if (toFile != null && annotated != null)
{
- AlignmentI newAl = new Alignment(seqs);
- if (toFile != null && annotated != null)
+ for (AlignmentAnnotation annot : annotated.getAlignmentAnnotation())
{
- for (AlignmentAnnotation annot : annotated.getAlignmentAnnotation())
+ if (annot.label.contains("Reference") || "RF".equals(annot.label))
{
- if (annot.label.contains("Reference") || "RF".equals(annot.label))
+ AlignmentAnnotation newRF;
+ if (annot.annotations.length > newAl.getWidth())
{
- AlignmentAnnotation newRF;
- if (annot.annotations.length > newAl.getWidth())
- {
- Annotation[] rfAnnots = new Annotation[newAl.getWidth()];
- System.arraycopy(annot.annotations, 0, rfAnnots, 0,
- rfAnnots.length);
- newRF = new AlignmentAnnotation("RF", "Reference Positions",
- rfAnnots);
- }
- else
- {
- newRF = new AlignmentAnnotation(annot);
- }
- newAl.addAnnotation(newRF);
+ Annotation[] rfAnnots = new Annotation[newAl.getWidth()];
+ System.arraycopy(annot.annotations, 0, rfAnnots, 0,
+ rfAnnots.length);
+ newRF = new AlignmentAnnotation("RF", "Reference Positions",
+ rfAnnots);
+ }
+ else
+ {
+ newRF = new AlignmentAnnotation(annot);
}
+ newAl.addAnnotation(newRF);
}
}
-
- StockholmFile file = new StockholmFile(newAl);
- String output = file.print(seqs, false);
- PrintWriter writer = new PrintWriter(toFile);
- writer.println(output);
- writer.close();
}
+
+ StockholmFile file = new StockholmFile(newAl);
+ String output = file.print(seqs, false);
+ PrintWriter writer = new PrintWriter(toFile);
+ writer.println(output);
+ writer.close();
}
/**