@Test public void testCharBlock() throws IOException { File testFile = FileUtils.toFile(NexusReaderTest.class.getResource("/gallwasps_aln.nex")); Nexus nexus = new NexusReader().parse(testFile); assertTrue(nexus.getAlignments().size() == 80); }
public Nexus parse(File file) throws IOException { CharStream in = new ANTLRInputStream(new FileInputStream(file)); NexusFileLexer lexer = new NexusFileLexer(in); lexer.removeErrorListeners(); lexer.addErrorListener(new DefaultParsingErrorListener()); CommonTokenStream tokens = new CommonTokenStream(lexer); Nexus nexus = new Nexus(); NexusFileParser parser = new NexusFileParser(tokens); parser.removeParseListeners(); parser.removeErrorListeners(); parser.addParseListener(new NexusFilePopulator(nexus, true)); parser.addErrorListener(new DefaultParsingErrorListener()); parser.setErrorHandler(new DefaultParsingErrorStrategy()); try { parser.parse(); } catch (RuntimeException e) { throw new IOException("Error parsing: " + file.getAbsolutePath() + "; " + e.getMessage(), e); } return nexus; }
NexusReader extends AbstractSpectreReader { public Nexus parse(File file) throws IOException { CharStream in = new ANTLRInputStream(new FileInputStream(file)); NexusFileLexer lexer = new NexusFileLexer(in); lexer.removeErrorListeners(); lexer.addErrorListener(new DefaultParsingErrorListener()); CommonTokenStream tokens = new CommonTokenStream(lexer); Nexus nexus = new Nexus(); NexusFileParser parser = new NexusFileParser(tokens); parser.removeParseListeners(); parser.removeErrorListeners(); parser.addParseListener(new NexusFilePopulator(nexus, true)); parser.addErrorListener(new DefaultParsingErrorListener()); parser.setErrorHandler(new DefaultParsingErrorStrategy()); try { parser.parse(); } catch (RuntimeException e) { throw new IOException("Error parsing: " + file.getAbsolutePath() + "; " + e.getMessage(), e); } return nexus; } }
NexusReader extends AbstractSpectreReader { public Nexus parse(File file) throws IOException { CharStream in = new ANTLRInputStream(new FileInputStream(file)); NexusFileLexer lexer = new NexusFileLexer(in); lexer.removeErrorListeners(); lexer.addErrorListener(new DefaultParsingErrorListener()); CommonTokenStream tokens = new CommonTokenStream(lexer); Nexus nexus = new Nexus(); NexusFileParser parser = new NexusFileParser(tokens); parser.removeParseListeners(); parser.removeErrorListeners(); parser.addParseListener(new NexusFilePopulator(nexus, true)); parser.addErrorListener(new DefaultParsingErrorListener()); parser.setErrorHandler(new DefaultParsingErrorStrategy()); try { parser.parse(); } catch (RuntimeException e) { throw new IOException("Error parsing: " + file.getAbsolutePath() + "; " + e.getMessage(), e); } return nexus; }  }
NexusReader extends AbstractSpectreReader { public Nexus parse(File file) throws IOException { CharStream in = new ANTLRInputStream(new FileInputStream(file)); NexusFileLexer lexer = new NexusFileLexer(in); lexer.removeErrorListeners(); lexer.addErrorListener(new DefaultParsingErrorListener()); CommonTokenStream tokens = new CommonTokenStream(lexer); Nexus nexus = new Nexus(); NexusFileParser parser = new NexusFileParser(tokens); parser.removeParseListeners(); parser.removeErrorListeners(); parser.addParseListener(new NexusFilePopulator(nexus, true)); parser.addErrorListener(new DefaultParsingErrorListener()); parser.setErrorHandler(new DefaultParsingErrorStrategy()); try { parser.parse(); } catch (RuntimeException e) { throw new IOException("Error parsing: " + file.getAbsolutePath() + "; " + e.getMessage(), e); } return nexus; }  Nexus parse(File file); @Override DistanceMatrix readDistanceMatrix(File file); @Override Sequences readAlignment(File file); @Override Locations readLocations(File file); @Override List<NewickTree> readTrees(File input, double weight); @Override SplitSystem readSplitSystem(File file); @Override String[] commonFileExtensions(); @Override String getIdentifier(); @Override boolean acceptsDataType(SpectreDataType spectreDataType); IdentifierList extractCircOrdering(File file); List<String> extractBlock(File file, String blockName); Nexus readNexusData(File inFile); }
NexusReader extends AbstractSpectreReader { public Nexus parse(File file) throws IOException { CharStream in = new ANTLRInputStream(new FileInputStream(file)); NexusFileLexer lexer = new NexusFileLexer(in); lexer.removeErrorListeners(); lexer.addErrorListener(new DefaultParsingErrorListener()); CommonTokenStream tokens = new CommonTokenStream(lexer); Nexus nexus = new Nexus(); NexusFileParser parser = new NexusFileParser(tokens); parser.removeParseListeners(); parser.removeErrorListeners(); parser.addParseListener(new NexusFilePopulator(nexus, true)); parser.addErrorListener(new DefaultParsingErrorListener()); parser.setErrorHandler(new DefaultParsingErrorStrategy()); try { parser.parse(); } catch (RuntimeException e) { throw new IOException("Error parsing: " + file.getAbsolutePath() + "; " + e.getMessage(), e); } return nexus; }  Nexus parse(File file); @Override DistanceMatrix readDistanceMatrix(File file); @Override Sequences readAlignment(File file); @Override Locations readLocations(File file); @Override List<NewickTree> readTrees(File input, double weight); @Override SplitSystem readSplitSystem(File file); @Override String[] commonFileExtensions(); @Override String getIdentifier(); @Override boolean acceptsDataType(SpectreDataType spectreDataType); IdentifierList extractCircOrdering(File file); List<String> extractBlock(File file, String blockName); Nexus readNexusData(File inFile);  }