From 0cd0dc34c9722ae6e718006425a0086d96f78ef3 Mon Sep 17 00:00:00 2001 From: Lars Willighagen Date: Sun, 27 Aug 2023 00:47:56 +0200 Subject: [PATCH 1/7] Add dropdown for PublicationXref database --- .../pathvisio/core/biopax/PublicationXref.java | 9 ++++++++- .../gui/dialogs/PublicationXRefDialog.java | 18 +++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/modules/org.pathvisio.core/src/org/pathvisio/core/biopax/PublicationXref.java b/modules/org.pathvisio.core/src/org/pathvisio/core/biopax/PublicationXref.java index bd1b13868..ecc77a9b6 100644 --- a/modules/org.pathvisio.core/src/org/pathvisio/core/biopax/PublicationXref.java +++ b/modules/org.pathvisio.core/src/org/pathvisio/core/biopax/PublicationXref.java @@ -80,13 +80,20 @@ public void setYear(String year) { setPropertyValue(PropertyType.YEAR, year); } + public String getDb() { + return getPropertyValue(PropertyType.DB); + } + + public void setDb(String db) { + setPropertyValue(PropertyType.DB, db); + } + public String getPubmedId() { return getPropertyValue(PropertyType.ID); } public void setPubmedId(String id) { setPropertyValue(PropertyType.ID, id); - setPropertyValue(PropertyType.DB, "PubMed"); } public List getAuthors() { diff --git a/modules/org.pathvisio.gui/src/org/pathvisio/gui/dialogs/PublicationXRefDialog.java b/modules/org.pathvisio.gui/src/org/pathvisio/gui/dialogs/PublicationXRefDialog.java index c3b50d228..051322df4 100644 --- a/modules/org.pathvisio.gui/src/org/pathvisio/gui/dialogs/PublicationXRefDialog.java +++ b/modules/org.pathvisio.gui/src/org/pathvisio/gui/dialogs/PublicationXRefDialog.java @@ -27,6 +27,7 @@ import java.util.regex.Pattern; import javax.swing.JButton; +import javax.swing.JComboBox; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; @@ -58,14 +59,17 @@ public class PublicationXRefDialog extends OkCancelDialog { final static String ADD = "Add"; final static String REMOVE = "Remove"; - final static String PMID = "Pubmed ID"; + final static String DB = "Database"; + final static String PMID = "ID"; final static String TITLE = "Title"; final static String SOURCE = "Source"; final static String YEAR = "Year"; final static String AUTHORS = "Authors (separate with " + PublicationXref.AUTHOR_SEP + ")"; final static String QUERY = "Query PubMed"; + final static String[] DB_OPTIONS = {"PubMed", "DOI", "ISBN"}; PublicationXref input; + JComboBox db; JTextField pmId; JTextField title; JTextField source; @@ -91,6 +95,11 @@ private void setText(String text, JTextComponent field) { } protected void refresh() { + if (input.getDb() != null) { + db.setSelectedIndex(java.util.Arrays.asList(DB_OPTIONS).indexOf(input.getDb())); + } else { + db.setSelectedIndex(0); + } setText(input.getPubmedId(), pmId); setText(input.getTitle(), title); setText(input.getSource(), source); @@ -99,6 +108,7 @@ protected void refresh() { } protected void okPressed() { + input.setDb(DB_OPTIONS[db.getSelectedIndex()]); input.setPubmedId(pmId.getText().trim()); input.setTitle(title.getText()); input.setSource(source.getText()); @@ -130,6 +140,7 @@ protected Void doInBackground() throws SAXException, IOException PubMedResult pmr = pmq.getResult(); if(pmr != null) { + db.setSelectedItem(DB_OPTIONS[0]); // set pubmed pmId.setText(pmr.getId()); // write the trimmed pmid to the dialog title.setText(pmr.getTitle()); year.setText(pmr.getYear()); @@ -149,12 +160,15 @@ protected Component createDialogPane() { JPanel contents = new JPanel(); contents.setLayout(new GridBagLayout()); + JLabel lblDb = new JLabel(DB); JLabel lblPmId = new JLabel(PMID); JLabel lblTitle = new JLabel(TITLE); JLabel lblSource = new JLabel(SOURCE); JLabel lblYear = new JLabel(YEAR); JLabel lblAuthors = new JLabel(AUTHORS); + db = new JComboBox(DB_OPTIONS); + db.setEditable(true); pmId = new JTextField(); title = new JTextField(); source = new JTextField(); @@ -203,6 +217,7 @@ void highlight(StyledDocument doc) { c.gridy = GridBagConstraints.RELATIVE; c.weightx = 0; contents.add(lblPmId, c); + contents.add(lblDb, c); contents.add(lblTitle, c); contents.add(lblYear, c); contents.add(lblSource, c); @@ -212,6 +227,7 @@ void highlight(StyledDocument doc) { c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; contents.add(pmId, c); + contents.add(db, c); contents.add(title, c); contents.add(year, c); contents.add(source, c); From d3060a25c0f7f5f73b851293a8c52334c52d0016 Mon Sep 17 00:00:00 2001 From: Lars Willighagen Date: Sun, 27 Aug 2023 00:48:14 +0200 Subject: [PATCH 2/7] Do not delete all authors from PublicationXref --- .../src/org/pathvisio/core/model/GpmlFormat2013a.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/modules/org.pathvisio.core/src/org/pathvisio/core/model/GpmlFormat2013a.java b/modules/org.pathvisio.core/src/org/pathvisio/core/model/GpmlFormat2013a.java index 24d0bc491..8d7d1bc91 100644 --- a/modules/org.pathvisio.core/src/org/pathvisio/core/model/GpmlFormat2013a.java +++ b/modules/org.pathvisio.core/src/org/pathvisio/core/model/GpmlFormat2013a.java @@ -844,9 +844,6 @@ public Document createJdom(Pathway data) throws ConverterException for (Element e : elementList) { // make sure biopax references are sorted alphabetically by rdf-id if(e.getName().equals("Biopax")) { - for(Element e3 : e.getChildren()) { - e3.removeChildren("AUTHORS", GpmlFormat.BIOPAX); - } e.sortChildren(new BiopaxAttributeComparator()); } root.addContent(e); From b1728099264adc8d16ef20ba4a9a22203d230df1 Mon Sep 17 00:00:00 2001 From: Lars Willighagen Date: Sun, 27 Aug 2023 01:02:26 +0200 Subject: [PATCH 3/7] Do not duplicate fields in PublicationXRef Fix #191 --- .../src/org/pathvisio/core/biopax/BiopaxNode.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/org.pathvisio.core/src/org/pathvisio/core/biopax/BiopaxNode.java b/modules/org.pathvisio.core/src/org/pathvisio/core/biopax/BiopaxNode.java index 907595a10..dd9b2e51e 100644 --- a/modules/org.pathvisio.core/src/org/pathvisio/core/biopax/BiopaxNode.java +++ b/modules/org.pathvisio.core/src/org/pathvisio/core/biopax/BiopaxNode.java @@ -60,9 +60,11 @@ public void addProperty(BiopaxProperty p) { List existingProps = getProperties(p.getName()); if(p.getMaxCardinality() != BiopaxProperty.UNBOUND && existingProps.size() >= p.getMaxCardinality()) { - //Replace the first occuring property + //Replace other properties with the same name int first = getFirstPropertyIndex(p.getName()); - properties.remove(first); + for(BiopaxProperty existingProp : existingProps) { + removeProperty(existingProp); + } properties.add(first, p); } else { properties.add(p); From 4e2a185a7dbf6f06b01e29ac2bdaef0bb6511f39 Mon Sep 17 00:00:00 2001 From: Lars Willighagen Date: Sun, 27 Aug 2023 01:02:44 +0200 Subject: [PATCH 4/7] Allow empty database selection in PublicationXRef --- .../src/org/pathvisio/gui/dialogs/PublicationXRefDialog.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/org.pathvisio.gui/src/org/pathvisio/gui/dialogs/PublicationXRefDialog.java b/modules/org.pathvisio.gui/src/org/pathvisio/gui/dialogs/PublicationXRefDialog.java index 051322df4..43c5c85df 100644 --- a/modules/org.pathvisio.gui/src/org/pathvisio/gui/dialogs/PublicationXRefDialog.java +++ b/modules/org.pathvisio.gui/src/org/pathvisio/gui/dialogs/PublicationXRefDialog.java @@ -108,7 +108,9 @@ protected void refresh() { } protected void okPressed() { - input.setDb(DB_OPTIONS[db.getSelectedIndex()]); + if (db.getSelectedIndex() > -1) { + input.setDb(DB_OPTIONS[db.getSelectedIndex()]); + } input.setPubmedId(pmId.getText().trim()); input.setTitle(title.getText()); input.setSource(source.getText()); From 4c1842922009e7b067312b13df13ae7ebb08c048 Mon Sep 17 00:00:00 2001 From: Lars Willighagen Date: Sun, 27 Aug 2023 01:09:58 +0200 Subject: [PATCH 5/7] Insert 'NA' for bp:ID, bp:DB when empty Fix #190 --- .../src/org/pathvisio/core/biopax/PublicationXref.java | 4 ++-- .../src/org/pathvisio/gui/dialogs/PublicationXRefDialog.java | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/modules/org.pathvisio.core/src/org/pathvisio/core/biopax/PublicationXref.java b/modules/org.pathvisio.core/src/org/pathvisio/core/biopax/PublicationXref.java index ecc77a9b6..94e502590 100644 --- a/modules/org.pathvisio.core/src/org/pathvisio/core/biopax/PublicationXref.java +++ b/modules/org.pathvisio.core/src/org/pathvisio/core/biopax/PublicationXref.java @@ -85,7 +85,7 @@ public String getDb() { } public void setDb(String db) { - setPropertyValue(PropertyType.DB, db); + setPropertyValue(PropertyType.DB, db.equals("") ? "NA" : db); } public String getPubmedId() { @@ -93,7 +93,7 @@ public String getPubmedId() { } public void setPubmedId(String id) { - setPropertyValue(PropertyType.ID, id); + setPropertyValue(PropertyType.ID, id.equals("") ? "NA" : id); } public List getAuthors() { diff --git a/modules/org.pathvisio.gui/src/org/pathvisio/gui/dialogs/PublicationXRefDialog.java b/modules/org.pathvisio.gui/src/org/pathvisio/gui/dialogs/PublicationXRefDialog.java index 43c5c85df..3305eaf1f 100644 --- a/modules/org.pathvisio.gui/src/org/pathvisio/gui/dialogs/PublicationXRefDialog.java +++ b/modules/org.pathvisio.gui/src/org/pathvisio/gui/dialogs/PublicationXRefDialog.java @@ -108,9 +108,7 @@ protected void refresh() { } protected void okPressed() { - if (db.getSelectedIndex() > -1) { - input.setDb(DB_OPTIONS[db.getSelectedIndex()]); - } + input.setDb((String) db.getSelectedItem()); input.setPubmedId(pmId.getText().trim()); input.setTitle(title.getText()); input.setSource(source.getText()); From a3a530f88e830e071361d721dc5ebd4990453309 Mon Sep 17 00:00:00 2001 From: Lars Willighagen Date: Sun, 27 Aug 2023 12:46:17 +0200 Subject: [PATCH 6/7] Update PublicationXref HTML for different databases --- .../core/biopax/PublicationXref.java | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/modules/org.pathvisio.core/src/org/pathvisio/core/biopax/PublicationXref.java b/modules/org.pathvisio.core/src/org/pathvisio/core/biopax/PublicationXref.java index 94e502590..1c8f137ed 100644 --- a/modules/org.pathvisio.core/src/org/pathvisio/core/biopax/PublicationXref.java +++ b/modules/org.pathvisio.core/src/org/pathvisio/core/biopax/PublicationXref.java @@ -29,6 +29,7 @@ */ public class PublicationXref extends BiopaxNode { static final String PUBMED_URL = "http://www.ncbi.nlm.nih.gov/pubmed/"; + static final String DOI_URL = "http://doi.org/"; public PublicationXref() { super(); @@ -195,13 +196,26 @@ public String toString() { builder.append(year) .append(". "); } + String db = getDb(); String pmid = getPubmedId(); if(!Utils.isEmpty(pmid)) { - builder.append("PubMed ") - .append(pmid) - .append("."); + if (db.equals("PubMed")) { + builder.append("PubMed ") + .append(pmid) + .append("."); + } else if (db.equals("DOI")) { + builder.append("doi:") + .append(pmid) + .append("."); + } else { + builder.append(db) + .append(" ") + .append(pmid); + } } return builder.toString(); } From dabde8f7470fc9fbc1347180343e6c48aca13d86 Mon Sep 17 00:00:00 2001 From: Lars Willighagen Date: Sun, 27 Aug 2023 12:58:18 +0200 Subject: [PATCH 7/7] Handle empty values better --- .../org/pathvisio/core/biopax/PublicationXref.java | 11 +++++++---- .../pathvisio/gui/dialogs/PublicationXRefDialog.java | 10 +++++++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/modules/org.pathvisio.core/src/org/pathvisio/core/biopax/PublicationXref.java b/modules/org.pathvisio.core/src/org/pathvisio/core/biopax/PublicationXref.java index 1c8f137ed..84c313d63 100644 --- a/modules/org.pathvisio.core/src/org/pathvisio/core/biopax/PublicationXref.java +++ b/modules/org.pathvisio.core/src/org/pathvisio/core/biopax/PublicationXref.java @@ -30,6 +30,7 @@ public class PublicationXref extends BiopaxNode { static final String PUBMED_URL = "http://www.ncbi.nlm.nih.gov/pubmed/"; static final String DOI_URL = "http://doi.org/"; + static final String EMPTY_VALUE_STRING = "NA"; public PublicationXref() { super(); @@ -82,19 +83,21 @@ public void setYear(String year) { } public String getDb() { - return getPropertyValue(PropertyType.DB); + String db = getPropertyValue(PropertyType.DB); + return db.equals(EMPTY_VALUE_STRING) ? "" : db; } public void setDb(String db) { - setPropertyValue(PropertyType.DB, db.equals("") ? "NA" : db); + setPropertyValue(PropertyType.DB, Utils.isEmpty(db) ? EMPTY_VALUE_STRING : db); } public String getPubmedId() { - return getPropertyValue(PropertyType.ID); + String id = getPropertyValue(PropertyType.ID); + return id.equals(EMPTY_VALUE_STRING) ? "" : id; } public void setPubmedId(String id) { - setPropertyValue(PropertyType.ID, id.equals("") ? "NA" : id); + setPropertyValue(PropertyType.ID, Utils.isEmpty(id) ? EMPTY_VALUE_STRING : id); } public List getAuthors() { diff --git a/modules/org.pathvisio.gui/src/org/pathvisio/gui/dialogs/PublicationXRefDialog.java b/modules/org.pathvisio.gui/src/org/pathvisio/gui/dialogs/PublicationXRefDialog.java index 3305eaf1f..254a9dbe1 100644 --- a/modules/org.pathvisio.gui/src/org/pathvisio/gui/dialogs/PublicationXRefDialog.java +++ b/modules/org.pathvisio.gui/src/org/pathvisio/gui/dialogs/PublicationXRefDialog.java @@ -95,10 +95,14 @@ private void setText(String text, JTextComponent field) { } protected void refresh() { - if (input.getDb() != null) { - db.setSelectedIndex(java.util.Arrays.asList(DB_OPTIONS).indexOf(input.getDb())); - } else { + String selectedDb = input.getDb(); + int selectedDbIndex = java.util.Arrays.asList(DB_OPTIONS).indexOf(selectedDb); + if (selectedDb == null) { db.setSelectedIndex(0); + } else if (selectedDbIndex > -1) { + db.setSelectedIndex(selectedDbIndex); + } else { + db.setSelectedItem(selectedDb); } setText(input.getPubmedId(), pmId); setText(input.getTitle(), title);