X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=blobdiff_plain;f=src%2Fjalview%2Fext%2Fvarna%2FVarnaCommands.java;h=a1d3a778841b0e96c32cee4f0cc299cf99295b71;hp=9d57969d73f3e079823cec21e0f03be6a7bbe2f3;hb=b57a02c25e335d033c97f8a6bacd6b54f62bd2b6;hpb=1cc81e06ac2faa5ee4b8879e9fa019956e34259f diff --git a/src/jalview/ext/varna/VarnaCommands.java b/src/jalview/ext/varna/VarnaCommands.java index 9d57969..a1d3a77 100644 --- a/src/jalview/ext/varna/VarnaCommands.java +++ b/src/jalview/ext/varna/VarnaCommands.java @@ -15,31 +15,35 @@ import java.awt.Color; import java.util.ArrayList; /** - * Routines for generating Jmol commands for Jalview/Jmol binding - * another cruisecontrol test. + * Routines for generating Jmol commands for Jalview/Jmol binding another + * cruisecontrol test. * * @author JimP - * + * */ public class VarnaCommands { /** - * Jmol utility which constructs the commands to colour chains by the given alignment + * Jmol utility which constructs the commands to colour chains by the given + * alignment * */ - public static String[] getColourBySequenceCommand(StructureSelectionManager ssm, String[] files, SequenceI[][] sequence, SequenceRenderer sr, FeatureRenderer fr, AlignmentI alignment) + public static String[] getColourBySequenceCommand( + StructureSelectionManager ssm, String[] files, + SequenceI[][] sequence, SequenceRenderer sr, FeatureRenderer fr, + AlignmentI alignment) { ArrayList str = new ArrayList(); StringBuffer command = new StringBuffer(); - + for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++) { StructureMapping[] mapping = ssm.getMapping(files[pdbfnum]); - + if (mapping == null || mapping.length < 1) continue; - + int lastPos = -1; for (int s = 0; s < sequence[pdbfnum].length; s++) { @@ -57,14 +61,14 @@ public class VarnaCommands continue; } int pos = mapping[m].getPDBResNum(asp.findPosition(r)); - + if (pos < 1 || pos == lastPos) continue; - + lastPos = pos; - + Color col = sr.getResidueBoxColour(sequence[pdbfnum][s], r); - + if (fr != null) col = fr.findFeatureColour(col, sequence[pdbfnum][s], r); String newSelcom = (mapping[m].getChain() != " " ? ":" @@ -78,16 +82,19 @@ public class VarnaCommands + col.getGreen() + "," + col.getBlue() + "]"; - if (command.length()>newSelcom.length() && command.substring(command.length()-newSelcom.length()).equals(newSelcom)) + if (command.length() > newSelcom.length() + && command.substring( + command.length() - newSelcom.length()) + .equals(newSelcom)) { command = VarnaCommands.condenseCommand(command, pos); continue; } // TODO: deal with case when buffer is too large for Jmol to parse // - execute command and flush - + command.append(";"); - if (command.length()>51200) + if (command.length() > 51200) { // add another chunk str.add(command.toString()); @@ -111,20 +118,25 @@ public class VarnaCommands public static StringBuffer condenseCommand(StringBuffer command, int pos) { - + // work back to last 'select' - int p=command.length(),q=p; - do { - p-=6; - if (p<1) { p=0; }; - } while ((q=command.indexOf("select",p))==-1 && p>0); - - StringBuffer sb = new StringBuffer(command.substring(0,q+7)); - - command = command.delete(0,q+7); - + int p = command.length(), q = p; + do + { + p -= 6; + if (p < 1) + { + p = 0; + } + ; + } while ((q = command.indexOf("select", p)) == -1 && p > 0); + + StringBuffer sb = new StringBuffer(command.substring(0, q + 7)); + + command = command.delete(0, q + 7); + String start; - + if (command.indexOf("-") > -1) { start = command.substring(0, command.indexOf("-")); @@ -133,9 +145,9 @@ public class VarnaCommands { start = command.substring(0, command.indexOf(":")); } - + sb.append(start + "-" + pos + command.substring(command.indexOf(":"))); - + return sb; }