Skip to content

Commit

Permalink
enable importing of alignments in files with .txt extension. fixes #78
Browse files Browse the repository at this point in the history
  • Loading branch information
rbouckaert committed Dec 3, 2023
1 parent b41a9ec commit ced29f3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/beastfx/app/inputeditor/BeautiAlignmentProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,17 @@ public List<BEASTInterface> getAlignments(BeautiDoc doc, File[] files) {
availableImporters.add(importer);
}
}
if (availableImporters.size() == 0 && file.getPath().toLowerCase().endsWith(".txt")) {
// remove .txt extension and try again
String path = file.getPath();
path = path.substring(0, path.length() - 4);
File file2 = new File(path);
for (AlignmentImporter importer : importers) {
if (importer.canHandleFile(file2)) {
availableImporters.add(importer);
}
}
}

if (availableImporters.size() > 0) {
AlignmentImporter importer = availableImporters.get(0);
Expand Down
6 changes: 5 additions & 1 deletion src/beastfx/app/inputeditor/FastaImporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ public List<BEASTInterface> loadFile(File file) {
// .ffn = nucleotide coding regions
// .frn = non-coding RNA
// .ffa = amino acid
boolean mayBeAminoacid = !(file.getName().toLowerCase().endsWith(".fna") || file.getName().toLowerCase().endsWith(".ffn") || file.getName().toLowerCase().endsWith(".frn"));
String filename = file.getName();
if (filename.toLowerCase().endsWith(".txt")) {
filename = filename.substring(0, filename.length() - 4);
}
boolean mayBeAminoacid = !(filename.toLowerCase().endsWith(".fna") || filename.toLowerCase().endsWith(".ffn") || filename.toLowerCase().endsWith(".frn"));

while (fin.ready()) {
String line = fin.readLine();
Expand Down

0 comments on commit ced29f3

Please sign in to comment.