} catch (IOException ex)
{
}
- ;
if (dta != null && dta.indexOf("*") > -1)
{
starterm = true;
// read as a FASTA (probably)
break;
}
- if ((data.indexOf("<") > -1)) // possible Markup Language data i.e HTML,
+ int lessThan = data.indexOf("<");
+ if ((lessThan > -1)) // possible Markup Language data i.e HTML,
// RNAML, XML
{
- // FIXME this is nuts - it consumes the rest of the file if no match
- boolean identified = false;
- do
- {
- if (data.matches("<(?i)html(\"[^\"]*\"|'[^']*'|[^'\">])*>"))
- {
- reply = HtmlFile.FILE_DESC;
- identified = true;
- break;
- }
-
- if (data.matches("<(?i)rnaml (\"[^\"]*\"|'[^']*'|[^'\">])*>"))
- {
- reply = "RNAML";
- identified = true;
- break;
- }
- } while ((data = source.nextLine()) != null);
-
- if (identified)
+ String upper = data.toUpperCase();
+ if (upper.substring(lessThan).startsWith("<HTML"))
{
+ reply = HtmlFile.FILE_DESC;
break;
}
- if (data == null)
+ if (upper.substring(lessThan).startsWith("<RNAML"))
{
+ reply = "RNAML";
break;
}
}
*/
package jalview.io;
+import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertFalse;
import static org.testng.AssertJUnit.assertTrue;
}
/**
- * Additional tests for (a) Jalview features file with no colour
- * specifications (old style 'groups' file) and (b) Jalview features file with
- * embedded GFF
+ * Additional tests for Jalview features file
*/
@Test(groups = "Functional")
public void testIdentify_featureFile()
{
IdentifyFile ider = new IdentifyFile();
- // Jalview format with features only, no feature colours
+ /*
+ * Jalview format with features only, no feature colours
+ */
String data = "Iron-sulfur (2Fe-2S)\tFER_CAPAA\t-1\t39\t39\tMETAL\n"
+ "Iron-phosphorus (2Fe-P)\tID_NOT_SPECIFIED\t2\t86\t87\tMETALLIC\n";
- Assert.assertEquals(IdentifyFile.FeaturesFile, ider.identify(data, AppletFormatAdapter.PASTE));
+ assertEquals(IdentifyFile.FeaturesFile,
+ ider.identify(data, AppletFormatAdapter.PASTE));
- // Jalview feature colour followed by GFF format feature data
+ /*
+ * Jalview feature colour followed by GFF format feature data
+ */
data = "METAL\tcc9900\n" + "GFF\n"
+ "FER_CAPAA\tuniprot\tMETAL\t44\t45\t4.0\t.\t.\n";
- Assert.assertEquals(IdentifyFile.FeaturesFile,
+ assertEquals(IdentifyFile.FeaturesFile,
+ ider.identify(data, AppletFormatAdapter.PASTE));
+
+ /*
+ * Feature with '<' in the name (JAL-2098)
+ */
+ data = "kD < 3\tred\n" + "Low kD\tFER_CAPAA\t-1\t39\t39\tkD < 3\n";
+ assertEquals(IdentifyFile.FeaturesFile,
ider.identify(data, AppletFormatAdapter.PASTE));
}