| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.ext.varna; |
| 22 |
|
|
| 23 |
|
import jalview.api.SequenceRenderer; |
| 24 |
|
import jalview.datamodel.AlignmentI; |
| 25 |
|
import jalview.datamodel.SequenceI; |
| 26 |
|
import jalview.renderer.seqfeatures.FeatureColourFinder; |
| 27 |
|
import jalview.structure.StructureMapping; |
| 28 |
|
import jalview.structure.StructureSelectionManager; |
| 29 |
|
|
| 30 |
|
import java.awt.Color; |
| 31 |
|
import java.util.ArrayList; |
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
@author |
| 38 |
|
|
| 39 |
|
|
| |
|
| 0% |
Uncovered Elements: 77 (77) |
Complexity: 21 |
Complexity Density: 0.45 |
|
| 40 |
|
public class VarnaCommands |
| 41 |
|
{ |
| 42 |
|
|
| 43 |
|
|
| 44 |
|
|
| 45 |
|
|
| 46 |
|
|
| 47 |
|
|
| |
|
| 0% |
Uncovered Elements: 55 (55) |
Complexity: 16 |
Complexity Density: 0.48 |
|
| 48 |
0 |
public static String[] getColourBySequenceCommand(... |
| 49 |
|
StructureSelectionManager ssm, String[] files, |
| 50 |
|
SequenceI[][] sequence, SequenceRenderer sr, |
| 51 |
|
FeatureColourFinder finder, AlignmentI alignment) |
| 52 |
|
{ |
| 53 |
0 |
ArrayList<String> str = new ArrayList<String>(); |
| 54 |
0 |
StringBuffer command = new StringBuffer(); |
| 55 |
|
|
| 56 |
0 |
for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++) |
| 57 |
|
{ |
| 58 |
0 |
StructureMapping[] mapping = ssm.getMapping(files[pdbfnum]); |
| 59 |
|
|
| 60 |
0 |
if (mapping == null || mapping.length < 1) |
| 61 |
|
{ |
| 62 |
0 |
continue; |
| 63 |
|
} |
| 64 |
|
|
| 65 |
0 |
int lastPos = -1; |
| 66 |
0 |
for (int s = 0; s < sequence[pdbfnum].length; s++) |
| 67 |
|
{ |
| 68 |
0 |
for (int sp, m = 0; m < mapping.length; m++) |
| 69 |
|
{ |
| 70 |
0 |
if (mapping[m].getSequence() == sequence[pdbfnum][s] |
| 71 |
|
&& (sp = alignment.findIndex(sequence[pdbfnum][s])) > -1) |
| 72 |
|
{ |
| 73 |
0 |
SequenceI asp = alignment.getSequenceAt(sp); |
| 74 |
0 |
for (int r = 0; r < asp.getLength(); r++) |
| 75 |
|
{ |
| 76 |
|
|
| 77 |
0 |
if (jalview.util.Comparison.isGap(asp.getCharAt(r))) |
| 78 |
|
{ |
| 79 |
0 |
continue; |
| 80 |
|
} |
| 81 |
0 |
int pos = mapping[m].getPDBResNum(asp.findPosition(r)); |
| 82 |
|
|
| 83 |
0 |
if (pos < 1 || pos == lastPos) |
| 84 |
|
{ |
| 85 |
0 |
continue; |
| 86 |
|
} |
| 87 |
|
|
| 88 |
0 |
lastPos = pos; |
| 89 |
|
|
| 90 |
0 |
Color col = sr.getResidueColour(sequence[pdbfnum][s], r, |
| 91 |
|
finder); |
| 92 |
|
|
| 93 |
0 |
String newSelcom = (mapping[m].getChain() != " " |
| 94 |
|
? ":" + mapping[m].getChain() |
| 95 |
|
: "") + "/" + (pdbfnum + 1) + ".1" + ";color[" |
| 96 |
|
+ col.getRed() + "," + col.getGreen() + "," |
| 97 |
|
+ col.getBlue() + "]"; |
| 98 |
0 |
if (command.length() > newSelcom.length() && command |
| 99 |
|
.substring(command.length() - newSelcom.length()) |
| 100 |
|
.equals(newSelcom)) |
| 101 |
|
{ |
| 102 |
0 |
command = VarnaCommands.condenseCommand(command, pos); |
| 103 |
0 |
continue; |
| 104 |
|
} |
| 105 |
|
|
| 106 |
|
|
| 107 |
|
|
| 108 |
0 |
command.append(";"); |
| 109 |
0 |
if (command.length() > 51200) |
| 110 |
|
{ |
| 111 |
|
|
| 112 |
0 |
str.add(command.toString()); |
| 113 |
0 |
command.setLength(0); |
| 114 |
|
} |
| 115 |
0 |
command.append("select " + pos); |
| 116 |
0 |
command.append(newSelcom); |
| 117 |
|
} |
| 118 |
0 |
break; |
| 119 |
|
} |
| 120 |
|
} |
| 121 |
|
} |
| 122 |
|
} |
| 123 |
|
{ |
| 124 |
|
|
| 125 |
0 |
str.add(command.toString()); |
| 126 |
0 |
command.setLength(0); |
| 127 |
|
} |
| 128 |
0 |
return str.toArray(new String[str.size()]); |
| 129 |
|
} |
| 130 |
|
|
| |
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 5 |
Complexity Density: 0.36 |
|
| 131 |
0 |
public static StringBuffer condenseCommand(StringBuffer command, int pos)... |
| 132 |
|
{ |
| 133 |
|
|
| 134 |
|
|
| 135 |
0 |
int p = command.length(), q = p; |
| 136 |
0 |
do |
| 137 |
|
{ |
| 138 |
0 |
p -= 6; |
| 139 |
0 |
if (p < 1) |
| 140 |
|
{ |
| 141 |
0 |
p = 0; |
| 142 |
|
} |
| 143 |
0 |
; |
| 144 |
? |
} while ((q = command.indexOf("select", p)) == -1 && p > 0); |
| 145 |
|
|
| 146 |
0 |
StringBuffer sb = new StringBuffer(command.substring(0, q + 7)); |
| 147 |
|
|
| 148 |
0 |
command = command.delete(0, q + 7); |
| 149 |
|
|
| 150 |
0 |
String start; |
| 151 |
|
|
| 152 |
0 |
if (command.indexOf("-") > -1) |
| 153 |
|
{ |
| 154 |
0 |
start = command.substring(0, command.indexOf("-")); |
| 155 |
|
} |
| 156 |
|
else |
| 157 |
|
{ |
| 158 |
0 |
start = command.substring(0, command.indexOf(":")); |
| 159 |
|
} |
| 160 |
|
|
| 161 |
0 |
sb.append(start + "-" + pos + command.substring(command.indexOf(":"))); |
| 162 |
|
|
| 163 |
0 |
return sb; |
| 164 |
|
} |
| 165 |
|
|
| 166 |
|
} |