-Subproject commit a3c44cae09b9d94e3cf63c5c4e776374f646bc67
+Subproject commit b977efb66f2d0b539bd433e80762737925035edc
public static MainFrame createUnboundInstance(final Phylogeny aptxTree)
{
Phylogeny[] aptxTrees = { aptxTree };
- return createBoundAptxFrame(aptxTrees, null);
+ return createAptxFrameInJalview(aptxTrees);
}
- public static MainFrame createInstance(final Phylogeny[] aptxTrees,
- AlignmentViewport jalviewAlignmentView)
- {
- return createBoundAptxFrame(aptxTrees, jalviewAlignmentView);
-
- }
-
- public static MainFrame createInstance(final Phylogeny aptxTree,
- final AlignmentViewport jalviewAlignmentView)
- {
- Phylogeny[] aptxTrees = { aptxTree }; // future possibility to load in
- // several trees simultaneously
- return createBoundAptxFrame(aptxTrees, jalviewAlignmentView);
-
- }
+ // public static MainFrame createInstance(final Phylogeny[] aptxTrees,
+ // AlignmentViewport jalviewAlignmentView)
+ // {
+ // return createAptxFrameInJalview(aptxTrees);
+ //
+ // }
+ //
+ // public static MainFrame createInstance(final Phylogeny aptxTree,
+ // final AlignmentViewport jalviewAlignmentView)
+ // {
+ // Phylogeny[] aptxTrees = { aptxTree }; // future possibility to load in
+ // // several trees simultaneously
+ // return createAptxFrameInJalview(aptxTrees);
+ //
+ // }
public static MainFrame createInstance(
final TreeBuilder calculatedTree) // very dense method, to be split up
Phylogeny[] aptxTrees = { aptxTree }; // future possibility to load in
// several trees simultaneously
- MainFrame aptxApp = createBoundAptxFrame(aptxTrees,
- calculatedTree.getAvport());
+ MainFrame aptxApp = createAptxFrameInJalview(aptxTrees);
+
bindNodesToJalviewSequences(aptxApp, calculatedTree.getAvport(),
aptxTreeBuilder.getAlignmentBoundNodes(),
aptxTreeBuilder.getNodesBoundAlignment());
- private static MainFrame createBoundAptxFrame(final Phylogeny[] aptxTrees,
- final AlignmentViewport jalviewAlignmentView)
+ public static MainFrame createAptxFrameInJalview(
+ final Phylogeny[] aptxTrees)
{
MainFrame aptxApp = Archaeopteryx.createApplication(aptxTrees,
"_aptx_jalview_configuration_file", null);
-
+ bindFrameToJalview(aptxApp);
return aptxApp;
}
- private static void bindNodesToJalviewSequences(final MainFrame aptxApp,
+ public static void bindNodesToJalviewSequences(final MainFrame aptxApp,
final AlignmentViewport jalviewAlignViewport,
final Map<SequenceI, PhylogenyNode> alignMappedToNodes,
final Map<PhylogenyNode, SequenceI> nodesMappedToAlign)
}
- private static MainFrame bindFrameToJalview(final MainFrame aptxApp)
+ public static MainFrame bindFrameToJalview(final MainFrame aptxApp)
{
int width = 400;
int height = 550;
--- /dev/null
+package jalview.ext.forester.io;
+
+
+import javax.swing.filechooser.FileFilter;
+
+import org.forester.archaeopteryx.MainFrame;
+
+
+public enum SupportedTreeFileFilter
+{
+ NHFILTER(MainFrame.nhfilter), NHXFILTER(MainFrame.nhxfilter),
+ XMLFILTER(MainFrame.xmlfilter), TOLFILTER(MainFrame.tolfilter),
+ NEXUSFILTER(MainFrame.nexusfilter);
+
+ private final FileFilter treeFilter;
+
+ SupportedTreeFileFilter(FileFilter treeFilter)
+ {
+ this.treeFilter = treeFilter;
+
+ }
+
+ public void printSupportedFormats()
+ {
+ for (SupportedTreeFileFilter format : SupportedTreeFileFilter.values())
+ {
+ System.out.println(format.getTreeFilter().getDescription());
+ }
+ }
+
+ public FileFilter getTreeFilter()
+ {
+ return treeFilter;
+ }
+
+}
--- /dev/null
+package jalview.ext.forester.io;
+
+import jalview.ext.archaeopteryx.ArchaeopteryxInit;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.forester.archaeopteryx.Archaeopteryx;
+import org.forester.archaeopteryx.MainFrame;
+import org.forester.util.ForesterUtil;
+
+public class TreeParser
+{
+ private final String filePath;
+
+ private final File file;
+
+ public TreeParser(String treeFilePath)
+ {
+ final String possibleError = ForesterUtil.isReadableFile(treeFilePath);
+ if (possibleError != null)
+ {
+ // something
+ }
+ filePath = treeFilePath;
+ file = new File(filePath);
+
+
+ }
+
+ public TreeParser(File treeFile) throws IOException
+ {
+ final String possibleError = ForesterUtil.isReadableFile(treeFile);
+ if (possibleError != null)
+ {
+ // something
+ }
+ file = treeFile;
+ filePath = file.getCanonicalPath();
+ }
+
+
+ public void loadTree()
+ {
+ String[] AptxArgs = new String[] { "-c",
+ "_aptx_jalview_configuration_file", filePath };
+ MainFrame aptx = Archaeopteryx.main(AptxArgs);
+ ArchaeopteryxInit.bindFrameToJalview(aptx);
+
+
+ }
+}
+
+/**
+ * Mostly refactored from Archaeopteryx.main() and
+ * MainFrameApplication.readPhylogeniesFromFile()
+ */
+// boolean nhx_or_nexus = false;
+// Configuration config = new Configuration(
+// "_aptx_jalview_configuration_file", false, false, false);
+// try
+// {
+// final PhylogenyParser p = ParserUtils.createParserDependingOnFileType(
+// file, config.isValidatePhyloXmlAgainstSchema());
+//
+// if (p instanceof NHXParser)
+// {
+// nhx_or_nexus = true;
+// final NHXParser nhx = (NHXParser) p;
+// nhx.setReplaceUnderscores(false);
+// nhx.setIgnoreQuotes(false);
+// nhx.setTaxonomyExtraction(config.getTaxonomyExtraction());
+// }
+// else if (p instanceof NexusPhylogeniesParser)
+// {
+// nhx_or_nexus = true;
+// final NexusPhylogeniesParser nex = (NexusPhylogeniesParser) p;
+// nex.setReplaceUnderscores(config.isReplaceUnderscoresInNhParsing());
+// nex.setIgnoreQuotes(false);
+// }
+// else if (p instanceof PhyloXmlParser)
+// {
+//
+// }
+// Phylogeny[] phylogenies = PhylogenyMethods.readPhylogenies(p, file);
+// if (nhx_or_nexus
+// && config.isInternalNumberAreConfidenceForNhParsing())
+// {
+// for (final Phylogeny phy : phylogenies)
+// {
+// PhylogenyMethods.transferInternalNodeNamesToConfidence(phy, "");
+//
+// }
+// }
+// }
+//
+// catch (IOException e)
+// {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
+// }
+
+
+
+
+
+
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
+import jalview.ext.forester.io.SupportedTreeFileFilter;
+import jalview.ext.forester.io.TreeParser;
import jalview.gui.ColourMenuHelper.ColourChangeListener;
import jalview.gui.ViewSelectionMenu.ViewSetProvider;
import jalview.io.AlignmentProperties;
jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
chooser.setFileView(new JalviewFileView());
chooser.setDialogTitle(
- MessageManager.getString("label.select_newick_like_tree_file"));
+ MessageManager.getString("label.select_newick_like_tree_file")); // modify
chooser.setToolTipText(
MessageManager.getString("label.load_tree_file"));
+ for (SupportedTreeFileFilter treeFormat : SupportedTreeFileFilter.values())
+ {
+ chooser.setFileFilter(treeFormat.getTreeFilter());
+ }
int value = chooser.showOpenDialog(null);
{
String filePath = chooser.getSelectedFile().getPath();
Cache.setProperty("LAST_DIRECTORY", filePath);
+
NewickFile fin = null;
try
{
+ TreeParser treeParser = new TreeParser(filePath);
+ treeParser.loadTree();
+
+
+
fin = new NewickFile(filePath, DataSourceType.FILE);
viewport.setCurrentTree(showNewickTree(fin, filePath).getTree());
} catch (Exception ex)