quick fix for verbose fortranesque comments in preamble of AMPS BLC files (lines...
authorjprocter <Jim Procter>
Thu, 26 Apr 2007 11:24:42 +0000 (11:24 +0000)
committerjprocter <Jim Procter>
Thu, 26 Apr 2007 11:24:42 +0000 (11:24 +0000)
src/jalview/io/IdentifyFile.java

index 7f3db40..a8d93d5 100755 (executable)
@@ -66,6 +66,7 @@ public class IdentifyFile
   public String Identify(FileParse source, boolean closeSource) {
     String reply = "PFAM";
     String data;
+    boolean lineswereskipped=false;
     try {
       while ( (data = source.nextLine()) != null)
       {
@@ -78,8 +79,9 @@ public class IdentifyFile
           break;
         }
 
-        if ( (data.indexOf("#") == 0) || (data.length() < 1))
+        if ((data.length() < 1) || (data.indexOf("#") == 0))
         {
+          lineswereskipped=true;
           continue;
         }
 
@@ -146,7 +148,10 @@ public class IdentifyFile
           reply = "PDB";
           break;
         }
-        else if (data.indexOf(":") < data.indexOf(",")) //  && data.indexOf(",")<data.indexOf(",", data.indexOf(",")))
+        else if (!lineswereskipped 
+                && data.charAt(0)!='*' 
+                  && data.charAt(0)!=' ' 
+                    && data.indexOf(":") < data.indexOf(",")) //  && data.indexOf(",")<data.indexOf(",", data.indexOf(",")))
         {
           // file looks like a concise JNet file
           reply = "JnetFile";
@@ -164,6 +169,8 @@ public class IdentifyFile
           reply="Jalview"; // archive.
           break;
         }
+        
+        lineswereskipped=true; // this means there was some junk before any key file signature  
       }
       if (closeSource) {
         source.close();