From 7069dfb8eacf6405040429bb74ffc109706ddc49 Mon Sep 17 00:00:00 2001 From: tcofoegbu Date: Mon, 9 May 2016 17:43:56 +0100 Subject: [PATCH] JAL-2101 JAL-2071 JAL-1563 Added fix to enable searching for old entry names in Uniprot FTS, modified Uniprot FTS data column config file to ensure query consistency with uniprot.org, formatted page range number in FTS summary panel, fixed broken tests, and added Jalview licence header to the Uniprot FTS data column config file --- resources/fts/uniprot_data_columns.txt | 49 ++++++++++++++------ src/jalview/fts/core/GFTSPanel.java | 4 ++ src/jalview/fts/service/pdb/PDBFTSPanel.java | 11 +++-- src/jalview/fts/service/pdb/PDBFTSRestClient.java | 16 +++++-- .../fts/service/uniprot/UniProtFTSRestClient.java | 9 +++- .../fts/service/uniprot/UniprotFTSPanel.java | 11 +++-- test/jalview/fts/core/FTSRestClientTest.java | 10 ++-- 7 files changed, 81 insertions(+), 29 deletions(-) diff --git a/resources/fts/uniprot_data_columns.txt b/resources/fts/uniprot_data_columns.txt index 6c78c16..c6b037c 100644 --- a/resources/fts/uniprot_data_columns.txt +++ b/resources/fts/uniprot_data_columns.txt @@ -1,3 +1,24 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors + * + * This file is part of Jalview. + * + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ + uniprot_data_columns # _group.id @@ -35,16 +56,16 @@ _data_column.preferred_col_width _data_column.is_shown_by_default _data_column.is_searchable Uniprot Id;id;String;g3;80;150;85;true;true -Entry Name;entry name|name;String;g3;100;150;105;true;true -Protein names;protein names|protein name;String;g3;300;1500;500;true;true +Entry Name;entry name|mnemonic;String;g3;100;150;105;true;true +Protein names;protein names|name;String;g3;300;1500;500;true;true Gene Names;genes|gene;String;g3;100;1000;145;true;true Organism;organism;String;g3;100;1000;200;true;true -Organism ID;organism-id;int;g3;60;100;80;false;true -Proteomes;proteome;String;g3;50;1000;95;false;true -Taxonomic lineage (ALL);lineage(ALL);String;g3;50;400;95;false;false -Virus hosts;virus hosts;String;g3;50;1000;95;false;true -Fragment;fragment;String;g7;50;1000;95;false;true -Gene encoded by;encodedon;String;g7;50;1000;95;false;true +Organism ID;organism-id;int;g3;60;100;80;false;false +Proteomes;proteome;String;g3;50;1000;95;false;false +Taxonomic lineage (ALL);lineage(ALL)|taxonomy;String;g3;50;400;95;false;false +Virus hosts;virus hosts|host;String;g3;50;1000;95;false;true +Fragment;fragment;String;g7;50;1000;95;false;false +Gene encoded by;encodedon;String;g7;50;1000;95;false;false Alternative products (isoforms);comment(ALTERNATIVE PRODUCTS);String;g7;50;1000;95;false;false Erroneous gene model prediction;comment(ERRONEOUS GENE MODEL PREDICTION);String;g7;50;1000;95;false;false Erroneous initiation;comment(ERRONEOUS INITIATION);String;g7;50;1000;95;false;false @@ -55,9 +76,9 @@ Polymorphism;comment(POLYMORPHISM);String;g7;50;1000;95;false;false RNA editing;comment(RNA EDITING);String;g7;50;1000;95;false;false Sequence caution;comment(SEQUENCE CAUTION);String;g7;50;1000;95;false;false Status;reviewed;String;g6;50;100;95;true;true -Length;length;int;g7;50;100;65;true;true +Length;length;int|T|0;g7;50;100;65;true;true Mass;mass;String;g7;50;100;80;false;true -Sequence;sequence;String;g7;50;1000;95;false;true +Sequence;sequence;String;g7;50;1000;95;false;false Alternative sequence;feature(ALTERNATIVE SEQUENCE);String;g7;50;1000;95;false;false Natural variant;feature(NATURAL VARIANT);String;g7;50;1000;95;false;false Non-adjacent residues;feature(NON ADJACENT RESIDUES);String;g7;50;1000;95;false;false @@ -83,15 +104,15 @@ DNA binding;feature(DNA BINDING);String;g8;50;1000;95;false;false Metal binding;feature(METAL BINDING);String;g8;50;1000;95;false;false Nucleotide binding;feature(NP BIND);String;g8;50;1000;95;false;false Site;feature(SITE);String;g8;50;1000;95;false;false -Annotation;annotation score;String;g6;50;1000;95;false;true -Features;features;String;g6;50;1000;95;false;true +Annotation;annotation score;String;g6;50;1000;95;false;false +Features;features;String;g6;50;1000;95;false;false Caution;comment(CAUTION);String;g6;50;1000;95;false;false Miscellaneous [CC];comment(GENERAL);String;g6;50;1000;95;false;false -Keywords;keywords;String;g6;50;1000;95;false;true +Keywords;keywords|keyword;String;g6;50;1000;95;false;true Protein existence;existence;String;g6;50;1000;95;false;true ALL;Search All;String;g7;50;1000;95;false;true; Subunit structure [CC];comment(SUBUNIT);String;g9;50;1000;95;false;false -Interacts with;interactor;String;g9;50;1000;95;false;true +Interacts with;interactor;String;g9;50;1000;95;false;false Developmental stage;comment(DEVELOPMENTAL STAGE);String;g10;50;1000;95;false;false Induction;comment(INDUCTION);String;g10;50;1000;95;false;false Tissue specificity;comment(TISSUE SPECIFICITY);String;g10;50;1000;95;false;false diff --git a/src/jalview/fts/core/GFTSPanel.java b/src/jalview/fts/core/GFTSPanel.java index 3e4a1cd..4dc61f0 100644 --- a/src/jalview/fts/core/GFTSPanel.java +++ b/src/jalview/fts/core/GFTSPanel.java @@ -41,6 +41,7 @@ import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -143,6 +144,9 @@ public abstract class GFTSPanel extends JPanel implements GFTSPanelI protected HashSet paginatorCart = new HashSet(); + protected static final DecimalFormat totalNumberformatter = new DecimalFormat( + "###,###"); + private JTable tbl_summary = new JTable() { private boolean inLayout; diff --git a/src/jalview/fts/service/pdb/PDBFTSPanel.java b/src/jalview/fts/service/pdb/PDBFTSPanel.java index 74b7853..0dd1369 100644 --- a/src/jalview/fts/service/pdb/PDBFTSPanel.java +++ b/src/jalview/fts/service/pdb/PDBFTSPanel.java @@ -116,9 +116,14 @@ public class PDBFTSPanel extends GFTSPanel if (isPaginationEnabled() && resultSetCount > 0) { updateSearchFrameTitle(defaultFTSFrameTitle + " - " + result - + " " + (offSet + 1) + " to " - + (offSet + resultSetCount) + " of " - + totalResultSetCount + + " " + + totalNumberformatter.format((Number) (offSet + 1)) + + " to " + + totalNumberformatter + .format((Number) (offSet + resultSetCount)) + + " of " + + totalNumberformatter + .format((Number) totalResultSetCount) + " " + " (" + (endTime - startTime) + " milli secs)"); } else diff --git a/src/jalview/fts/service/pdb/PDBFTSRestClient.java b/src/jalview/fts/service/pdb/PDBFTSRestClient.java index 29450e8..93a7df3 100644 --- a/src/jalview/fts/service/pdb/PDBFTSRestClient.java +++ b/src/jalview/fts/service/pdb/PDBFTSRestClient.java @@ -326,11 +326,13 @@ public class PDBFTSRestClient extends FTSRestClient { try { - summaryRowData[colCounter++] = (field.getDataColumnClass() == Integer.class) ? Integer + summaryRowData[colCounter++] = (field.getDataType() + .getDataTypeClass() == Integer.class) ? Integer .valueOf(fieldData) - : (field.getDataColumnClass() == Double.class) ? Double + : (field.getDataType() + .getDataTypeClass() == Double.class) ? Double .valueOf(fieldData) - : fieldData; + : sanitiseData(fieldData); } catch (Exception e) { e.printStackTrace(); @@ -389,6 +391,14 @@ public class PDBFTSRestClient extends FTSRestClient }; } + private static String sanitiseData(String data) + { + String cleanData = data.replaceAll("\\[\"", "").replaceAll("\\]\"", "") + .replaceAll("\\[", "").replaceAll("\\]", "") + .replaceAll("\",\"", ", ").replaceAll("\"", ""); + return cleanData; + } + @Override public String getColumnDataConfigFileName() { diff --git a/src/jalview/fts/service/uniprot/UniProtFTSRestClient.java b/src/jalview/fts/service/uniprot/UniProtFTSRestClient.java index 0447715..a4f82cf 100644 --- a/src/jalview/fts/service/uniprot/UniProtFTSRestClient.java +++ b/src/jalview/fts/service/uniprot/UniProtFTSRestClient.java @@ -66,6 +66,9 @@ public class UniProtFTSRestClient extends FTSRestClient String query = uniportRestRequest.getFieldToSearchBy() .equalsIgnoreCase("Search All") ? uniportRestRequest + .getSearchTerm() + + " or mnemonic:" + + uniportRestRequest .getSearchTerm() : uniportRestRequest.getFieldToSearchBy() + ":" + uniportRestRequest.getSearchTerm(); @@ -226,9 +229,11 @@ public class UniProtFTSRestClient extends FTSRestClient { try { - summaryRowData[colCounter++] = (field.getDataColumnClass() == Integer.class) ? Integer + summaryRowData[colCounter++] = (field.getDataType() + .getDataTypeClass() == Integer.class) ? Integer .valueOf(fieldData) - : (field.getDataColumnClass() == Double.class) ? Double + : (field.getDataType() + .getDataTypeClass() == Double.class) ? Double .valueOf(fieldData) : fieldData; } catch (Exception e) { diff --git a/src/jalview/fts/service/uniprot/UniprotFTSPanel.java b/src/jalview/fts/service/uniprot/UniprotFTSPanel.java index 6c28ee5..f2fcb76 100644 --- a/src/jalview/fts/service/uniprot/UniprotFTSPanel.java +++ b/src/jalview/fts/service/uniprot/UniprotFTSPanel.java @@ -118,9 +118,14 @@ public class UniprotFTSPanel extends GFTSPanel if (isPaginationEnabled() && resultSetCount > 0) { updateSearchFrameTitle(defaultFTSFrameTitle + " - " + result - + " " + (offSet + 1) + " to " - + (offSet + resultSetCount) + " of " - + totalResultSetCount + + " " + + totalNumberformatter.format((Number) (offSet + 1)) + + " to " + + totalNumberformatter + .format((Number) (offSet + resultSetCount)) + + " of " + + totalNumberformatter + .format((Number) totalResultSetCount) + " " + " (" + (endTime - startTime) + " milli secs)"); } else diff --git a/test/jalview/fts/core/FTSRestClientTest.java b/test/jalview/fts/core/FTSRestClientTest.java index 0dac04b..ddf60bc 100644 --- a/test/jalview/fts/core/FTSRestClientTest.java +++ b/test/jalview/fts/core/FTSRestClientTest.java @@ -76,7 +76,7 @@ public class FTSRestClientTest String actual = ftsRestClient .getDataColumnsFieldsAsCommaDelimitedString(wantedFields); Assert.assertEquals(actual, - "id,entry name,protein names,genes,organism,length,reviewed"); + "id,entry name,protein names,genes,organism,reviewed,length"); } @@ -151,7 +151,7 @@ public class FTSRestClientTest public void getDefaultResponsePageSize() { int defaultResSize = ftsRestClient.getDefaultResponsePageSize(); - Assert.assertEquals(defaultResSize, 100); + Assert.assertEquals(defaultResSize, 500); } @Test(groups = { "Functional" }) @@ -213,10 +213,12 @@ public class FTSRestClientTest FTSDataColumnI foundDataCol = ftsRestClient .getDataColumnByNameOrCode("Protein names"); Assert.assertNotNull(foundDataCol); - Assert.assertEquals(foundDataCol.getDataColumnClass(), String.class); + Assert.assertEquals(foundDataCol.getDataType().getDataTypeClass(), + String.class); foundDataCol = ftsRestClient.getDataColumnByNameOrCode("length"); Assert.assertNotNull(foundDataCol); - Assert.assertEquals(foundDataCol.getDataColumnClass(), Integer.class); + Assert.assertEquals(foundDataCol.getDataType().getDataTypeClass(), + Integer.class); // foundDataCol = ftsRestClient.getDataColumnByNameOrCode("length"); // Assert.assertNotNull(foundDataCol); // Assert.assertEquals(foundDataCol.getDataColumnClass(), Double.class); -- 1.7.10.2