Example #1
0
 private static String addFileList(String script, String tag) {
   String fileList = "";
   int i = -1;
   while ((i = script.indexOf(tag, i + 1)) >= 0) {
     fileList += Parser.getNextQuotedString(script, i) + "\n";
   }
   return fileList;
 }
Example #2
0
 protected void readAtomCountAndOrigin() throws Exception {
   String atomLine = br.readLine();
   String[] tokens = Parser.getTokens(atomLine, 0);
   atomCount = parseInt(tokens[0]);
   negativeAtomCount = (atomCount < 0); // MO list
   if (negativeAtomCount) atomCount = -atomCount;
   volumetricOrigin.set(parseFloat(tokens[1]), parseFloat(tokens[2]), parseFloat(tokens[3]));
   JvxlReader.jvxlCheckAtomLine(
       isXLowToHigh, isAngstroms, tokens[0], atomLine, jvxlFileHeaderBuffer);
   if (!isAngstroms) volumetricOrigin.scale(ANGSTROMS_PER_BOHR);
 }
  static String determineFileType(BufferedReader bufferedReader) {
    // JVXL should be on the FIRST line of the file, but it may be
    // after comments or missing.

    // Apbs, Jvxl, or Cube

    String line;
    LimitedLineReader br = new LimitedLineReader(bufferedReader, 16000);
    // sure bets, but not REQUIRED:
    if ((line = br.info()).indexOf("#JVXL+") == 0) return "Jvxl+";
    if (line.indexOf("#JVXL") == 0) return "Jvxl";
    if (line.indexOf("&plot") == 0) return "Jaguar";
    if (line.indexOf("!NTITLE") >= 0 || line.indexOf("REMARKS ") >= 0) return "Xplor";
    line = br.readNonCommentLine();
    if (line.indexOf("object 1 class gridpositions counts") == 0) return "Apbs";

    // Jvxl, or Cube, maybe formatted Plt

    String[] tokens = Parser.getTokens(line);
    line = br.readNonCommentLine(); // second line
    if (tokens.length == 2
        && Parser.parseInt(tokens[0]) == 3
        && Parser.parseInt(tokens[1]) != Integer.MIN_VALUE) {
      tokens = Parser.getTokens(line);
      if (tokens.length == 3
          && Parser.parseInt(tokens[0]) != Integer.MIN_VALUE
          && Parser.parseInt(tokens[1]) != Integer.MIN_VALUE
          && Parser.parseInt(tokens[2]) != Integer.MIN_VALUE) return "PltFormatted";
    }
    line = br.readNonCommentLine(); // third line
    // next line should be the atom line
    int nAtoms = Parser.parseInt(line);
    if (nAtoms == Integer.MIN_VALUE) return (line.indexOf("+") == 0 ? "Jvxl+" : "UNKNOWN");
    if (nAtoms >= 0) return "Cube"; // Can't be a Jvxl file
    nAtoms = -nAtoms;
    for (int i = 4 + nAtoms; --i >= 0; )
      if ((line = br.readNonCommentLine()) == null) return "UNKNOWN";
    int nSurfaces = Parser.parseInt(line);
    if (nSurfaces == Integer.MIN_VALUE) return "UNKNOWN";
    return (nSurfaces < 0 ? "Jvxl" : "Cube"); // Final test looks at surface definition line
  }
 int parseInt(String s) {
   next[0] = 0;
   return Parser.parseInt(s, next);
 }
 int parseInt() {
   return Parser.parseInt(line, next);
 }
 float parseFloatNext(String s) {
   return Parser.parseFloat(s, next);
 }
 float parseFloat(String s) {
   next[0] = 0;
   return Parser.parseFloat(s, next);
 }
 float parseFloat() {
   return Parser.parseFloat(line, next);
 }
 public static String[] getTokens(String s) {
   return Parser.getTokens(s);
 }
 protected String parseToken(String s, int iStart, int iEnd) {
   next[0] = iStart;
   return Parser.parseToken(s, iEnd, next);
 }
 protected static String parseTrimmed(String s, int iStart, int iEnd) {
   return Parser.parseTrimmed(s, iStart, iEnd);
 }
 protected String parseToken(String s) {
   next[0] = 0;
   return Parser.parseToken(s, next);
 }
 protected String parseTokenNext(String s) {
   return Parser.parseToken(s, next);
 }
 protected String parseToken() {
   return Parser.parseToken(line, next);
 }
 protected int parseInt(String s, int iStart, int iEnd) {
   next[0] = iStart;
   return Parser.parseInt(s, iEnd, next);
 }
 protected static String[] getTokens(String s, int iStart) {
   return Parser.getTokens(s, iStart);
 }
 int parseIntNext(String s) {
   return Parser.parseInt(s, next);
 }
 protected String[] getTokens() {
   return Parser.getTokens(line);
 }
 int parseInt(String s, int iStart) {
   next[0] = iStart;
   return Parser.parseInt(s, next);
 }
 String[] getTokens() {
   return Parser.getTokens(line, 0);
 }
 protected void parseStringInfestedFloatArray(String s, float[] data) {
   Parser.parseStringInfestedFloatArray(s, null, data);
 }
 protected static float[] getTokensFloat(String s, float[] f, int n) {
   if (f == null) f = new float[n];
   Parser.parseFloatArray(getTokens(s), f, n);
   return f;
 }