From 6d981e3a3cac0e7f487d2b3d40e45cfd6ca8435c Mon Sep 17 00:00:00 2001 From: jprocter Date: Tue, 28 Aug 2012 14:22:02 +0100 Subject: [PATCH] formatting --- src/jalview/gui/Jalview2XML.java | 189 +++++++++++++----------- src/jalview/renderer/AnnotationRenderer.java | 1 - src/jalview/ws/jws2/AAConsClient.java | 21 ++- src/jalview/ws/jws2/JabawsAlignCalcWorker.java | 77 ++++++---- 4 files changed, 164 insertions(+), 124 deletions(-) diff --git a/src/jalview/gui/Jalview2XML.java b/src/jalview/gui/Jalview2XML.java index ee67b55..8872be0 100644 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -510,7 +510,8 @@ public class Jalview2XML if (av.isHiddenRepSequence(jal.getSequenceAt(i))) { - jalview.datamodel.SequenceI[] reps = av.getRepresentedSequences(jal.getSequenceAt(i)).getSequencesInOrder(jal); + jalview.datamodel.SequenceI[] reps = av.getRepresentedSequences( + jal.getSequenceAt(i)).getSequencesInOrder(jal); for (int h = 0; h < reps.length; h++) { @@ -617,8 +618,8 @@ public class Jalview2XML for (int smap = 0; smap < jmol.jmb.sequence[peid].length; smap++) { -// if (jal.findIndex(jmol.jmb.sequence[peid][smap]) > -1) - if (jds==jmol.jmb.sequence[peid][smap]) + // if (jal.findIndex(jmol.jmb.sequence[peid][smap]) > -1) + if (jds == jmol.jmb.sequence[peid][smap]) { StructureState state = new StructureState(); state.setVisible(true); @@ -870,8 +871,10 @@ public class Jalview2XML an.setLabel(aa[i].label); - if (aa[i] == av.getAlignmentQualityAnnot() || aa[i] == av.getAlignmentConservationAnnotation() - || aa[i] == av.getAlignmentConsensusAnnotation() || aa[i].autoCalculated) + if (aa[i] == av.getAlignmentQualityAnnot() + || aa[i] == av.getAlignmentConservationAnnotation() + || aa[i] == av.getAlignmentConsensusAnnotation() + || aa[i].autoCalculated) { // new way of indicating autocalculated annotation - an.setAutoCalculated(aa[i].autoCalculated); @@ -881,7 +884,7 @@ public class Jalview2XML an.setScore(aa[i].getScore()); } - if (aa[i].getCalcId()!=null) + if (aa[i].getCalcId() != null) { calcIdSet.add(aa[i].getCalcId()); an.setCalcId(aa[i].getCalcId()); @@ -941,7 +944,7 @@ public class Jalview2XML { JGroup[] groups = new JGroup[jal.getGroups().size()]; int i = -1; - for (jalview.datamodel.SequenceGroup sg:jal.getGroups()) + for (jalview.datamodel.SequenceGroup sg : jal.getGroups()) { groups[++i] = new JGroup(); @@ -1195,7 +1198,8 @@ public class Jalview2XML fs.addSetting(setting); settingsAdded.addElement(key); } - en = ap.seqPanel.seqCanvas.getFeatureRenderer().featureGroups.keySet().iterator(); + en = ap.seqPanel.seqCanvas.getFeatureRenderer().featureGroups + .keySet().iterator(); Vector groupsAdded = new Vector(); while (en.hasNext()) { @@ -1292,7 +1296,7 @@ public class Jalview2XML vCalcIdParam.addServiceURL(settings.getServiceURI()); // generic URI allowing a third party to resolve another instance of the // service used for this calculation - for (String urls:settings.getServiceURLs()) + for (String urls : settings.getServiceURLs()) { vCalcIdParam.addServiceURL(urls); } @@ -1311,8 +1315,8 @@ public class Jalview2XML // need to be able to recover 1) settings 2) user-defined presets or // recreate settings from preset 3) predefined settings provided by // service - or settings that can be transferred (or discarded) - vCalcIdParam.setParameters(settings - .getWsParamFile().replace("\n", "|\\n|")); + vCalcIdParam.setParameters(settings.getWsParamFile().replace("\n", + "|\\n|")); vCalcIdParam.setAutoUpdate(settings.isAutoUpdate()); // todo - decide if updateImmediately is needed for any projects. @@ -1326,33 +1330,47 @@ public class Jalview2XML { if (calcIdParam.getVersion().equals("1.0")) { - Jws2Instance service=Jws2Discoverer.getDiscoverer().getPreferredServiceFor(calcIdParam.getServiceURL()); - if (service!=null) + Jws2Instance service = Jws2Discoverer.getDiscoverer() + .getPreferredServiceFor(calcIdParam.getServiceURL()); + if (service != null) { - WsParamSetI parmSet=null; - try { - parmSet = service.getParamStore().parseServiceParameterFile(calcIdParam.getName(), calcIdParam.getDescription(), calcIdParam.getServiceURL(), calcIdParam.getParameters().replace("|\\n|", "\n")); + WsParamSetI parmSet = null; + try + { + parmSet = service.getParamStore().parseServiceParameterFile( + calcIdParam.getName(), calcIdParam.getDescription(), + calcIdParam.getServiceURL(), + calcIdParam.getParameters().replace("|\\n|", "\n")); } catch (IOException x) { - warn("Couldn't parse parameter data for "+calcIdParam.getCalcId(), x); + warn("Couldn't parse parameter data for " + + calcIdParam.getCalcId(), x); return false; } - List argList=null; - if (calcIdParam.getName().length()>0) { - parmSet = service.getParamStore().getPreset(calcIdParam.getName()); - if (parmSet!=null) + List argList = null; + if (calcIdParam.getName().length() > 0) + { + parmSet = service.getParamStore() + .getPreset(calcIdParam.getName()); + if (parmSet != null) { - // TODO : check we have a good match with settings in AACons - otherwise we'll need to create a new preset + // TODO : check we have a good match with settings in AACons - + // otherwise we'll need to create a new preset } } - else { + else + { argList = parmSet.getArguments(); - parmSet=null; + parmSet = null; } - AAConsSettings settings = new AAConsSettings(calcIdParam.isAutoUpdate(), service, parmSet, argList); - av.setCalcIdSettingsFor(calcIdParam.getCalcId(), settings, calcIdParam.isNeedsUpdate()); + AAConsSettings settings = new AAConsSettings( + calcIdParam.isAutoUpdate(), service, parmSet, argList); + av.setCalcIdSettingsFor(calcIdParam.getCalcId(), settings, + calcIdParam.isNeedsUpdate()); return true; - } else { + } + else + { warn("Cannot resolve a service for the parameters used in this project. Try configuring a JABAWS server."); return false; } @@ -1360,6 +1378,7 @@ public class Jalview2XML throw new Error("Unsupported Version for calcIdparam " + calcIdParam.toString()); } + /** * External mapping between jalview objects and objects yielding a valid and * unique object ID string. This is null for normal Jalview project IO, but @@ -1371,7 +1390,7 @@ public class Jalview2XML /** * Construct a unique ID for jvobj using either existing bindings or if none * exist, the result of the hashcode call for the object. - * + * * @param jvobj * jalview data object * @return unique ID for referring to jvobj @@ -1402,7 +1421,7 @@ public class Jalview2XML /** * return local jalview object mapped to ID, if it exists - * + * * @param idcode * (may be null) * @return null or object bound to idcode @@ -1638,7 +1657,7 @@ public class Jalview2XML /** * Load a jalview project archive from a jar file - * + * * @param file * - HTTP URL or filename */ @@ -1708,7 +1727,7 @@ public class Jalview2XML * initialise uniqueSetSuffix, seqRefIds, viewportsAdded and frefedSequence * themselves. Any null fields will be initialised with default values, * non-null fields are left alone. - * + * * @param jprovider * @return */ @@ -1929,7 +1948,7 @@ public class Jalview2XML } ; out.close(); - String t=outFile.getAbsolutePath(); + String t = outFile.getAbsolutePath(); alreadyLoadedPDB.put(pdbId, t); return t; } @@ -1966,7 +1985,7 @@ public class Jalview2XML /** * Load alignment frame from jalview XML DOM object - * + * * @param object * DOM * @param file @@ -2027,8 +2046,7 @@ public class Jalview2XML hiddenSeqs = new Vector(); } - hiddenSeqs.addElement(seqRefIds - .get(seqId)); + hiddenSeqs.addElement(seqRefIds.get(seqId)); } } @@ -2368,7 +2386,7 @@ public class Jalview2XML } if (an[i].hasBelowAlignment()) { - jaa.belowAlignment=an[i].isBelowAlignment(); + jaa.belowAlignment = an[i].isBelowAlignment(); } jaa.setCalcId(an[i].getCalcId()); @@ -2735,13 +2753,12 @@ public class Jalview2XML } if (ids[p].getFile() != null) { - File mapkey=new File(ids[p].getFile()); + File mapkey = new File(ids[p].getFile()); Object[] seqstrmaps = (Object[]) ((Hashtable) jmoldat[2]) .get(mapkey); if (seqstrmaps == null) { - ((Hashtable) jmoldat[2]).put( - mapkey, + ((Hashtable) jmoldat[2]).put(mapkey, seqstrmaps = new Object[] { pdbFile, ids[p].getId(), new Vector(), new Vector() }); @@ -2838,25 +2855,28 @@ public class Jalview2XML { newFileLoc = new StringBuffer(); } - do { + do + { // look for next filename in load statement - newFileLoc.append(state.substring(cp, - ncp = (state.indexOf("\"", ncp + 1) + 1))); - String oldfilenam = state.substring(ncp, - ecp = state.indexOf("\"", ncp)); - // recover the new mapping data for this old filename - // have to normalize filename - since Jmol and jalview do filename - // translation differently. - Object[] filedat = oldFiles.get(new File(oldfilenam)); - newFileLoc.append(Platform.escapeString((String) filedat[0])); - pdbfilenames.addElement((String) filedat[0]); - pdbids.addElement((String) filedat[1]); - seqmaps.addElement(((Vector) filedat[2]) - .toArray(new SequenceI[0])); - newFileLoc.append("\""); - cp = ecp + 1; // advance beyond last \" and set cursor so we can - // look for next file statement. - } while ((ncp=state.indexOf("/*file*/",cp))>-1); + newFileLoc.append(state.substring(cp, + ncp = (state.indexOf("\"", ncp + 1) + 1))); + String oldfilenam = state.substring(ncp, + ecp = state.indexOf("\"", ncp)); + // recover the new mapping data for this old filename + // have to normalize filename - since Jmol and jalview do + // filename + // translation differently. + Object[] filedat = oldFiles.get(new File(oldfilenam)); + newFileLoc.append(Platform + .escapeString((String) filedat[0])); + pdbfilenames.addElement((String) filedat[0]); + pdbids.addElement((String) filedat[1]); + seqmaps.addElement(((Vector) filedat[2]) + .toArray(new SequenceI[0])); + newFileLoc.append("\""); + cp = ecp + 1; // advance beyond last \" and set cursor so we can + // look for next file statement. + } while ((ncp = state.indexOf("/*file*/", cp)) > -1); } if (cp > 0) { @@ -2992,8 +3012,7 @@ public class Jalview2XML } if (usetoColourbyseq) { - comp.useAlignmentPanelForColourbyseq(ap, - !jmolColouring); + comp.useAlignmentPanelForColourbyseq(ap, !jmolColouring); } else { @@ -3020,8 +3039,8 @@ public class Jalview2XML for (int i = 0; i < JSEQ.length; i++) { - af.viewport.setSequenceColour(af.viewport.getAlignment().getSequenceAt(i), - new java.awt.Color(JSEQ[i].getColour())); + af.viewport.setSequenceColour(af.viewport.getAlignment() + .getSequenceAt(i), new java.awt.Color(JSEQ[i].getColour())); } af.viewport.gatherViewsHere = view.getGatheredViews(); @@ -3143,8 +3162,8 @@ public class Jalview2XML if (view.getAnnotationColours().getColourScheme() .equals("None")) { - cs = new AnnotationColourGradient( - af.viewport.getAlignment().getAlignmentAnnotation()[i], + cs = new AnnotationColourGradient(af.viewport + .getAlignment().getAlignmentAnnotation()[i], new java.awt.Color(view.getAnnotationColours() .getMinColour()), new java.awt.Color(view .getAnnotationColours().getMaxColour()), @@ -3153,16 +3172,16 @@ public class Jalview2XML else if (view.getAnnotationColours().getColourScheme() .startsWith("ucs")) { - cs = new AnnotationColourGradient( - af.viewport.getAlignment().getAlignmentAnnotation()[i], + cs = new AnnotationColourGradient(af.viewport + .getAlignment().getAlignmentAnnotation()[i], GetUserColourScheme(jms, view .getAnnotationColours().getColourScheme()), view.getAnnotationColours().getAboveThreshold()); } else { - cs = new AnnotationColourGradient( - af.viewport.getAlignment().getAlignmentAnnotation()[i], + cs = new AnnotationColourGradient(af.viewport + .getAlignment().getAlignmentAnnotation()[i], ColourSchemeProperty.getColour(al, view .getAnnotationColours().getColourScheme()), view.getAnnotationColours().getAboveThreshold()); @@ -3173,8 +3192,8 @@ public class Jalview2XML { for (int g = 0; g < al.getGroups().size(); g++) { - jalview.datamodel.SequenceGroup sg = al - .getGroups().get(g); + jalview.datamodel.SequenceGroup sg = al.getGroups() + .get(g); if (sg.cs == null) { @@ -3193,8 +3212,8 @@ public class Jalview2XML * view.getAnnotationColours().getAboveThreshold()); } else */ { - sg.cs = new AnnotationColourGradient( - af.viewport.getAlignment().getAlignmentAnnotation()[i], + sg.cs = new AnnotationColourGradient(af.viewport + .getAlignment().getAlignmentAnnotation()[i], sg.cs, view.getAnnotationColours() .getAboveThreshold()); } @@ -3242,8 +3261,8 @@ public class Jalview2XML } if (view.hasIgnoreGapsinConsensus()) { - af.viewport.setIgnoreGapsConsensus(view - .getIgnoreGapsinConsensus(), null); + af.viewport.setIgnoreGapsConsensus(view.getIgnoreGapsinConsensus(), + null); } if (view.hasFollowHighlight()) { @@ -3415,14 +3434,16 @@ public class Jalview2XML } for (JvAnnotRow auan : autoAlan) { - visan.put(auan.template.label+(auan.template.getCalcId()==null ? "" : "\t"+auan.template.getCalcId()), auan); + visan.put(auan.template.label + + (auan.template.getCalcId() == null ? "" : "\t" + + auan.template.getCalcId()), auan); } int hSize = al.getAlignmentAnnotation().length; ArrayList reorder = new ArrayList(); // work through any autoCalculated annotation already on the view // removing it if it should be placed in a different location on the // annotation panel. - List remains=new ArrayList(visan.keySet()); + List remains = new ArrayList(visan.keySet()); for (int h = 0; h < hSize; h++) { jalview.datamodel.AlignmentAnnotation jalan = al @@ -3430,12 +3451,12 @@ public class Jalview2XML if (jalan.autoCalculated) { String k; - JvAnnotRow valan = visan.get(k=jalan.label); - if (jalan.getCalcId()!=null) + JvAnnotRow valan = visan.get(k = jalan.label); + if (jalan.getCalcId() != null) { - valan = visan.get(k=jalan.label+ "\t"+jalan.getCalcId()); + valan = visan.get(k = jalan.label + "\t" + jalan.getCalcId()); } - + if (valan != null) { // delete the auto calculated row from the alignment @@ -3462,11 +3483,13 @@ public class Jalview2XML } } } - // Add any (possibly stale) autocalculated rows that were not appended to the view during construction - for (String other:remains) + // Add any (possibly stale) autocalculated rows that were not appended to + // the view during construction + for (String other : remains) { - JvAnnotRow othera=visan.get(other); - if (othera!=nullAnnot && othera.template.getCalcId()!=null && othera.template.getCalcId().length()>0) + JvAnnotRow othera = visan.get(other); + if (othera != nullAnnot && othera.template.getCalcId() != null + && othera.template.getCalcId().length() > 0) { reorder.add(othera); } diff --git a/src/jalview/renderer/AnnotationRenderer.java b/src/jalview/renderer/AnnotationRenderer.java index 8588bf2..e527c10 100644 --- a/src/jalview/renderer/AnnotationRenderer.java +++ b/src/jalview/renderer/AnnotationRenderer.java @@ -560,7 +560,6 @@ public class AnnotationRenderer { aa[gg].visible = false; } - if (aa[gg].graphMax > groupmax) { groupmax = aa[gg].graphMax; diff --git a/src/jalview/ws/jws2/AAConsClient.java b/src/jalview/ws/jws2/AAConsClient.java index 42a7bdb..c565915 100644 --- a/src/jalview/ws/jws2/AAConsClient.java +++ b/src/jalview/ws/jws2/AAConsClient.java @@ -28,19 +28,27 @@ public class AAConsClient extends JabawsAlignCalcWorker alignedSeqs = true; nucleotidesAllowed = false; proteinAllowed = true; - gapMap=new boolean[0]; + gapMap = new boolean[0]; initViewportParams(); } protected void initViewportParams() { - ((jalview.gui.AlignViewport) alignViewport).setCalcIdSettingsFor(getCalcId(), new AAConsSettings(true, service, this.preset, (arguments!=null) ? JabaParamStore.getJwsArgsfromJaba(arguments) : null), true); + ((jalview.gui.AlignViewport) alignViewport).setCalcIdSettingsFor( + getCalcId(), + new AAConsSettings(true, service, this.preset, + (arguments != null) ? JabaParamStore + .getJwsArgsfromJaba(arguments) : null), true); } + @Override - public void updateParameters(WsParamSetI newpreset, java.util.List newarguments) { + public void updateParameters(WsParamSetI newpreset, + java.util.List newarguments) + { super.updateParameters(newpreset, newarguments); initViewportParams(); }; + public String getServiceActionText() { return "calculating Amino acid consensus using AACons service"; @@ -97,13 +105,10 @@ public class AAConsClient extends JabawsAlignCalcWorker public static void removeAAConsAnnotation(AlignmentPanel alignPanel) { - for (AlignmentAnnotation aa: alignPanel.getAlignment().findAnnotation(SequenceAnnotationWSClient.AAConsCalcId)) + for (AlignmentAnnotation aa : alignPanel.getAlignment().findAnnotation( + SequenceAnnotationWSClient.AAConsCalcId)) { alignPanel.getAlignment().deleteAnnotation(aa); } - // List - // ourannots=alignPanel.getAlignment().findAnnotation(Screen3D.) - // TODO Auto-generated method stub - } } diff --git a/src/jalview/ws/jws2/JabawsAlignCalcWorker.java b/src/jalview/ws/jws2/JabawsAlignCalcWorker.java index d8807e7..58cb3ac 100644 --- a/src/jalview/ws/jws2/JabawsAlignCalcWorker.java +++ b/src/jalview/ws/jws2/JabawsAlignCalcWorker.java @@ -41,6 +41,7 @@ import compbio.metadata.WrongParameterException; public abstract class JabawsAlignCalcWorker extends AlignCalcWorker { Jws2Instance service; + @SuppressWarnings("unchecked") protected SequenceAnnotation aaservice; @@ -84,7 +85,7 @@ public abstract class JabawsAlignCalcWorker extends AlignCalcWorker * reconfigure and restart the AAConsClient. This method will spawn a new * thread that will wait until any current jobs are finished, modify the * parameters and restart the conservation calculation with the new values. - * + * * @param newpreset * @param newarguments */ @@ -128,7 +129,7 @@ public abstract class JabawsAlignCalcWorker extends AlignCalcWorker int serverErrorsLeft = 3; String rslt = "JOB NOT DEFINED"; - StringBuffer msg=new StringBuffer(); + StringBuffer msg = new StringBuffer(); try { if (checkDone()) @@ -151,7 +152,7 @@ public abstract class JabawsAlignCalcWorker extends AlignCalcWorker guiProgress.setProgressBar("JABA " + getServiceActionText(), progressId = System.currentTimeMillis()); } - if (preset == null && arguments==null) + if (preset == null && arguments == null) { rslt = aaservice.analize(seqs); } @@ -310,19 +311,22 @@ public abstract class JabawsAlignCalcWorker extends AlignCalcWorker if (ap != null) { calcMan.workerComplete(this); - if (guiProgress != null && progressId!=-1) + if (guiProgress != null && progressId != -1) { guiProgress.setProgressBar("", progressId); } ap.paintAlignment(true); } - if (msg.length()>0) + if (msg.length() > 0) { // TODO: stash message somewhere in annotation or alignment view. // code below shows result in a text box popup - /* jalview.gui.CutAndPasteTransfer cap = new jalview.gui.CutAndPasteTransfer(); - cap.setText(msg.toString()); - jalview.gui.Desktop.addInternalFrame(cap, "Job Status for "+getServiceActionText(), 600, 400); */ + /* + * jalview.gui.CutAndPasteTransfer cap = new + * jalview.gui.CutAndPasteTransfer(); cap.setText(msg.toString()); + * jalview.gui.Desktop.addInternalFrame(cap, + * "Job Status for "+getServiceActionText(), 600, 400); + */ } } @@ -352,8 +356,11 @@ public abstract class JabawsAlignCalcWorker extends AlignCalcWorker protected boolean bySequence = false; Map seqNames; + boolean[] gapMap; + int realw; + public List getInputSequences(AlignmentI alignment) { if (alignment == null || alignment.getWidth() <= 0 @@ -372,7 +379,7 @@ public abstract class JabawsAlignCalcWorker extends AlignCalcWorker { seqNames = new HashMap(); } - gapMap=new boolean[0]; + gapMap = new boolean[0]; for (SequenceI sq : ((List) alignment.getSequences())) { if (sq.getEnd() - sq.getStart() > minlen - 1) @@ -386,25 +393,28 @@ public abstract class JabawsAlignCalcWorker extends AlignCalcWorker FastaSequence seq; if (submitGaps) { - seqs.add(seq = new compbio.data.sequence.FastaSequence(newname,sq.getSequenceAsString())); - if (gapMap==null || gapMap.length ln) { @@ -415,7 +425,7 @@ public abstract class JabawsAlignCalcWorker extends AlignCalcWorker if (alignedSeqs && submitGaps) { realw = 0; - for (int i=0;ipp) + if (orig.length > pp) { - padded[i++]=orig[pp]; - } else { - padded[i++]='-'; - } + padded[i++] = orig[pp]; + } + else + { + padded[i++] = '-'; + } } } seqs.set(p, new compbio.data.sequence.FastaSequence(sq.getId(), - new String(padded))); + new String(padded))); } } return seqs; @@ -452,7 +465,7 @@ public abstract class JabawsAlignCalcWorker extends AlignCalcWorker /** * notify manager that we have started, and wait for a free calculation slot - * + * * @return true if slot is obtained and work still valid, false if another * thread has done our work for us. */ -- 1.7.10.2