From 877f6cdc498ecfba8ddefc3e157700ca4c0fb56d Mon Sep 17 00:00:00 2001 From: jprocter Date: Wed, 1 Aug 2007 16:29:14 +0000 Subject: [PATCH] added the '-tree' parameter to open a tree from the command line --- src/jalview/bin/Jalview.java | 59 ++++++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 19 deletions(-) diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index f0c33a1..65628fb 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -18,11 +18,13 @@ */ package jalview.bin; +import java.io.IOException; import java.util.*; import javax.swing.*; import jalview.gui.*; +import jalview.io.AppletFormatAdapter; /** * Main class for Jalview Application @@ -60,6 +62,8 @@ public class Jalview + "-annotations FILE\tAdd precalculated annotations to the alignment.\n" + + "-tree FILE\tLoad the given newick format tree file onto the alignment\n" + + "-features FILE\tUse the given file to mark features on the alignment.\n" + "-fasta FILE\tCreate alignment file FILE in Fasta format.\n" + "-clustal FILE\tCreate alignment file FILE in Clustal format.\n" @@ -173,22 +177,10 @@ public class Jalview } } - protocol = "File"; - - if (file.indexOf("http:") > -1 || file.indexOf("file:") > -1) - { - protocol = "URL"; - } - - if (file.endsWith(".jar")) - { - format = "Jalview"; - } - else - { - format = new jalview.io.IdentifyFile().Identify(file, protocol); - } - + protocol = checkProtocol(file); + + format = new jalview.io.IdentifyFile().Identify(file, protocol); + AlignFrame af = fileLoader.LoadFileWaitTillLoaded(file, protocol, format); if (af == null) @@ -222,13 +214,13 @@ public class Jalview data = aparser.getValue("groups"); if (data != null) { - af.parseFeaturesFile(data, protocol); + af.parseFeaturesFile(data, checkProtocol(data)); System.out.println("Added " + data); } data = aparser.getValue("features"); if (data != null) { - af.parseFeaturesFile(data, protocol); + af.parseFeaturesFile(data, checkProtocol(data)); System.out.println("Added " + data); } @@ -238,6 +230,24 @@ public class Jalview af.loadJalviewDataFile(data); System.out.println("Added " + data); } + data = aparser.getValue("tree"); + if (data != null) + { + jalview.io.NewickFile fin = null; + try { + fin = new jalview.io.NewickFile(data, checkProtocol(data)); + if (fin!=null) + { + af.getViewport().setCurrentTree(af.ShowNewickTree(fin, data).getTree()); + System.out.println("Added tree " + data); + } + } + catch (IOException ex) + { + System.err.println("Couldn't add tree "+data); + ex.printStackTrace(System.err); + } + } String imageName = "unnamed.png"; while (aparser.getSize() > 1) @@ -317,8 +327,19 @@ public class Jalview } } -} + + private static String checkProtocol(String file) + { + String protocol = jalview.io.FormatAdapter.FILE; + + if (file.indexOf("http:") > -1 || file.indexOf("file:") > -1) + { + protocol = jalview.io.FormatAdapter.URL; + } + return protocol; + } +} class ArgsParser { Vector vargs = null; -- 1.7.10.2