return new FeaturesFile();
}
},
+ FeatureSettings("Jalview Feature Settings File","fc",false,false)
+ {
+ @Override
+ public AlignmentFileReaderI getReader(FileParse source)
+ throws IOException
+ {
+ return null;
+ }
+
+ @Override
+ public AlignmentFileWriterI getWriter(AlignmentI al)
+ {
+ return null;
+ }
+ },
ScoreMatrix("Substitution matrix", "", false, false)
{
@Override
public class IdentifyFile
{
+ private static final String XMLHEADER = "<?XML VERSION=\"1.0\" ENCODING=\"UTF-8\" STANDALONE=\"YES\"?>";
+
public FileFormatI identify(Object file, DataSourceType protocol)
throws FileFormatException
{
String data;
int bytesRead = 0;
int trimmedLength = 0;
+ boolean isXml = false; // set true if first line is XMLHEADER
boolean lineswereskipped = false;
boolean isBinary = false; // true if length is non-zero and non-printable
// characters are encountered
reply = FileFormat.ScoreMatrix;
break;
}
+ if (data.startsWith(XMLHEADER) && !lineswereskipped)
+ {
+ isXml = true;
+ }
if (data.startsWith("LOCUS"))
{
reply = FileFormat.GenBank;
reply = FileFormat.Rnaml;
break;
}
+ if (isXml && data.contains("<NS2:JALVIEWUSERCOLOURS SCHEMENAME=\"SEQUENCE FEATURES\" XMLNS:NS2=\"WWW.JALVIEW.ORG/COLOURS\">"))
+ {
+ reply = FileFormat.FeatureSettings;
+ break;
+ }
}
if ((data.length() < 1) || (data.indexOf("#") == 0))
import jalview.datamodel.features.FeatureMatcherSet;
import jalview.datamodel.features.FeatureMatcherSetI;
import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
+import jalview.io.FileFormatI;
import jalview.io.FileLoader;
+import jalview.io.IdentifyFile;
import jalview.schemes.FeatureColour;
import jalview.schemes.FeatureColourTest;
import jalview.util.matcher.Condition;
"<html>By Score (> 4.0)<br>" + simpleTooltip
+ "</br></html>");
}
+ String fsfile="<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><ns2:JalviewUserColours schemeName=\"Sequence Features\" xmlns:ns2=\"www.jalview.org/colours\">",fsfile2="<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<ns2:JalviewUserColours schemeName=\"Sequence Features\" xmlns:ns2=\"www.jalview.org/colours\">";
+ @Test(groups="Functional")
+ public void testIdentifyFeatureSettingsFile() throws Exception
+ {
+ FileFormatI type = new IdentifyFile().identify(fsfile, DataSourceType.PASTE);
+ assertTrue(FileFormat.FeatureSettings==type,"Feature settings file was identified as "+type);
+ type = new IdentifyFile().identify(fsfile2, DataSourceType.PASTE);
+ assertTrue(FileFormat.FeatureSettings==type,"Feature settings file with newline was identified as "+type);
+ }
}