@Test public void testDist2() throws IOException { File dist1Nex = FileUtils.toFile(NetMakeTest.class.getResource("/dist2.nex")); File netout = new File(folder.getRoot(), "network.nex"); File treeout = new File(folder.getRoot(), "tree.nex"); NetMakeOptions options = new NetMakeOptions(); options.setInput(dist1Nex); options.setOutputNetwork(netout); options.setOutputTree(treeout); options.setWeighting1("TREE"); options.setCoAlg("NETMAKE"); NetMake nm = new NetMake(options); nm.run(); assertTrue(netout.exists()); assertTrue(treeout.exists()); List<String> netlines = FileUtils.readLines(netout, "UTF-8"); List<String> treelines = FileUtils.readLines(treeout, "UTF-8"); assertTrue(!netlines.isEmpty()); assertTrue(!treelines.isEmpty()); }
@Override public void run() { try { StopWatch stopWatch = new StopWatch(); stopWatch.start(); notifyUser("Loading distance matrix from: " + this.options.getInput().getAbsolutePath()); SpectreReaderFactory factory = SpectreReaderFactory.getInstance(); SpectreReader spectreReader = factory.create(FilenameUtils.getExtension(this.options.getInput().getName())); DistanceMatrix distanceMatrix = null; Sequences seqs = null; if (spectreReader.getIdentifier() == "FASTA") { seqs = spectreReader.readAlignment(this.options.getInput()); } else if (spectreReader.getIdentifier() == "NEXUS") { Nexus nexus = new NexusReader().parse(this.options.getInput()); if (nexus.getDistanceMatrix() == null) { seqs = nexus.getAlignments(); } else { distanceMatrix = nexus.getDistanceMatrix(); } } else { distanceMatrix = spectreReader.readDistanceMatrix(this.options.getInput()); } if (distanceMatrix == null && seqs != null) { log.info("Loaded MSA containing " + seqs.size() + " sequences of length " + seqs.getSeq(0).length()); DistanceCalculatorFactory dcf = DistanceCalculatorFactory.valueOf(this.options.getDc().toUpperCase().trim()); distanceMatrix = dcf.createDistanceMatrix(seqs); log.info("Distance matrix calculated from MSA using " + dcf.name()); } else if (distanceMatrix == null) { throw new IOException("Could not find or generate distance matrix from input"); } log.info("Distance matrix contains " + distanceMatrix.size() + " taxa."); CircularOrderingAlgorithms coa = CircularOrderingAlgorithms.valueOf(this.options.getCoAlg().toUpperCase()); CircularOrderingCreator coc = null; log.info("Circular ordering algorithm: " + coa.toString()); if (coa == CircularOrderingAlgorithms.NETMAKE) { Weighting weighting1 = Weightings.createWeighting(this.options.getWeighting1(), distanceMatrix, this.options.getTreeParam(), true); Weighting weighting2 = (this.options.getWeighting2() != null && !this.options.getWeighting2().equalsIgnoreCase("none")) ? Weightings.createWeighting(this.options.getWeighting2(), distanceMatrix, this.options.getTreeParam(), false) : null; log.info("Weightings configured."); log.info(" - Weighting 1: " + weighting1.toString()); log.info(" - Weighting 2: " + (weighting2 == null ? "null" : weighting2.toString())); log.info("Running netmake circular ordering algorithm in mode: " + NetMakeCircularOrderer.getRunMode(weighting1, weighting2).toString()); coc = new NetMakeCircularOrderer(weighting1, weighting2); } else if (coa == CircularOrderingAlgorithms.NEIGHBORNET) { coc = new NeighborNetImpl(); } notifyUser("Executing netmake"); NetMakeResult result = this.execute(distanceMatrix, coc); notifyUser("Saving results to disk"); result.save(this.options.getOutputNetwork(), this.options.getOutputTree()); this.trackerFinished(true); stopWatch.stop(); log.info("Completed Successfully - Total run time: " + stopWatch.toString()); } catch (Exception e) { log.error(e.getMessage(), e); this.setError(e); this.trackerFinished(false); } finally { this.notifyListener(); } }
NetMake extends RunnableTool { @Override public void run() { try { StopWatch stopWatch = new StopWatch(); stopWatch.start(); notifyUser("Loading distance matrix from: " + this.options.getInput().getAbsolutePath()); SpectreReaderFactory factory = SpectreReaderFactory.getInstance(); SpectreReader spectreReader = factory.create(FilenameUtils.getExtension(this.options.getInput().getName())); DistanceMatrix distanceMatrix = null; Sequences seqs = null; if (spectreReader.getIdentifier() == "FASTA") { seqs = spectreReader.readAlignment(this.options.getInput()); } else if (spectreReader.getIdentifier() == "NEXUS") { Nexus nexus = new NexusReader().parse(this.options.getInput()); if (nexus.getDistanceMatrix() == null) { seqs = nexus.getAlignments(); } else { distanceMatrix = nexus.getDistanceMatrix(); } } else { distanceMatrix = spectreReader.readDistanceMatrix(this.options.getInput()); } if (distanceMatrix == null && seqs != null) { log.info("Loaded MSA containing " + seqs.size() + " sequences of length " + seqs.getSeq(0).length()); DistanceCalculatorFactory dcf = DistanceCalculatorFactory.valueOf(this.options.getDc().toUpperCase().trim()); distanceMatrix = dcf.createDistanceMatrix(seqs); log.info("Distance matrix calculated from MSA using " + dcf.name()); } else if (distanceMatrix == null) { throw new IOException("Could not find or generate distance matrix from input"); } log.info("Distance matrix contains " + distanceMatrix.size() + " taxa."); CircularOrderingAlgorithms coa = CircularOrderingAlgorithms.valueOf(this.options.getCoAlg().toUpperCase()); CircularOrderingCreator coc = null; log.info("Circular ordering algorithm: " + coa.toString()); if (coa == CircularOrderingAlgorithms.NETMAKE) { Weighting weighting1 = Weightings.createWeighting(this.options.getWeighting1(), distanceMatrix, this.options.getTreeParam(), true); Weighting weighting2 = (this.options.getWeighting2() != null && !this.options.getWeighting2().equalsIgnoreCase("none")) ? Weightings.createWeighting(this.options.getWeighting2(), distanceMatrix, this.options.getTreeParam(), false) : null; log.info("Weightings configured."); log.info(" - Weighting 1: " + weighting1.toString()); log.info(" - Weighting 2: " + (weighting2 == null ? "null" : weighting2.toString())); log.info("Running netmake circular ordering algorithm in mode: " + NetMakeCircularOrderer.getRunMode(weighting1, weighting2).toString()); coc = new NetMakeCircularOrderer(weighting1, weighting2); } else if (coa == CircularOrderingAlgorithms.NEIGHBORNET) { coc = new NeighborNetImpl(); } notifyUser("Executing netmake"); NetMakeResult result = this.execute(distanceMatrix, coc); notifyUser("Saving results to disk"); result.save(this.options.getOutputNetwork(), this.options.getOutputTree()); this.trackerFinished(true); stopWatch.stop(); log.info("Completed Successfully - Total run time: " + stopWatch.toString()); } catch (Exception e) { log.error(e.getMessage(), e); this.setError(e); this.trackerFinished(false); } finally { this.notifyListener(); } } }
NetMake extends RunnableTool { @Override public void run() { try { StopWatch stopWatch = new StopWatch(); stopWatch.start(); notifyUser("Loading distance matrix from: " + this.options.getInput().getAbsolutePath()); SpectreReaderFactory factory = SpectreReaderFactory.getInstance(); SpectreReader spectreReader = factory.create(FilenameUtils.getExtension(this.options.getInput().getName())); DistanceMatrix distanceMatrix = null; Sequences seqs = null; if (spectreReader.getIdentifier() == "FASTA") { seqs = spectreReader.readAlignment(this.options.getInput()); } else if (spectreReader.getIdentifier() == "NEXUS") { Nexus nexus = new NexusReader().parse(this.options.getInput()); if (nexus.getDistanceMatrix() == null) { seqs = nexus.getAlignments(); } else { distanceMatrix = nexus.getDistanceMatrix(); } } else { distanceMatrix = spectreReader.readDistanceMatrix(this.options.getInput()); } if (distanceMatrix == null && seqs != null) { log.info("Loaded MSA containing " + seqs.size() + " sequences of length " + seqs.getSeq(0).length()); DistanceCalculatorFactory dcf = DistanceCalculatorFactory.valueOf(this.options.getDc().toUpperCase().trim()); distanceMatrix = dcf.createDistanceMatrix(seqs); log.info("Distance matrix calculated from MSA using " + dcf.name()); } else if (distanceMatrix == null) { throw new IOException("Could not find or generate distance matrix from input"); } log.info("Distance matrix contains " + distanceMatrix.size() + " taxa."); CircularOrderingAlgorithms coa = CircularOrderingAlgorithms.valueOf(this.options.getCoAlg().toUpperCase()); CircularOrderingCreator coc = null; log.info("Circular ordering algorithm: " + coa.toString()); if (coa == CircularOrderingAlgorithms.NETMAKE) { Weighting weighting1 = Weightings.createWeighting(this.options.getWeighting1(), distanceMatrix, this.options.getTreeParam(), true); Weighting weighting2 = (this.options.getWeighting2() != null && !this.options.getWeighting2().equalsIgnoreCase("none")) ? Weightings.createWeighting(this.options.getWeighting2(), distanceMatrix, this.options.getTreeParam(), false) : null; log.info("Weightings configured."); log.info(" - Weighting 1: " + weighting1.toString()); log.info(" - Weighting 2: " + (weighting2 == null ? "null" : weighting2.toString())); log.info("Running netmake circular ordering algorithm in mode: " + NetMakeCircularOrderer.getRunMode(weighting1, weighting2).toString()); coc = new NetMakeCircularOrderer(weighting1, weighting2); } else if (coa == CircularOrderingAlgorithms.NEIGHBORNET) { coc = new NeighborNetImpl(); } notifyUser("Executing netmake"); NetMakeResult result = this.execute(distanceMatrix, coc); notifyUser("Saving results to disk"); result.save(this.options.getOutputNetwork(), this.options.getOutputTree()); this.trackerFinished(true); stopWatch.stop(); log.info("Completed Successfully - Total run time: " + stopWatch.toString()); } catch (Exception e) { log.error(e.getMessage(), e); this.setError(e); this.trackerFinished(false); } finally { this.notifyListener(); } } NetMake();  NetMake(NetMakeOptions options);  NetMake(NetMakeOptions options, StatusTracker statusTracker); }
NetMake extends RunnableTool { @Override public void run() { try { StopWatch stopWatch = new StopWatch(); stopWatch.start(); notifyUser("Loading distance matrix from: " + this.options.getInput().getAbsolutePath()); SpectreReaderFactory factory = SpectreReaderFactory.getInstance(); SpectreReader spectreReader = factory.create(FilenameUtils.getExtension(this.options.getInput().getName())); DistanceMatrix distanceMatrix = null; Sequences seqs = null; if (spectreReader.getIdentifier() == "FASTA") { seqs = spectreReader.readAlignment(this.options.getInput()); } else if (spectreReader.getIdentifier() == "NEXUS") { Nexus nexus = new NexusReader().parse(this.options.getInput()); if (nexus.getDistanceMatrix() == null) { seqs = nexus.getAlignments(); } else { distanceMatrix = nexus.getDistanceMatrix(); } } else { distanceMatrix = spectreReader.readDistanceMatrix(this.options.getInput()); } if (distanceMatrix == null && seqs != null) { log.info("Loaded MSA containing " + seqs.size() + " sequences of length " + seqs.getSeq(0).length()); DistanceCalculatorFactory dcf = DistanceCalculatorFactory.valueOf(this.options.getDc().toUpperCase().trim()); distanceMatrix = dcf.createDistanceMatrix(seqs); log.info("Distance matrix calculated from MSA using " + dcf.name()); } else if (distanceMatrix == null) { throw new IOException("Could not find or generate distance matrix from input"); } log.info("Distance matrix contains " + distanceMatrix.size() + " taxa."); CircularOrderingAlgorithms coa = CircularOrderingAlgorithms.valueOf(this.options.getCoAlg().toUpperCase()); CircularOrderingCreator coc = null; log.info("Circular ordering algorithm: " + coa.toString()); if (coa == CircularOrderingAlgorithms.NETMAKE) { Weighting weighting1 = Weightings.createWeighting(this.options.getWeighting1(), distanceMatrix, this.options.getTreeParam(), true); Weighting weighting2 = (this.options.getWeighting2() != null && !this.options.getWeighting2().equalsIgnoreCase("none")) ? Weightings.createWeighting(this.options.getWeighting2(), distanceMatrix, this.options.getTreeParam(), false) : null; log.info("Weightings configured."); log.info(" - Weighting 1: " + weighting1.toString()); log.info(" - Weighting 2: " + (weighting2 == null ? "null" : weighting2.toString())); log.info("Running netmake circular ordering algorithm in mode: " + NetMakeCircularOrderer.getRunMode(weighting1, weighting2).toString()); coc = new NetMakeCircularOrderer(weighting1, weighting2); } else if (coa == CircularOrderingAlgorithms.NEIGHBORNET) { coc = new NeighborNetImpl(); } notifyUser("Executing netmake"); NetMakeResult result = this.execute(distanceMatrix, coc); notifyUser("Saving results to disk"); result.save(this.options.getOutputNetwork(), this.options.getOutputTree()); this.trackerFinished(true); stopWatch.stop(); log.info("Completed Successfully - Total run time: " + stopWatch.toString()); } catch (Exception e) { log.error(e.getMessage(), e); this.setError(e); this.trackerFinished(false); } finally { this.notifyListener(); } } NetMake();  NetMake(NetMakeOptions options);  NetMake(NetMakeOptions options, StatusTracker statusTracker); NetMakeOptions getOptions(); void setOptions(NetMakeOptions options); NetMakeResult execute(DistanceMatrix distanceMatrix, CircularOrderingCreator circularOrderingCreator); @Override void run(); }
NetMake extends RunnableTool { @Override public void run() { try { StopWatch stopWatch = new StopWatch(); stopWatch.start(); notifyUser("Loading distance matrix from: " + this.options.getInput().getAbsolutePath()); SpectreReaderFactory factory = SpectreReaderFactory.getInstance(); SpectreReader spectreReader = factory.create(FilenameUtils.getExtension(this.options.getInput().getName())); DistanceMatrix distanceMatrix = null; Sequences seqs = null; if (spectreReader.getIdentifier() == "FASTA") { seqs = spectreReader.readAlignment(this.options.getInput()); } else if (spectreReader.getIdentifier() == "NEXUS") { Nexus nexus = new NexusReader().parse(this.options.getInput()); if (nexus.getDistanceMatrix() == null) { seqs = nexus.getAlignments(); } else { distanceMatrix = nexus.getDistanceMatrix(); } } else { distanceMatrix = spectreReader.readDistanceMatrix(this.options.getInput()); } if (distanceMatrix == null && seqs != null) { log.info("Loaded MSA containing " + seqs.size() + " sequences of length " + seqs.getSeq(0).length()); DistanceCalculatorFactory dcf = DistanceCalculatorFactory.valueOf(this.options.getDc().toUpperCase().trim()); distanceMatrix = dcf.createDistanceMatrix(seqs); log.info("Distance matrix calculated from MSA using " + dcf.name()); } else if (distanceMatrix == null) { throw new IOException("Could not find or generate distance matrix from input"); } log.info("Distance matrix contains " + distanceMatrix.size() + " taxa."); CircularOrderingAlgorithms coa = CircularOrderingAlgorithms.valueOf(this.options.getCoAlg().toUpperCase()); CircularOrderingCreator coc = null; log.info("Circular ordering algorithm: " + coa.toString()); if (coa == CircularOrderingAlgorithms.NETMAKE) { Weighting weighting1 = Weightings.createWeighting(this.options.getWeighting1(), distanceMatrix, this.options.getTreeParam(), true); Weighting weighting2 = (this.options.getWeighting2() != null && !this.options.getWeighting2().equalsIgnoreCase("none")) ? Weightings.createWeighting(this.options.getWeighting2(), distanceMatrix, this.options.getTreeParam(), false) : null; log.info("Weightings configured."); log.info(" - Weighting 1: " + weighting1.toString()); log.info(" - Weighting 2: " + (weighting2 == null ? "null" : weighting2.toString())); log.info("Running netmake circular ordering algorithm in mode: " + NetMakeCircularOrderer.getRunMode(weighting1, weighting2).toString()); coc = new NetMakeCircularOrderer(weighting1, weighting2); } else if (coa == CircularOrderingAlgorithms.NEIGHBORNET) { coc = new NeighborNetImpl(); } notifyUser("Executing netmake"); NetMakeResult result = this.execute(distanceMatrix, coc); notifyUser("Saving results to disk"); result.save(this.options.getOutputNetwork(), this.options.getOutputTree()); this.trackerFinished(true); stopWatch.stop(); log.info("Completed Successfully - Total run time: " + stopWatch.toString()); } catch (Exception e) { log.error(e.getMessage(), e); this.setError(e); this.trackerFinished(false); } finally { this.notifyListener(); } } NetMake();  NetMake(NetMakeOptions options);  NetMake(NetMakeOptions options, StatusTracker statusTracker); NetMakeOptions getOptions(); void setOptions(NetMakeOptions options); NetMakeResult execute(DistanceMatrix distanceMatrix, CircularOrderingCreator circularOrderingCreator); @Override void run();  }