SEQUENCE_GROUP Group_B 1 351 2-5
SEQUENCE_GROUP Group_C 12 14 -1 seq1 seq2 seq3
PROPERTIES Group_A description=This is the description colour=Helix Propensity pidThreshold=0 outlineColour=red displayBoxes=true displayText=false colourText=false textCol1=black textCol2=black textColThreshold=0
-PROPERTIES Group_B outlineColour=red
+PROPERTIES Group_B outlineColour=red colour=None
PROPERTIES Group_C colour=Clustal
*/
public class ViewDef
{
- public String viewname;
+ // TODO this class is not used - remove?
+ public final String viewname;
- public HiddenSequences hidseqs;
+ public final HiddenSequences hidseqs;
- public ColumnSelection hiddencols;
+ public final ColumnSelection hiddencols;
- public Vector visibleGroups;
+ // public final Vector visibleGroups;
- public Hashtable hiddenRepSeqs;
+ public final Hashtable hiddenRepSeqs;
- public ViewDef(String viewname, HiddenSequences hidseqs,
- ColumnSelection hiddencols, Hashtable hiddenRepSeqs)
+ public ViewDef(String vname, HiddenSequences hseqs,
+ ColumnSelection hcols, Hashtable hRepSeqs)
{
- this.viewname = viewname;
- this.hidseqs = hidseqs;
- this.hiddencols = hiddencols;
- this.hiddenRepSeqs = hiddenRepSeqs;
+ this.viewname = vname;
+ this.hidseqs = hseqs;
+ this.hiddencols = hcols;
+ this.hiddenRepSeqs = hRepSeqs;
}
}
}
if (list == null)
{
- list = view.visibleGroups;
+ // list = view.visibleGroups;
}
if (cs == null)
{
return false;
}
- public void printGroups(List<SequenceGroup> list)
+ protected void printGroups(List<SequenceGroup> list)
{
SequenceI seqrep = null;
for (SequenceGroup sg : list)
if (sg.cs != null)
{
text.append("colour=");
- text.append(sg.cs.toString());
+ text.append(ColourSchemeProperty.getColourName(sg.cs
+ .getColourScheme()));
text.append("\t");
if (sg.cs.getThreshold() != 0)
{
import jalview.json.binding.biojson.v1.SequenceGrpPojo;
import jalview.json.binding.biojson.v1.SequencePojo;
import jalview.renderer.seqfeatures.FeatureColourFinder;
+import jalview.schemes.ColourSchemeProperty;
import jalview.schemes.JalviewColourScheme;
import jalview.schemes.ResidueColourScheme;
import jalview.util.ColorUtils;
{
SequenceGrpPojo seqGrpPojo = new SequenceGrpPojo();
seqGrpPojo.setGroupName(seqGrp.getName());
- seqGrpPojo.setColourScheme(seqGrp.getColourScheme()
- .getSchemeName());
+ seqGrpPojo.setColourScheme(ColourSchemeProperty
+ .getColourName(seqGrp.getColourScheme()));
seqGrpPojo.setColourText(seqGrp.getColourText());
seqGrpPojo.setDescription(seqGrp.getDescription());
seqGrpPojo.setDisplayBoxes(seqGrp.getDisplayBoxes());
}
}
}
- globalColourScheme = (viewport.getGlobalColourScheme() == null) ? ResidueColourScheme.NONE
- : viewport.getGlobalColourScheme().getSchemeName();
+ globalColourScheme = ColourSchemeProperty.getColourName(viewport
+ .getGlobalColourScheme());
setDisplayedFeatures(viewport.getFeaturesDisplayed());
showSeqFeatures = viewport.isShowSequenceFeatures();
.equalsIgnoreCase(seqCoordSys.getName())
&& isAccessionMatched(cRefDb.getDbAccessionId()))
{
- String resNumIndexString = cRefDb.getDbResNum()
- .equalsIgnoreCase("None") ? String.valueOf(UNASSIGNED)
- : cRefDb.getDbResNum();
- try
- {
- currSeqIndex = Integer.valueOf(resNumIndexString);
- } catch (NumberFormatException nfe)
- {
- currSeqIndex = Integer.valueOf(resNumIndexString
- .split("[a-zA-Z]")[0]);
- continue;
- }
+ currSeqIndex = getLeadingIntegerValue(
+ cRefDb.getDbResNum(), UNASSIGNED);
if (pdbRefDb != null)
{
break;// exit loop if pdb and uniprot are already found
}
if (currSeqIndex >= seq.getStart() && currSeqIndex <= seq.getEnd())
{
- int resNum;
- try
- {
- resNum = (pdbRefDb == null) ? Integer.valueOf(residue
- .getDbResNum()) : Integer.valueOf(pdbRefDb
- .getDbResNum());
- } catch (NumberFormatException nfe)
- {
- if (pdbRefDb == null || pdbRefDb.getDbResNum().equals("null"))
- {
- resNum = UNASSIGNED;
- continue;
- }
- resNum = Integer.valueOf(pdbRefDb
- .getDbResNum().split("[a-zA-Z]")[0]);
- continue;
- }
+
+ int resNum = (pdbRefDb == null) ? getLeadingIntegerValue(
+ residue.getDbResNum(), UNASSIGNED)
+ : getLeadingIntegerValue(pdbRefDb.getDbResNum(),
+ UNASSIGNED);
if (isResidueObserved(residue)
|| seqCoordSys == CoordinateSys.UNIPROT)
}
/**
+ * Get the leading integer part of a string that begins with an integer.
+ *
+ * @param input
+ * - the string input to process
+ * @param failValue
+ * - value returned if unsuccessful
+ * @return
+ */
+ static int getLeadingIntegerValue(String input, int failValue)
+ {
+ if (input == null)
+ {
+ return failValue;
+ }
+ String[] parts = input.split("(?=\\D)(?<=\\d)");
+ if (parts != null && parts.length > 0 && parts[0].matches("[0-9]+"))
+ {
+ return Integer.valueOf(parts[0]);
+ }
+ return failValue;
+ }
+
+
+ /**
*
* @param chainId
* Target chain to populate mapping of its atom positions.
assertEquals("Cached PDB Entries", filterOpt.getName());
}
- @Test(groups = { "Functional" })
+ @Test(groups = { "Network" })
public void fetchStructuresInfoTest()
{
SequenceI[] selectedSeqs = new SequenceI[] { seq };
DataSourceType.FILE));
AnnotationFile aff = new AnnotationFile();
+ // ViewDef is not used by Jalview
ViewDef v = aff.new ViewDef(null, al.getHiddenSequences(), cs,
new Hashtable());
String anfileout = new AnnotationFile().printAnnotations(
expectedSeqs.put(seq.getName(), seq);
}
- // create and add sequence groups
- ArrayList<SequenceI> grpSeqs = new ArrayList<SequenceI>();
+ // create and add a sequence group
+ List<SequenceI> grpSeqs = new ArrayList<SequenceI>();
grpSeqs.add(seqs[1]);
grpSeqs.add(seqs[2]);
grpSeqs.add(seqs[3]);
grpSeqs.add(seqs[4]);
- SequenceGroup seqGrp = new SequenceGroup(grpSeqs, "JGroup:1883305585",
+ SequenceGroup seqGrp = new SequenceGroup(grpSeqs,
+ "JGroup:1883305585",
null, true, true, false, 21, 29);
ColourSchemeI scheme = ColourSchemeMapper.getJalviewColourScheme(
"zappo", seqGrp);
"Zappo colour scheme expected!");
}
- @Test(groups = { "Functional" })
/**
- * Test for bug JAL-2489, NPE when exporting BioJSON with global colour scheme set as 'None'
+ * Test for bug JAL-2489, NPE when exporting BioJSON with global colour
+ * scheme, and a group colour scheme, set as 'None'
*/
- public void testBioJSONRoundTripWithGlobalColourSchemeSetAsNone()
+ @Test(groups = { "Functional" })
+ public void testBioJSONRoundTripWithColourSchemeNone()
{
AppletFormatAdapter formatAdapter = new AppletFormatAdapter();
bioJsonFile.getHiddenSequences(),
bioJsonFile.getColumnSelection(), AlignFrame.DEFAULT_WIDTH,
AlignFrame.DEFAULT_HEIGHT);
- // Change colour scheme to 'None' and perform round trip
+
+ /*
+ * Create a group on the alignment;
+ * Change global and group colour scheme to 'None' and perform round trip
+ */
+ SequenceGroup sg = new SequenceGroup();
+ sg.addSequence(_alignment.getSequenceAt(0), false);
+ sg.setColourScheme(null);
ColourSchemeI cs = ColourSchemeMapper.getJalviewColourScheme(
ResidueColourScheme.NONE, _alignment);
alignFrame.changeColour(cs);
// System.out.println(">>>>>>>>>>>>>> features matched : " + matched);
return matched;
}
+
+ /**
+ * Test group roundtrip with null (None) group colour scheme
+ *
+ * @throws IOException
+ */
+ @Test(groups = { "Functional" })
+ public void testGrpParsed_colourNone() throws IOException
+ {
+ AlignmentI copy = new Alignment(testAlignment);
+ SequenceGroup sg = testAlignment.getGroups().get(0);
+ SequenceGroup copySg = new SequenceGroup(new ArrayList<SequenceI>(),
+ sg.getName(),
+ null, sg.getDisplayBoxes(), sg.getDisplayText(),
+ sg.getColourText(), sg.getStartRes(), sg.getEndRes());
+ for (SequenceI seq : sg.getSequences())
+ {
+ int seqIndex = testAlignment.findIndex(seq);
+ copySg.addSequence(copy.getSequenceAt(seqIndex), false);
+ }
+ copy.addGroup(copySg);
+
+ AlignFrame af = new AlignFrame(copy, copy.getWidth(), copy.getHeight());
+ AppletFormatAdapter formatAdapter = new AppletFormatAdapter(
+ af.alignPanel);
+ String jsonOutput = formatAdapter.formatSequences(FileFormat.Json,
+ copy, false);
+ formatAdapter = new AppletFormatAdapter();
+ AlignmentI newAlignment = formatAdapter.readFile(jsonOutput,
+ DataSourceType.PASTE, FileFormat.Json);
+
+ Assert.assertNotNull(newAlignment.getGroups());
+ for (SequenceGroup seqGrp : newAlignment.getGroups())
+ {
+ SequenceGroup expectedGrp = expectedGrps.get(seqGrp.getName());
+ AssertJUnit.assertTrue(
+ "Failed SequenceGroup Test for >>> " + seqGrp.getName(),
+ isGroupMatched(expectedGrp, seqGrp));
+ passedCount++;
+ }
+ AssertJUnit.assertEquals("Some SequenceGroups did not pass the test",
+ TEST_GRP_HEIGHT, passedCount);
+ }
}
disc = JalviewJabawsTestUtils.getJabawsDiscoverer();
}
- @Test(groups = { "Functional" })
+ @Test(groups = { "Network" })
public void testWriteParameterSet() throws WrongParameterException
{
for (Jws2Instance service : disc.getServices())
Assert.assertNull(entityP);
}
+
+ @Test(groups = { "Network" })
+ public void getLeadingIntegerFromString()
+ {
+ Assert.assertEquals(
+ SiftsClient.getLeadingIntegerValue("1234abcd", -1), 1234);
+ Assert.assertEquals(
+ SiftsClient.getLeadingIntegerValue("1234", -1),
+ 1234);
+ Assert.assertEquals(
+ SiftsClient.getLeadingIntegerValue("abcd", -1), -1);
+ Assert.assertEquals(
+ SiftsClient.getLeadingIntegerValue("abcd1234", -1), -1);
+ Assert.assertEquals(
+ SiftsClient.getLeadingIntegerValue("None", -1), -1);
+ Assert.assertEquals(
+ SiftsClient.getLeadingIntegerValue("Null", -1), -1);
+ }
}