if (value != null)
{
value = value.trim();
+ if (value.isEmpty())
+ {
+ return;
+ }
/*
* Parse numeric value unless we have previously
* seen text data for this attribute type
*/
- if (type == null && couldBeNumber(value) || type == Datatype.Number)
+ if ((type == null && couldBeNumber(value))
+ || type == Datatype.Number)
{
try
{
hasValue = false;
}
}
+ else
+ {
+ /*
+ * if not a number, and not seen before...
+ */
+ type = Datatype.Character;
+ min = 0f;
+ max = 0f;
+ hasValue = false;
+ }
}
}
/**
- * Answers the description of the attribute, if recorded and unique, or null if either no, or more than description is recorded
+ * Answers the description of the attribute, if recorded and unique, or null
+ * if either no, or more than description is recorded
+ *
* @return
*/
public String getDescription()
}
/**
- * This quick check will save significant time avoiding numerous NumberFormatExceptions.
+ * A partial check that the string is numeric - only checks the first
+ * character. Returns true if the first character is a digit, or if it is '.',
+ * '+' or '-' and not the only character. Otherwise returns false (including
+ * for an empty string). Note this is not a complete check as it returns true
+ * for (e.g.) "1A".
*
* @param f
* @return
*/
- public boolean couldBeNumber(String f)
+ public static boolean couldBeNumber(String f)
{
int len = f.length();
if (len == 0)
+ {
return false;
+ }
char ch = f.charAt(0);
- switch (ch) {
+ switch (ch)
+ {
case '.':
case '+':
case '-':
return len > 1;
}
- return (ch <= '9' && ch >= '0');
+ return (ch <= '9' && ch >= '0');
}
/**
{
return;
}
-
+
Map<String[], AttributeData> atts = attributes.get(featureType);
if (atts == null)
{
Boolean.toString(structFromPdb.isSelected()));
if (!Platform.isJS())
{
- Cache.setPropertyNoSave(STRUCTURE_DISPLAY,
- structViewer.getSelectedItem().toString());
+ Cache.setPropertyNoSave(STRUCTURE_DISPLAY,
+ structViewer.getSelectedItem().toString());
}
Cache.setOrRemove(CHIMERA_PATH, chimeraPath.getText());
Cache.setPropertyNoSave("MAP_WITH_SIFTS",
{
if (mappings != null)
{
- mappings.clear();
+ mappings.clear();
}
if (seqmappings != null)
{
- seqmappings.clear();
+ seqmappings.clear();
}
if (sel_listeners != null)
{
- sel_listeners.clear();
+ sel_listeners.clear();
}
if (listeners != null)
{
- listeners.clear();
+ listeners.clear();
}
if (commandListeners != null)
{
- commandListeners.clear();
+ commandListeners.clear();
}
if (view_listeners != null)
{
- view_listeners.clear();
+ view_listeners.clear();
}
if (pdbFileNameId != null)
{
- pdbFileNameId.clear();
+ pdbFileNameId.clear();
}
if (pdbIdFileName != null)
{
- pdbIdFileName.clear();
+ pdbIdFileName.clear();
}
}
* Test the method that keeps attribute names in non-case-sensitive order,
* including handling of 'compound' names
*/
- @Test(groups="Functional")
+ @Test(groups = "Functional")
public void testAttributeNameComparator()
{
FeatureAttributes fa = FeatureAttributes.getInstance();
"comparator");
assertEquals(
- comp.compare(new String[] { "CSQ" }, new String[] { "csq" }), 0);
+ comp.compare(new String[]
+ { "CSQ" }, new String[] { "csq" }), 0);
- assertTrue(comp.compare(new String[] { "CSQ", "a" },
- new String[] { "csq" }) > 0);
+ assertTrue(
+ comp.compare(new String[]
+ { "CSQ", "a" }, new String[] { "csq" }) > 0);
- assertTrue(comp.compare(new String[] { "CSQ" }, new String[] { "csq",
- "b" }) < 0);
+ assertTrue(
+ comp.compare(new String[]
+ { "CSQ" }, new String[] { "csq", "b" }) < 0);
- assertTrue(comp.compare(new String[] { "CSQ", "AF" }, new String[] {
- "csq", "ac" }) > 0);
+ assertTrue(
+ comp.compare(new String[]
+ { "CSQ", "AF" }, new String[] { "csq", "ac" }) > 0);
- assertTrue(comp.compare(new String[] { "CSQ", "ac" }, new String[] {
- "csq", "AF" }) < 0);
+ assertTrue(
+ comp.compare(new String[]
+ { "CSQ", "ac" }, new String[] { "csq", "AF" }) < 0);
}
@Test(groups = "Functional")
"group");
sf.setValue("kd", "-1");
sf.setValue("domain", "Metal");
+ sf.setValue("foo", " ");
sf.setValue("phase", "1");
- sf.setValue("phase", "reverse");
+ sf.setValue("phase", "1reverse");
assertEquals(fa.getDatatype("Pfam", "kd"), Datatype.Number);
assertEquals(fa.getDatatype("Pfam", "domain"), Datatype.Character);
assertEquals(fa.getDatatype("Pfam", "phase"), Datatype.Mixed);
+ assertNull(fa.getDatatype("Pfam", "unobserved"));
+ assertNull(fa.getDatatype("Pfam", "foo"));// empty values are ignored
}
}
{
StructureImportSettings.setShowSeqFeatures(true);
ssm = StructureSelectionManager.getStructureSelectionManager(null);
+ ssm.resetAll();
}
@Test(groups = { "Functional" })
ssm.registerMappings(set2);
ssm.registerMappings(set2);
- assertEquals(3, ssm.getSequenceMappings().size());
- assertTrue(ssm.getSequenceMappings().contains(acf1));
- assertTrue(ssm.getSequenceMappings().contains(acf2));
- assertTrue(ssm.getSequenceMappings().contains(acf3));
+ List<AlignedCodonFrame> mappings = ssm.getSequenceMappings();
+ assertEquals(3, mappings.size());
+ assertTrue(mappings.contains(acf1));
+ assertTrue(mappings.contains(acf2));
+ assertTrue(mappings.contains(acf3));
}
/**