X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2Fjws2%2FRNAalifoldClient.java;h=b3000b3714349f3aa61879a39af8cbc30453e5b7;hb=ab43013b7e357b84b4abade0dba949668dfb2a0e;hp=277973241f04401bae6d30edcac185b80eee7e88;hpb=6c54f6a2f72b57aa1f803d68241549e050ae68e8;p=jalview.git diff --git a/src/jalview/ws/jws2/RNAalifoldClient.java b/src/jalview/ws/jws2/RNAalifoldClient.java index 2779732..b3000b3 100644 --- a/src/jalview/ws/jws2/RNAalifoldClient.java +++ b/src/jalview/ws/jws2/RNAalifoldClient.java @@ -1,3 +1,23 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2b1) + * Copyright (C) 2014 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. + */ package jalview.ws.jws2; import jalview.api.AlignCalcWorkerI; @@ -17,6 +37,7 @@ import java.util.TreeSet; import java.util.regex.Pattern; import compbio.data.sequence.RNAStructReader.AlifoldResult; +import compbio.data.sequence.FastaSequence; import compbio.data.sequence.RNAStructScoreManager; import compbio.data.sequence.Range; import compbio.data.sequence.Score; @@ -24,11 +45,12 @@ import compbio.metadata.Argument; /** * Client for the JABA RNA Alifold Service + * * @author daluke - Daniel Barton - * + * */ -public class RNAalifoldClient extends JabawsAlignCalcWorker implements +public class RNAalifoldClient extends JabawsCalcWorker implements AlignCalcWorkerI { @@ -44,24 +66,21 @@ public class RNAalifoldClient extends JabawsAlignCalcWorker implements WsParamSetI preset, List paramset) { super(sh, alignFrame, preset, paramset); - - //if (arguments == null) - // arguments = new ArrayList(); - af = alignFrame; methodName = sh.serviceType; - alignedSeqs=true; - submitGaps=true; + alignedSeqs = true; + submitGaps = true; nucleotidesAllowed = true; proteinAllowed = false; initViewportParams(); } - + public String getCalcId() { return CALC_ID; } - private static String CALC_ID="jalview.ws.jws2.RNAalifoldClient"; + + private static String CALC_ID = "jalview.ws.jws2.RNAalifoldClient"; public static AlignAnalysisUIText getAlignAnalysisUITest() { @@ -87,6 +106,12 @@ public class RNAalifoldClient extends JabawsAlignCalcWorker implements } @Override + boolean checkValidInputSeqs(boolean dynamic, List seqs) + { + return (seqs.size() > 1); + } + + @Override public void updateResultAnnotation(boolean immediate) { @@ -198,7 +223,8 @@ public class RNAalifoldClient extends JabawsAlignCalcWorker implements private AlignmentAnnotation constructAnnotationFromScoreHolder( AlignmentAnnotation annotation, String struct, TreeSet data) { - Annotation[] anns = new Annotation[struct.length()]; + Annotation[] anns = new Annotation[gapMap != null ? gapMap.length + 1 + : struct.length()]; if (data != null && data.size() > 1 @@ -216,9 +242,17 @@ public class RNAalifoldClient extends JabawsAlignCalcWorker implements basePairs.put(score.getRanges().first(), new Float(score .getScores().get(0))); } - for (int i = 0; i < struct.length(); i++) - { + for (int i = 0, ri = 0, iEnd = struct.length(); i < iEnd; i++, ri++) + { + if (gapMap != null) + { + // skip any gapped columns in the input data + while (!gapMap[ri]) + { + ri++; + } + } // Return all the contacts associated with position i LinkedHashMap contacts = isContact(basePairs, i + 1); @@ -242,16 +276,27 @@ public class RNAalifoldClient extends JabawsAlignCalcWorker implements } } - anns[i] = new Annotation(struct.substring(i, i + 1), description, + anns[ri] = new Annotation(struct.substring(i, i + 1), description, isSS(struct.charAt(i)), prob); } } else if (data == null || data.size() == 1) { - for (int i = 0; i < struct.length(); i++) + for (int i = 0, ri = 0, iEnd = struct.length(); i < iEnd; i++, ri++) { - - anns[i] = new Annotation(struct.substring(i, i + 1), "", + if (gapMap != null) + { + // skip any gapped columns in the input data + while (!gapMap[ri] && ri < gapMap.length) + { + ri++; + } + if (ri == gapMap.length) + { + break; + } + } + anns[ri] = new Annotation(struct.substring(i, i + 1), "", isSS(struct.charAt(i)), Float.NaN); }