action.by_conservation = By Conservation
action.wrap = Wrap
action.show_gaps = Show Gaps
-action.show_occupancy = Show Occupancy
action.show_hidden_markers = Show Hidden Markers
action.find = Find
action.undefine_groups = Undefine Groups
label.invalid_name = Invalid Name !
label.output_seq_details = Output Sequence Details to list all database references
label.urllinks = Links
+label.quality_descr = Alignment Quality based on Blosum62 scores
+label.conservation_descr = Conservation of total alignment less than {0}% gaps
+label.consensus_descr = PID
+label.complement_consensus_descr = PID for cDNA
+label.strucconsensus_descr = PID for base pairs
+label.occupancy_descr = Number of aligned positions
\ No newline at end of file
label.score_model_enhconservation = Conservación de las propiedades físico-químicas
label.status_bar = Barra de estado
label.out_to_textbox = Generar cuadro de texto
+label.occupancy = Ocupación
label.clustal = Clustal
# label.colourScheme_<schemeName> as in JalviewColourScheme
label.colourScheme_clustal = Clustalx
label.updating_vamsas_session = Actualizando sesión VAMSAS
label.loading_file = Cargando fichero: {0}
label.edit_params = Editar {0}
+label.as_percentage = Como Porcentaje
error.not_implemented = No implementado
error.no_such_method_as_clone1_for = No existe ese método como un clone1 de {0}
error.null_from_clone1 = Nulo de clone1!
final int gapped = profile.getNonGapped();
- String description = "";
+ String description = "" + gapped;
- gaprow.annotations[i] = new Annotation(description, description,
+ gaprow.annotations[i] = new Annotation("", description,
'\0', gapped, jalview.util.ColorUtils.bleachColour(
Color.DARK_GRAY, (float) scale * gapped));
}
}
populateThresholdComboBox(threshold);
-
+ AnnotationColumnChooser lastChooser = av
+ .getAnnotationColumnSelectionState();
// restore Object state from the previous session if one exists
- if (av.getAnnotationColumnSelectionState() != null)
+ if (lastChooser != null)
{
- currentSearchPanel = av.getAnnotationColumnSelectionState()
+ currentSearchPanel = lastChooser
.getCurrentSearchPanel();
- currentStructureFilterPanel = av.getAnnotationColumnSelectionState()
+ currentStructureFilterPanel = lastChooser
.getCurrentStructureFilterPanel();
- annotations.select(av.getAnnotationColumnSelectionState()
+ annotations.select(lastChooser
.getAnnotations().getSelectedIndex());
- threshold.select(av.getAnnotationColumnSelectionState()
+ threshold.select(lastChooser
.getThreshold().getSelectedIndex());
- actionOption = av.getAnnotationColumnSelectionState()
+ actionOption = lastChooser
.getActionOption();
+ percentThreshold.setState(lastChooser.percentThreshold.getState());
}
try
ngStructureFilterPanel = new StructureFilterPanel(this);
thresholdPanel.setTitle("Threshold Filter");
- thresholdPanel.add(percentThreshold);
thresholdPanel.add(getThreshold());
thresholdPanel.add(slider);
thresholdPanel.add(thresholdValue);
+ thresholdPanel.add(percentThreshold);
actionPanel.add(ok);
actionPanel.add(cancel);
{
if (!adjusting)
{
- thresholdValue.setText((slider.getValue() / 1000f) + "");
+ setThresholdValueText();
valueChanged(!sliderDragging);
}
}
slider.setEnabled(true);
thresholdValue.setEnabled(true);
+ percentThreshold.setEnabled(true);
if (selectedThresholdItem == AnnotationColourGradient.NO_THRESHOLD)
{
slider.setEnabled(false);
thresholdValue.setEnabled(false);
thresholdValue.setText("");
+ percentThreshold.setEnabled(false);
// build filter params
}
else if (selectedThresholdItem != AnnotationColourGradient.NO_THRESHOLD)
// slider.setMajorTickSpacing((int) (range / 10f));
slider.setEnabled(true);
thresholdValue.setEnabled(true);
+ percentThreshold.setEnabled(true);
adjusting = false;
// build filter params
@Override
public void actionPerformed(ActionEvent evt)
{
- if (evt.getSource() == thresholdValue)
- {
- try
- {
- float f = new Float(thresholdValue.getText()).floatValue();
- slider.setValue((int) (f * 1000));
- adjustmentValueChanged(null);
- } catch (NumberFormatException ex)
- {
- }
- }
- else if (evt.getSource() == ok)
+ if (evt.getSource() == ok)
{
ok_actionPerformed(null);
}
updateView();
}
+ /**
+ * update the text field from the threshold slider. preserves state of
+ * 'adjusting' so safe to call in init.
+ */
protected void setThresholdValueText()
{
+ boolean oldadj = adjusting;
adjusting = true;
if (percentThreshold.getState())
{
double scl = slider.getMaximum() - slider.getMinimum();
scl = (slider.getValue() - slider.getMinimum()) / scl;
- thresholdValue.setText(100 * scl + "");
+ thresholdValue.setText(100f * scl + "");
}
else
{
thresholdValue.setText((slider.getValue() / 1000f) + "");
}
thresholdValue.setCaretPosition(0);
- adjusting = false;
+ adjusting = oldadj;
}
public void thresholdValue_actionPerformed(ActionEvent e)
float f = Float.parseFloat(thresholdValue.getText());
if (percentThreshold.getState())
{
- slider.setValue(slider.getMinimum()
- + ((int) ((f / 100f) * (slider.getMaximum() - slider
- .getMinimum()))));
+ int pos = slider.getMinimum()
+ + (int) ((slider.getMaximum() - slider.getMinimum()) * f / 100f);
+ slider.setValue(pos);
}
else
{
slider.setValue((int) (f * 1000));
}
- updateView();
+ valueChanged(false);
} catch (NumberFormatException ex)
{
}
if (start < fwidth)
{
viscontigs[nvis] = start;
- viscontigs[nvis + 1] = fwidth; // end is inclusive
+ viscontigs[nvis + 1] = fwidth - 1; // end is inclusive
nvis += 2;
}
return viscontigs;
}
else
{
- return new int[] { 0, width };
+ return new int[] { 0, width - 1 };
}
}
/*
* update these constants when Jalview has been checked / updated for
- * changes to Ensembl REST API
+ * changes to Ensembl REST API (ref JAL-2105)
* @see https://github.com/Ensembl/ensembl-rest/wiki/Change-log
* @see http://rest.ensembl.org/info/rest?content-type=application/json
*/
- private static final String LATEST_ENSEMBLGENOMES_REST_VERSION = "4.8";
+ private static final String LATEST_ENSEMBLGENOMES_REST_VERSION = "5.0";
- private static final String LATEST_ENSEMBL_REST_VERSION = "4.8";
+ private static final String LATEST_ENSEMBL_REST_VERSION = "5.0";
private static final String REST_CHANGE_LOG = "https://github.com/Ensembl/ensembl-rest/wiki/Change-log";
boolean laterVersion = StringUtils.compareVersions(version, expected) == 1;
if (laterVersion)
{
- System.err.println(String.format(
- "Expected %s REST version %s but found %s, see %s",
- getDbSource(), expected, version, REST_CHANGE_LOG));
+ System.err
+ .println(String
+ .format("EnsemblRestClient expected %s REST version %s but found %s, see %s",
+ getDbSource(), expected, version,
+ REST_CHANGE_LOG));
}
info.restVersion = version;
} catch (Throwable t)
setAnnotations(new JComboBox<String>(getAnnotationItems(false)));
populateThresholdComboBox(threshold);
-
+ AnnotationColumnChooser lastChooser = av
+ .getAnnotationColumnSelectionState();
// restore Object state from the previous session if one exists
- if (av.getAnnotationColumnSelectionState() != null)
+ if (lastChooser != null)
{
- currentSearchPanel = av.getAnnotationColumnSelectionState()
+ currentSearchPanel = lastChooser
.getCurrentSearchPanel();
- currentStructureFilterPanel = av.getAnnotationColumnSelectionState()
+ currentStructureFilterPanel = lastChooser
.getCurrentStructureFilterPanel();
- annotations.setSelectedIndex(av.getAnnotationColumnSelectionState()
+ annotations.setSelectedIndex(lastChooser
.getAnnotations().getSelectedIndex());
- threshold.setSelectedIndex(av.getAnnotationColumnSelectionState()
+ threshold.setSelectedIndex(lastChooser
.getThreshold().getSelectedIndex());
- actionOption = av.getAnnotationColumnSelectionState()
+ actionOption = lastChooser
.getActionOption();
+ percentThreshold.setSelected(lastChooser.percentThreshold
+ .isSelected());
}
try
slider.setMaximum((int) (getCurrentAnnotation().graphMax * 1000));
slider.setValue((int) (getCurrentAnnotation().threshold.value * 1000));
- if (percentThreshold.isSelected())
- {
- thresholdValue
- .setText(""
- + ((getCurrentAnnotation().threshold.value - getCurrentAnnotation().graphMin) * 100f / (getCurrentAnnotation().graphMax - getCurrentAnnotation().graphMin)));
- }
- else
- {
- thresholdValue.setText(getCurrentAnnotation().threshold.value + "");
- }
+ setThresholdValueText();
slider.setMajorTickSpacing((int) (range / 10f));
slider.setEnabled(true);
});
}
+ /**
+ * update the text field from the threshold slider. preserves state of
+ * 'adjusting' so safe to call in init.
+ */
protected void setThresholdValueText()
{
+ boolean oldadj = adjusting;
adjusting = true;
if (percentThreshold.isSelected())
{
{
thresholdValue.setText((slider.getValue() / 1000f) + "");
}
- adjusting = false;
+ adjusting = oldadj;
}
protected void addSliderMouseListeners()
{
try
{
float f = Float.parseFloat(thresholdValue.getText());
- if (percentThreshold.isEnabled())
+ if (percentThreshold.isSelected())
{
slider.setValue(slider.getMinimum()
+ ((int) ((f / 100f) * (slider.getMaximum() - slider
import jalview.util.Comparison;
import jalview.util.MapList;
import jalview.util.MappingUtils;
+import jalview.util.MessageManager;
import jalview.viewmodel.styles.ViewStyle;
import jalview.workers.AlignCalcManager;
import jalview.workers.ComplementConsensusThread;
{
initRNAStructure();
}
- consensus = new AlignmentAnnotation("Consensus", "PID",
+ consensus = new AlignmentAnnotation("Consensus",
+ MessageManager.getString("label.consensus_descr"),
new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
initConsensus(consensus);
initGapCounts();
if (doConsensus)
{
complementConsensus = new AlignmentAnnotation("cDNA Consensus",
- "PID for cDNA", new Annotation[1], 0f, 100f,
+ MessageManager
+ .getString("label.complement_consensus_descr"),
+ new Annotation[1], 0f, 100f,
AlignmentAnnotation.BAR_GRAPH);
initConsensus(complementConsensus);
return true;
if (showOccupancy)
{
gapcounts = new AlignmentAnnotation("Occupancy",
- "Number of aligned positions", new Annotation[1], 0f,
+ MessageManager.getString("label.occupancy_descr"),
+ new Annotation[1], 0f,
alignment.getHeight(), AlignmentAnnotation.BAR_GRAPH);
gapcounts.hasText = true;
gapcounts.autoCalculated = true;
if (conservation == null)
{
conservation = new AlignmentAnnotation("Conservation",
- "Conservation of total alignment less than "
- + getConsPercGaps() + "% gaps", new Annotation[1],
+ MessageManager.formatMessage("label.conservation_descr",
+ getConsPercGaps()), new Annotation[1],
0f, 11f, AlignmentAnnotation.BAR_GRAPH);
conservation.hasText = true;
conservation.autoCalculated = true;
if (quality == null)
{
quality = new AlignmentAnnotation("Quality",
- "Alignment Quality based on Blosum62 scores",
+ MessageManager.getString("label.quality_descr"),
new Annotation[1], 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
quality.hasText = true;
quality.autoCalculated = true;
{
if (alignment.hasRNAStructure() && strucConsensus == null)
{
- strucConsensus = new AlignmentAnnotation("StrucConsensus", "PID",
+ strucConsensus = new AlignmentAnnotation("StrucConsensus",
+ MessageManager.getString("label.strucconsensus_descr"),
new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
strucConsensus.hasText = true;
strucConsensus.autoCalculated = true;
.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.
import static org.testng.Assert.assertEquals;
+import jalview.gui.AlignFrame;
+import jalview.gui.AlignViewport;
import jalview.gui.JvOptionPane;
+import jalview.io.DataSourceType;
+import jalview.io.FileLoader;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
assertEquals(av.getVisibleAlignment('$').getSequenceAt(0)
.getSequenceAsString(), "A$$CDE");
}
+
+ @Test(groups = { "Functional" })
+ public void testGetVisibleContigs()
+ {
+ AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
+ ">s1\n0123456789\n", DataSourceType.PASTE);
+ AlignViewport av = af.getViewport();
+ AlignmentView view = av.getAlignmentView(true);
+
+ /*
+ * verify getVisibleContigs returns inclusive [start, end] ranges
+ *
+ * no columns hidden
+ */
+ int[] contigs = view.getVisibleContigs();
+ assertEquals(contigs, new int[] { 0, 9 });
+
+ /*
+ * hide 3 internal columns
+ */
+ av.hideColumns(5, 7);
+ // the old AlignmentView is now stale!
+ contigs = view.getVisibleContigs();
+ assertEquals(contigs, new int[] { 0, 9 });
+ // get a fresh AlignmentView
+ view = av.getAlignmentView(true);
+ contigs = view.getVisibleContigs();
+ assertEquals(contigs, new int[] { 0, 4, 8, 9 });
+
+ // hide first 2 columns
+ av.hideColumns(0, 1);
+ view = av.getAlignmentView(true);
+ contigs = view.getVisibleContigs();
+ assertEquals(contigs, new int[] { 2, 4, 8, 9 });
+
+ // hide last column
+ av.hideColumns(9, 9);
+ view = av.getAlignmentView(true);
+ contigs = view.getVisibleContigs();
+ assertEquals(contigs, new int[] { 2, 4, 8, 8 });
+
+ // unhide columns 5-7
+ av.showColumn(5);
+ view = av.getAlignmentView(true);
+ contigs = view.getVisibleContigs();
+ assertEquals(contigs, new int[] { 2, 8 });
+
+ // hide columns 2-7
+ av.hideColumns(2, 7);
+ view = av.getAlignmentView(true);
+ contigs = view.getVisibleContigs();
+ assertEquals(contigs, new int[] { 8, 8 });
+
+ // hide column 8
+ av.hideColumns(8, 8);
+ view = av.getAlignmentView(true);
+ contigs = view.getVisibleContigs();
+ assertEquals(contigs, new int[] {});
+
+ // unhide all
+ av.showAllHiddenColumns();
+ view = av.getAlignmentView(true);
+ contigs = view.getVisibleContigs();
+ assertEquals(contigs, new int[] { 0, 9 });
+ }
}
--- /dev/null
+package jalview.ws.dbsources;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertNotNull;
+import static org.testng.AssertJUnit.assertTrue;
+
+import jalview.bin.Cache;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.DBRefEntry;
+import jalview.datamodel.DBRefSource;
+import jalview.datamodel.SequenceI;
+import jalview.fts.api.FTSData;
+import jalview.fts.api.FTSDataColumnI;
+import jalview.fts.api.FTSRestClientI;
+import jalview.fts.core.FTSRestRequest;
+import jalview.fts.core.FTSRestResponse;
+import jalview.fts.service.uniprot.UniProtFTSRestClient;
+import jalview.ws.SequenceFetcher;
+import jalview.ws.seqfetcher.DbSourceProxy;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * A class to verify that remotely fetched data has an expected format and can
+ * be successfully processed by Jalview. This is intended as a first line of
+ * defence and early warning of service affecting changes to data fetched
+ * externally.
+ * <p>
+ * This is class is not intended to cover remote services e.g. alignment. Nor
+ * should it duplicate tests already provided by other classes (such as
+ * PDBFTSRestClientTest). Or maybe we will relocate those tests here...
+ */
+public class RemoteFormatTest
+{
+ SequenceFetcher sf;
+
+ @Test(groups = "Network")
+ public void testFetchUniprot() throws Exception
+ {
+ List<DbSourceProxy> sps = sf.getSourceProxy(DBRefSource.UNIPROT);
+ assertFalse(sps.isEmpty());
+ AlignmentI response = sps.get(0).getSequenceRecords("P30419");
+ assertNotNull(response);
+ assertEquals(response.getHeight(), 1);
+ SequenceI sq = response.getSequenceAt(0);
+ assertTrue("No PDBEntry on sequence.", sq.getAllPDBEntries().size() > 0);
+ assertTrue("No DBRef on sequence.", sq.getDBRefs().length > 0);
+ List<DBRefEntry> dbr = sq.getPrimaryDBRefs();
+ assertFalse(dbr.isEmpty());
+ assertEquals(
+ "Sequence start/end doesn't match number of residues in sequence",
+ sq.getEnd() - sq.getStart() + 1, sq.getLength());
+ }
+
+ @Test(groups = "Network")
+ public void testFetchPdb()
+ {
+ // 1QIP
+ }
+
+ @Test(groups = "Network")
+ public void testFetchEmbl()
+ {
+ // X53828
+ }
+
+ @Test(groups = "Network")
+ public void testFetchEmblCDS()
+ {
+ // CAA37824
+ }
+
+ @Test(groups = "Network")
+ public void testFetchEnsembl()
+ {
+ // ENSG00000157764
+ }
+
+ @Test(groups = "Network")
+ public void testFetchEnsemblGenomes()
+ {
+ // DDB_G0283883
+ }
+
+ @Test(groups = "Network")
+ public void testFetchPfamSeed()
+ {
+ // PF03760
+ }
+
+ @Test(groups = "Network")
+ public void testFetchPfamFull()
+ {
+ // PF03760
+ }
+
+ @Test(groups = "Network")
+ public void testFetchRfamSeed()
+ {
+ // RF00014
+ }
+
+ @Test(groups = { "Network" })
+ public void testUniprotFreeTextSearch() throws Exception
+ {
+ List<FTSDataColumnI> wantedFields = new ArrayList<FTSDataColumnI>();
+ FTSRestClientI client = UniProtFTSRestClient.getInstance();
+ wantedFields.add(client.getDataColumnByNameOrCode("id"));
+ wantedFields.add(client.getDataColumnByNameOrCode("entry name"));
+ wantedFields.add(client.getDataColumnByNameOrCode("organism"));
+ wantedFields.add(client.getDataColumnByNameOrCode("reviewed")); // Status
+ wantedFields.add(client.getDataColumnByNameOrCode("length"));
+
+ FTSRestRequest request = new FTSRestRequest();
+ request.setAllowEmptySeq(false);
+ request.setResponseSize(100);
+ request.setFieldToSearchBy("Search All");
+ request.setSearchTerm("metanephrops"); // lobster!
+ request.setWantedFields(wantedFields);
+
+ FTSRestResponse response;
+ response = client.executeRequest(request);
+ assertTrue(response.getNumberOfItemsFound() > 20);
+ assertTrue(response.getSearchSummary() != null);
+ assertTrue(response.getSearchSummary().size() > 20);
+ // verify we successfully filtered out the header row (JAL-2485)
+ FTSData header = response.getSearchSummary().iterator().next();
+ assertFalse("Failed to filter out summary header row",
+ header.getSummaryData()[0].toString().equalsIgnoreCase("Entry"));
+ }
+
+ @BeforeMethod(alwaysRun = true)
+ public void setUp() throws Exception
+ {
+ Cache.loadProperties("test/jalview/io/testProps.jvprops");
+ // ensure 'add annotation from structure' is selected
+ Cache.applicationProperties.setProperty("STRUCT_FROM_PDB",
+ Boolean.TRUE.toString());
+ Cache.applicationProperties.setProperty("ADD_SS_ANN",
+ Boolean.TRUE.toString());
+
+ sf = new SequenceFetcher(false);
+ }
+}
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);
+ }
}