Skip to content

Commit 46a3fac

Browse files
committed
Merge pull request #265 from lafita/patch
Patch
2 parents 66c3860 + 1075567 commit 46a3fac

File tree

9 files changed

+221
-44
lines changed

9 files changed

+221
-44
lines changed

biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/DisplayAFP.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,16 @@ public static final List<Integer> getEQRAlignmentPos(AFPChain afpChain){
7575

7676
private static boolean isAlignedPosition(int i, char c1, char c2, boolean isFatCat,char[]symb)
7777
{
78-
if ( isFatCat){
78+
// if ( isFatCat){
7979
char s = symb[i];
8080
if ( c1 != '-' && c2 != '-' && s != ' '){
8181
return true;
8282
}
83-
} else {
84-
85-
if ( c1 != '-' && c2 != '-')
86-
return true;
87-
}
83+
// } else {
84+
//
85+
// if ( c1 != '-' && c2 != '-')
86+
// return true;
87+
// }
8888

8989
return false;
9090

biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/aligpanel/AligPanel.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ public void paintComponent(Graphics g){
244244
else
245245
isGapped = true;
246246
} else {
247-
if ( c1 != '-' && c2 != '-' ){
247+
char s = symb[i];
248+
if ( c1 != '-' && c2 != '-' && s!= ' '){
248249
// no gap
249250
g2D.setFont(eqFont);
250251
} else {
@@ -276,7 +277,7 @@ public void paintComponent(Graphics g){
276277
} else {
277278

278279
int colorPos = 0;
279-
if (isFATCAT ) {
280+
if (isFATCAT) {
280281
int block = 0;
281282
char s = symb[i];
282283
try {
@@ -291,11 +292,19 @@ public void paintComponent(Graphics g){
291292
colorPos = ColorUtils.colorWheel.length % colorPos ;
292293
}
293294
} else {
294-
colorPos = AFPAlignmentDisplay.getBlockNrForAlignPos(afpChain, i);
295-
bg = ColorUtils.getIntermediate(ColorUtils.orange, end1, blockNum, colorPos);
296-
bg2 = ColorUtils.getIntermediate(ColorUtils.cyan, end2, blockNum, colorPos);
297-
//bg = ColorUtils.rotateHue(ColorUtils.orange, (1.0f / 24.0f) * colorPos );
298-
//bg2 = ColorUtils.rotateHue(ColorUtils.cyan, (1.0f / 16.0f) * colorPos);
295+
colorPos = AFPAlignmentDisplay.getBlockNrForAlignPos(afpChain, i);
296+
if (afpChain.getBlockColors()==null){
297+
bg = ColorUtils.getIntermediate(ColorUtils.orange, end1, blockNum, colorPos);
298+
bg2 = ColorUtils.getIntermediate(ColorUtils.cyan, end2, blockNum, colorPos);
299+
//bg = ColorUtils.rotateHue(ColorUtils.orange, (1.0f / 24.0f) * colorPos );
300+
//bg2 = ColorUtils.rotateHue(ColorUtils.cyan, (1.0f / 16.0f) * colorPos);
301+
}
302+
else{
303+
Color[] colors = afpChain.getBlockColors();
304+
int n = colors.length;
305+
bg = colors[colorPos%n];
306+
bg2 = colors[((colorPos+1)%n)%afpChain.getBlockNum()];
307+
}
299308
}
300309

301310

biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/jmol/StructureAlignmentJmol.java

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ public void actionPerformed(ActionEvent e) {
541541

542542
}
543543

544-
public static String getJmolString(AFPChain afpChain, Atom[] ca1, Atom[] ca2){
544+
public String getJmolString(AFPChain afpChain, Atom[] ca1, Atom[] ca2){
545545

546546
if ( afpChain.getBlockNum() > 1){
547547
return getMultiBlockJmolScript( afpChain, ca1, ca2);
@@ -633,7 +633,7 @@ public static String getJmolScript4Block(AFPChain afpChain, Atom[] ca1, Atom[] c
633633

634634
jmol.append("select */2; color lightgrey; model 2; ");
635635

636-
printJmolScript4Block(ca1, ca2, blockNum, optLen, optAln, jmol, blockNr);
636+
printJmolScript4Block(ca1, ca2, blockNum, optLen, optAln, jmol, blockNr, afpChain.getBlockColors());
637637

638638
jmol.append("model 0; ");
639639
jmol.append(LIGAND_DISPLAY_SCRIPT);
@@ -661,7 +661,7 @@ private static String getMultiBlockJmolScript(AFPChain afpChain, Atom[] ca1, Ato
661661

662662
for(int bk = 0; bk < blockNum; bk ++) {
663663

664-
printJmolScript4Block(ca1, ca2, blockNum, optLen, optAln, jmol, bk);
664+
printJmolScript4Block(ca1, ca2, blockNum, optLen, optAln, jmol, bk, afpChain.getBlockColors());
665665
}
666666
jmol.append("model 0; ");
667667
jmol.append(LIGAND_DISPLAY_SCRIPT);
@@ -672,21 +672,31 @@ private static String getMultiBlockJmolScript(AFPChain afpChain, Atom[] ca1, Ato
672672
}
673673

674674
private static void printJmolScript4Block(Atom[] ca1, Atom[] ca2, int blockNum,
675-
int[] optLen, int[][][] optAln, StringWriter jmol, int bk) {
675+
int[] optLen, int[][][] optAln, StringWriter jmol, int bk, Color[] colors) {
676676
//the block nr determines the color...
677677
int colorPos = bk;
678-
if ( colorPos > ColorUtils.colorWheel.length){
679-
colorPos = ColorUtils.colorWheel.length % colorPos ;
680-
}
681-
682-
Color end1 = ColorUtils.rotateHue(ColorUtils.orange, (1.0f / 24.0f) * blockNum );
683-
Color end2 = ColorUtils.rotateHue(ColorUtils.cyan, (1.0f / 24.0f) * (blockNum +1) ) ;
684-
685-
Color c1 = ColorUtils.getIntermediate(ColorUtils.orange, end1, blockNum, bk);
686-
Color c2 = ColorUtils.getIntermediate(ColorUtils.cyan, end2, blockNum, bk);
687-
688-
689678

679+
Color c1;
680+
Color c2;
681+
//If the colors for the block are specified in AFPChain use them, otherwise the default ones are calculated
682+
if (colors==null){
683+
684+
if ( colorPos > ColorUtils.colorWheel.length){
685+
colorPos = ColorUtils.colorWheel.length % colorPos ;
686+
}
687+
688+
Color end1 = ColorUtils.rotateHue(ColorUtils.orange, (1.0f / 24.0f) * blockNum );
689+
Color end2 = ColorUtils.rotateHue(ColorUtils.cyan, (1.0f / 24.0f) * (blockNum +1) ) ;
690+
691+
c1 = ColorUtils.getIntermediate(ColorUtils.orange, end1, blockNum, bk);
692+
c2 = ColorUtils.getIntermediate(ColorUtils.cyan, end2, blockNum, bk);
693+
}
694+
else{
695+
int n = colors.length;
696+
697+
c1 = colors[colorPos%n];
698+
c2 = colors[(colorPos+1%n)%blockNum];
699+
}
690700

691701
List<String> pdb1 = new ArrayList<String>();
692702
List<String> pdb2 = new ArrayList<String>();

biojava-structure/src/main/java/org/biojava/nbio/structure/align/ce/CECalculator.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,6 +1060,7 @@ private void checkBestTraces( AFPChain afpChain,
10601060
inner_loop:
10611061
for(int idep=1; idep<=winSize/2; idep++) {
10621062

1063+
// isCopied indicates that bestTrace has changed and needs to be re-copied
10631064
if(!isCopied)
10641065
for(jt=0; jt<nBestTrace; jt++) {
10651066
trace1[jt]=bestTrace1[jt];
@@ -1068,11 +1069,13 @@ private void checkBestTraces( AFPChain afpChain,
10681069
}
10691070
isCopied=false;
10701071

1072+
// Move an atom from the previous trace to the current on, or vice versa
10711073
traceLen[it-1]+=idir;
10721074
traceLen[it]-=idir;
10731075
trace1[it]+=idir;
10741076
trace2[it]+=idir;
10751077

1078+
// Copy atoms from the current trace into strBuf
10761079
is=0;
10771080
for(jt=0; jt<nBestTrace; jt++) {
10781081
for(int i=0; i<traceLen[jt]; i++) {
@@ -1083,9 +1086,12 @@ private void checkBestTraces( AFPChain afpChain,
10831086
}
10841087
is+=traceLen[jt];
10851088
}
1089+
// Check new RMSD
10861090
//sup_str(strBuf1, strBuf2, strLen, d_);
10871091
rmsdNew=calc_rmsd(strBuf1, strBuf2, strLen, true);
10881092
//System.out.println(String.format("step %d %d %d %.2f old: %.2f", it, idir, idep, rmsdNew, rmsd));
1093+
1094+
// Update best trace if RMSD improved
10891095
if(rmsdNew<rmsd) {
10901096

10911097
for(jt=0; jt<nBestTrace; jt++) {
@@ -1394,13 +1400,13 @@ private int optimizeSuperposition(AFPChain afpChain, int nse1, int nse2, int str
13941400

13951401
}
13961402
}
1397-
1398-
mat = notifyMatrixListener(mat);
13991403

14001404
if ( params.getScoringStrategy() == CeParameters.ScoringStrategy.SEQUENCE_CONSERVATION){
14011405
mat = updateMatrixWithSequenceConservation(mat,ca1,ca2, params);
14021406
}
14031407

1408+
mat = notifyMatrixListener(mat);
1409+
14041410
double gapOpen = params.getGapOpen();
14051411
double gapExtension = params.getGapExtension();
14061412

biojava-structure/src/main/java/org/biojava/nbio/structure/align/ce/CeUserArgumentProcessor.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
*/
3636
public class CeUserArgumentProcessor extends AbstractUserArgumentProcessor {
3737

38-
protected class CeStartupParams extends StartupParameters {
38+
protected static class CeStartupParams extends StartupParameters {
3939
protected int maxGapSize;
4040
protected int winSize;
4141
protected ScoringStrategy scoringStrategy;
@@ -203,7 +203,6 @@ public String getDbSearchLegend(){
203203

204204
return "# name1\tname2\tscore\tz-score\trmsd\tlen1\tlen2\tcov1\tcov2\t%ID\tDescription\t " ;
205205

206-
207206
}
208207

209208

biojava-structure/src/main/java/org/biojava/nbio/structure/align/model/AFPChain.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.biojava.nbio.structure.align.util.AFPAlignmentDisplay;
2626
import org.biojava.nbio.structure.jama.Matrix;
2727

28+
import java.awt.Color;
2829
import java.io.Serializable;
2930
import java.util.ArrayList;
3031
import java.util.Arrays;
@@ -105,6 +106,7 @@ public class AFPChain implements Serializable, Cloneable
105106
int[][][] blockResList;//the list of AFP for each block
106107
Matrix[] blockRotationMatrix;
107108
Atom[] blockShiftVector;
109+
Color[] blockColors; //An array of colors for each block, size = blockNum.
108110

109111
int focusResn; //the size of the set
110112
int[] focusRes1; //the residues from protein 1
@@ -1282,6 +1284,16 @@ public void setBlockShiftVector(Atom[] blockShiftVector)
12821284
{
12831285
this.blockShiftVector = blockShiftVector;
12841286
}
1287+
1288+
public Color[] getBlockColors()
1289+
{
1290+
return blockColors;
1291+
}
1292+
1293+
public void setBlockColors(Color[] colors)
1294+
{
1295+
this.blockColors = colors;
1296+
}
12851297

12861298
public String getAlgorithmName() {
12871299
return algorithmName;

biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AFPAlignmentDisplay.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -449,19 +449,18 @@ public static int getBlockNrForAlignPos(AFPChain afpChain, int aligPos){
449449
}
450450
}
451451

452-
len++;
452+
453453
p1b = p1;
454454
p2b = p2;
455455
if ( len >= aligPos) {
456456

457457
return i;
458458
}
459+
len++;
459460
}
460461
}
461462

462463
return blockNum;
463464

464465
}
465-
466-
467466
}

0 commit comments

Comments
 (0)