From 4e988b599b29712e28b5746d7594c33c67cd2f74 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Mon, 31 Oct 2005 15:55:28 +0000 Subject: [PATCH] DBPrefix and JVSuffix added --- src/jalview/appletgui/AlignViewport.java | 23 +++++++++--- src/jalview/appletgui/AlignmentPanel.java | 9 +---- src/jalview/appletgui/IdCanvas.java | 14 ++----- src/jalview/gui/IdCanvas.java | 18 ++------- src/jalview/gui/Jalview2XML.java | 7 ++-- src/jalview/gui/Preferences.java | 6 ++- src/jalview/io/HTMLOutput.java | 26 ++++--------- src/jalview/io/VamsasDatastore.java | 57 ++++++++++++++++++++++++++++- src/jalview/jbgui/GAlignFrame.java | 33 +++++++++++++---- src/jalview/jbgui/GPreferences.java | 39 +++++++++++--------- 10 files changed, 145 insertions(+), 87 deletions(-) diff --git a/src/jalview/appletgui/AlignViewport.java b/src/jalview/appletgui/AlignViewport.java index 209f939..382fcb6 100755 --- a/src/jalview/appletgui/AlignViewport.java +++ b/src/jalview/appletgui/AlignViewport.java @@ -36,7 +36,8 @@ public class AlignViewport int startSeq; int endSeq; - boolean showFullId = true; + boolean showDBPrefix = true; + boolean showJVSuffix = true; boolean showText = true; boolean showColourText = false; boolean showBoxes = true; @@ -98,7 +99,7 @@ public class AlignViewport String param = applet.getParameter("showFullId"); if (param != null) { - showFullId = Boolean.valueOf(param).booleanValue(); + showJVSuffix = Boolean.valueOf(param).booleanValue(); } param = applet.getParameter("showAnnotation"); @@ -596,14 +597,24 @@ public class AlignViewport return colourAppliesToAllGroups; } - public boolean getShowFullId() + public boolean getShowJVSuffix() { - return showFullId; + return showJVSuffix; } - public void setShowFullId(boolean b) + public void setShowJVSuffix(boolean b) { - showFullId = b; + showJVSuffix = b; + } + + public boolean getShowDBPrefix() + { + return showDBPrefix; + } + + public void setShowDBPrefix(boolean b) + { + showDBPrefix = b; } public boolean getShowAnnotation() diff --git a/src/jalview/appletgui/AlignmentPanel.java b/src/jalview/appletgui/AlignmentPanel.java index 7332a1a..44370d4 100755 --- a/src/jalview/appletgui/AlignmentPanel.java +++ b/src/jalview/appletgui/AlignmentPanel.java @@ -204,14 +204,7 @@ public class AlignmentPanel while (i < al.getHeight() && al.getSequenceAt(i) != null) { SequenceI s = al.getSequenceAt(i); - if (av.getShowFullId()) - { - id = s.getDisplayId(); - } - else - { - id = s.getName(); - } + id = s.getDisplayId(av.getShowDBPrefix(), av.getShowJVSuffix()); if (fm.stringWidth(id) > idWidth) { diff --git a/src/jalview/appletgui/IdCanvas.java b/src/jalview/appletgui/IdCanvas.java index d581273..7686e8a 100755 --- a/src/jalview/appletgui/IdCanvas.java +++ b/src/jalview/appletgui/IdCanvas.java @@ -74,11 +74,7 @@ public class IdCanvas gg.setColor(Color.black); } - String string = s.getName(); - if (av.getShowFullId()) - { - string = s.getDisplayId(); - } + String string = s.getDisplayId(av.getShowDBPrefix(), av.getShowJVSuffix()); gg.drawString(string, 0, ((i - starty) * charHeight) + ypos + @@ -266,11 +262,9 @@ public class IdCanvas av.charHeight); gg.setColor(currentTextColor); - String string = av.alignment.getSequenceAt(i).getName(); - if (av.getShowFullId()) - { - string = av.alignment.getSequenceAt(i).getDisplayId(); - } + String string = av.alignment.getSequenceAt(i) + .getDisplayId(av.getShowDBPrefix(), av.getShowJVSuffix()); + gg.drawString(string, 0, ((i - starty) * av.charHeight) + av.charHeight - (av.charHeight / 5)); diff --git a/src/jalview/gui/IdCanvas.java b/src/jalview/gui/IdCanvas.java index 9b1f10d..5314ade 100755 --- a/src/jalview/gui/IdCanvas.java +++ b/src/jalview/gui/IdCanvas.java @@ -93,15 +93,9 @@ public class IdCanvas extends JPanel gg.setColor(Color.black); } - String string = s.getName(); - if (av.getShowFullId()) - { - string = s.getDisplayId(); - } - - gg.drawString(string, 0, - (((i - starty + 1) * charHeight) + ypos) - (charHeight / 5)); + gg.drawString( s.getDisplayId(av.getShowDBPrefix(), av.getShowJVSuffix()), + 0, (((i - starty + 1) * charHeight) + ypos) - (charHeight / 5)); } /** @@ -290,12 +284,8 @@ public class IdCanvas extends JPanel gg.setColor(currentTextColor); - String string = av.alignment.getSequenceAt(i).getName(); - - if (av.getShowFullId()) - { - string = av.alignment.getSequenceAt(i).getDisplayId(); - } + String string = av.alignment.getSequenceAt(i).getDisplayId( + av.getShowDBPrefix(), av.getShowJVSuffix()); gg.drawString(string, 0, (((i - starty) * av.charHeight) + av.charHeight) - diff --git a/src/jalview/gui/Jalview2XML.java b/src/jalview/gui/Jalview2XML.java index 9ab6419..f49878c 100755 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -27,6 +27,7 @@ import java.io.*; import java.net.*; import java.util.*; + import java.util.jar.*; import javax.swing.*; @@ -393,7 +394,7 @@ public class Jalview2XML view.setShowBoxes(av.getShowBoxes()); view.setShowColourText(av.getColourText()); view.setShowConservation(av.showConservation); - view.setShowFullId(av.getShowFullId()); + view.setShowFullId(av.getShowJVSuffix()); view.setShowIdentity(av.showIdentity); view.setShowQuality(av.showQuality); view.setShowSequenceFeatures(av.showSequenceFeatures); @@ -700,8 +701,8 @@ public class Jalview2XML af.viewport.setConservationSelected(view.getConservationSelected()); af.conservationMenuItem.setSelected(view.getConservationSelected()); - af.viewport.setShowFullId(view.getShowFullId()); - af.fullSeqId.setSelected(view.getShowFullId()); + af.viewport.setShowJVSuffix(view.getShowFullId()); + af.seqLimits.setSelected(view.getShowFullId()); af.viewport.setFont(new java.awt.Font(view.getFontName(), view.getFontStyle(), view.getFontSize())); diff --git a/src/jalview/gui/Preferences.java b/src/jalview/gui/Preferences.java index 078eff1..8915f6f 100755 --- a/src/jalview/gui/Preferences.java +++ b/src/jalview/gui/Preferences.java @@ -79,7 +79,8 @@ public class Preferences extends GPreferences Desktop.addInternalFrame(frame, "Preferences", 480, 390); frame.setMinimumSize(new Dimension(480,390)); - fullID.setSelected( Cache.getDefault("SHOW_FULL_ID", true)); + dbRef.setSelected( Cache.getDefault("SHOW_DBREF", true)); + seqLimit.setSelected( Cache.getDefault("SHOW_JVSUFFIX", true)); fullScreen.setSelected( Cache.getDefault("SHOW_FULLSCREEN", false)); annotations.setSelected( Cache.getDefault("SHOW_ANNOTATIONS", true)); @@ -196,7 +197,8 @@ public class Preferences extends GPreferences public void ok_actionPerformed(ActionEvent e) { - Cache.applicationProperties.setProperty("SHOW_FULL_ID", Boolean.toString(fullID.isSelected())); + Cache.applicationProperties.setProperty("SHOW_DBREF", Boolean.toString(dbRef.isSelected())); + Cache.applicationProperties.setProperty("SHOW_JVSUFFIX", Boolean.toString(seqLimit.isSelected())); Cache.applicationProperties.setProperty("SHOW_FULLSCREEN", Boolean.toString(fullScreen.isSelected())); Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS", Boolean.toString(annotations.isSelected())); diff --git a/src/jalview/io/HTMLOutput.java b/src/jalview/io/HTMLOutput.java index 201ff0c..257e9fa 100755 --- a/src/jalview/io/HTMLOutput.java +++ b/src/jalview/io/HTMLOutput.java @@ -134,16 +134,11 @@ public class HTMLOutput seq = alignment.getSequenceAt(i); groups = alignment.findAllGroups(seq); - if (av.getShowFullId()) - { - out.println("" + seq.getDisplayId() + - "  "); - } - else - { - out.println("" + seq.getName() + + String id = seq.getDisplayId(av.getShowDBPrefix(), av.getShowJVSuffix()); + + out.println("" + id + "  "); - } + for (int res = 0; res < seq.getLength(); res++) { @@ -229,16 +224,11 @@ public class HTMLOutput seq = al.getSequenceAt(s); groups = al.findAllGroups(seq); - if (av.getShowFullId()) - { - out.println("" + seq.getDisplayId() + - "  "); - } - else - { - out.println("" + seq.getName() + + String id = seq.getDisplayId(av.getShowDBPrefix(), av.getShowJVSuffix()); + + out.println("" + id + "  "); - } + for (int res = startRes; res < endRes; res++) { diff --git a/src/jalview/io/VamsasDatastore.java b/src/jalview/io/VamsasDatastore.java index 3c79599..69213af 100755 --- a/src/jalview/io/VamsasDatastore.java +++ b/src/jalview/io/VamsasDatastore.java @@ -86,6 +86,30 @@ public class VamsasDatastore sequence.setStart(jal.getDataset().getSequenceAt(i).getStart()); sequence.setEnd(jal.getDataset().getSequenceAt(i).getEnd()); + + if(jal.getDataset().getSequenceAt(i).getSequenceFeatures()!=null) + { + int sfSize = jal.getDataset().getSequenceAt(i).getSequenceFeatures().size(); + + for (int sf = 0; sf < sfSize; sf++) + { + jalview.datamodel.SequenceFeature feature = + (jalview.datamodel.SequenceFeature) + jal.getDataset().getSequenceAt(i).getSequenceFeatures().elementAt(sf); + + DataSetAnnotations dsa = new DataSetAnnotations(); + dsa.setType(feature.getType()); + dsa.setBegin(feature.getBegin()); + dsa.setEnd(feature.getEnd()); + dsa.setDescription(feature.getDescription()); + dsa.setStatus(feature.getStatus()); + dsa.addProvenance(dummyProvenance()); + dsa.setSeqRef(sequence); + dsa.setId("sf"+(time++)); + dataset.addDataSetAnnotations(dsa); + } + } + if(jal.getDataset().getSequenceAt(i).getDBRef()!=null) { java.util.Vector entries = jal.getDataset().getSequenceAt(i).getDBRef(); @@ -278,6 +302,23 @@ public class VamsasDatastore dataset.getSequence(i).getEnd() ); seqs[i].setVamsasId(dataset.getSequence(i).getId()); + if (dataset.getDataSetAnnotations() != null) + { + for (int dsa = 0; dsa < dataset.getDataSetAnnotationsCount(); dsa++) + { + if (dataset.getDataSetAnnotations(dsa).getSeqRef() == + dataset.getSequence(i)) + { + seqs[i].addSequenceFeature(new jalview.datamodel. + SequenceFeature( + dataset.getDataSetAnnotations(dsa).getType(), + dataset.getDataSetAnnotations(dsa).getDescription(), + dataset.getDataSetAnnotations(dsa).getStatus(), + dataset.getDataSetAnnotations(dsa).getBegin(), + dataset.getDataSetAnnotations(dsa).getEnd())); + } + } + } dbref = dataset.getSequence(i).getDbRef(); if(dbref.length>0) @@ -291,7 +332,6 @@ public class VamsasDatastore dbref[db].getAccessionId().toString())); } } - } jalview.datamodel.Alignment jdataset = new jalview.datamodel.Alignment(seqs); //////////////////////////////////////////////// @@ -302,6 +342,8 @@ public class VamsasDatastore Alignment alignment = dataset.getAlignment(0); iSize = alignment.getAlignmentSequenceCount(); seqs = new jalview.datamodel.Sequence[iSize]; + String id; + int j, jSize = jdataset.getHeight(); for (i = 0; i < iSize; i++) { seqs[i] = new jalview.datamodel.Sequence( @@ -309,6 +351,17 @@ public class VamsasDatastore alignment.getAlignmentSequence(i).getSequence(), alignment.getAlignmentSequence(i).getStart(), alignment.getAlignmentSequence(i).getEnd()); + + id = ( (Sequence) alignment.getAlignmentSequence(i).getRefid()).getId(); + + for(j=0; j