public GaussianParserTest() throws Exception { IBIOMESConfiguration.getInstance(TestCommon.TEST_IBIOMES_CONFIG_FILE, true); }
/** * Parse CHARMM parameter file * * @param filePath * @throws Exception */ private void parseFile() throws Exception { ArrayList<String> lines = new ArrayList<String>(); IBIOMESFileReader br = null; String line = null; boolean append = false; boolean appendCurrent = false; int nLines = 0; try { br = new IBIOMESFileReader(this); while ((line = br.readLine()) != null) { line = line.trim(); if (!line.startsWith("!") && !line.startsWith("*") && line.length() > 0) { int indexComment = line.indexOf('!'); if (indexComment != -1) line = line.substring(0, indexComment).trim(); appendCurrent = append; if (line.endsWith(" -")) { line = line.substring(0, line.lastIndexOf(" -")).trim(); append = true; } else append = false; if (!appendCurrent) { lines.add(line); nLines++; } else { String concatLine = lines.get(nLines - 1) + " " + line; lines.remove(nLines - 1); lines.add(concatLine); } } } br.close(); for (String entry : lines) { entry = entry.toLowerCase(); int index = entry.indexOf(' '); if (index > 0) { // use first word as keyword String key = entry.substring(0, index); // put rest of values in array String[] values = entry.substring(index + 1).split("\\s+"); List<String> valueList = Arrays.asList(values); parameters.put(key, valueList); } } ExperimentTask task = CHARMMKeywordMapper.mapKeysToTask(parameters); this.tasks = new ArrayList<ExperimentTask>(); this.tasks.add(task); } catch (Exception e) { this.format = LocalFile.FORMAT_UNKNOWN; if (IBIOMESConfiguration.getInstance().isOutputToConsole()) System.out.println( "WARNING: cannot parse '" + this.getAbsolutePath() + "' as a CHARMM input file."); if (IBIOMESConfiguration.getInstance().isOutputErrorStackToConsole()) e.printStackTrace(); if (br != null) { try { br.close(); } catch (Exception e2) { e.printStackTrace(); } } throw e; } }