Skip to content

Commit 223ae77

Browse files
committed
Merge pull request biojava#295 from lafita/minor
MultipleAlignment GUI
2 parents 77e0d1c + 20010a5 commit 223ae77

36 files changed

+3492
-2172
lines changed

biojava-structure-gui/src/main/java/demo/DemoMultipleMC.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
import org.biojava.nbio.structure.align.util.AtomCache;
1717

1818
/**
19-
* Demo for running the CEMC Algorithm on a protein family and visualizing the results.
19+
* Demo for running the CEMC Algorithm on a protein family and
20+
* visualizing the results.
2021
* Choose the family by commenting out the protein family names.
2122
*
2223
* @author Aleix Lafita
@@ -26,13 +27,12 @@ public class DemoMultipleMC {
2627

2728
public static void main(String[] args) throws IOException, StructureException, InterruptedException, ExecutionException {
2829

29-
//Specify the structures to align
3030
//ASP-proteinases (CEMC paper)
3131
//List<String> names = Arrays.asList("3app", "4ape", "2apr", "5pep", "1psn", "4cms", "1bbs.A", "1smr.A", "2jxr.A", "1mpp", "2asi", "1am5");
3232
//Protein Kinases (CEMC paper)
3333
//List<String> names = Arrays.asList("1cdk.A", "1cja.A", "1csn", "1b6c.B", "1ir3.A", "1fgk.A", "1byg.A", "1hck", "1blx.A", "3erk", "1bmk.A", "1kob.A", "1tki.A", "1phk", "1a06");
3434
//DHFR (Gerstein 1998 paper)
35-
List<String> names = Arrays.asList("d1dhfa_", "8dfr", "d4dfra_", "3dfr");
35+
//List<String> names = Arrays.asList("d1dhfa_", "8dfr", "d4dfra_", "3dfr");
3636
//TIM barrels (MUSTA paper)
3737
//List<String> names = Arrays.asList("1tim.A", "1vzw", "1nsj", "3tha.A", "4enl", "2mnr", "7tim.A", "1tml", "1btc", "a1piia1", "6xia", "5rub.A", "2taa.B");
3838
//Calcium Binding (MUSTA paper)
@@ -54,7 +54,13 @@ public static void main(String[] args) throws IOException, StructureException, I
5454
//Circular Permutations: SAND and MFPT domains
5555
//List<String> names = Arrays.asList("d2bjqa1", "d1h5pa_", "d1ufna_"); //"d1oqja"
5656
//Flexible domain family of proteins (FatCat paper?)
57-
57+
//Amonium Transporters (Aleix Bachelor's Thesis)
58+
//List<String> names = Arrays.asList("1xqf.A","2b2f.A", "3b9w.A","3hd6.A");
59+
//Cytochrome C Oxidases (Aleix Bachelor's Thesis)
60+
//List<String> names = Arrays.asList("2dyr.A","2gsm.A","2yev.A","3hb3.A","3omn.A","1fft.A","1xme.A","3o0r.B","3ayf.A");
61+
List<String> names = Arrays.asList("2dyr.A","2gsm.A","1fft.A","1xme.A","3o0r.B","3ayf.A");
62+
//Cation Transporting ATPases (Aleix Bachelor's Thesis)
63+
//List<String> names = Arrays.asList("3b8e.A","2zxe.A", "3tlm.A","1iwo.A");
5864
//Ankyrin Repeats
5965
//List<String> names = Arrays.asList("d1n0ra_", "3ehq.A", "1awc.B"); //ankyrin
6066

@@ -66,9 +72,9 @@ public static void main(String[] args) throws IOException, StructureException, I
6672
}
6773

6874
//Here the multiple structural alignment algorithm comes in place to generate the alignment object
69-
MultipleMcMain algorithm = new MultipleMcMain();
75+
MultipleMcMain algorithm = new MultipleMcMain(new CeCPMain());
7076
MultipleMcParameters params = (MultipleMcParameters) algorithm.getParameters();
71-
params.setPairwiseAlgorithm(CeCPMain.algorithmName);
77+
params.setMinBlockLen(10);
7278

7379
MultipleAlignment result = algorithm.align(atomArrays);
7480
result.getEnsemble().setStructureNames(names);

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
*/
2323
package org.biojava.nbio.structure.align.gui;
2424

25-
2625
import org.biojava.nbio.structure.Structure;
2726
import org.biojava.nbio.structure.StructureException;
2827
import org.biojava.nbio.structure.align.StructureAlignment;
@@ -43,7 +42,6 @@
4342
import java.awt.event.ActionEvent;
4443
import java.io.File;
4544

46-
4745
/** A JFrame that allows to trigger a pairwise structure alignment,
4846
* either from files in a directory,
4947
* or after manual upload.
@@ -323,10 +321,9 @@ public void actionPerformed(ActionEvent evt) {
323321
protected void configureParameters() {
324322
StructureAlignment algorithm = getStructureAlignment();
325323
System.out.println("configure parameters for " + algorithm.getAlgorithmName());
326-
324+
327325
// show a new config GUI
328-
new ParameterGUI(algorithm);
329-
326+
new ParameterGUI(algorithm.getParameters(), algorithm.getAlgorithmName());
330327
}
331328

332329

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

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
import org.biojava.nbio.structure.align.gui.jmol.AbstractAlignmentJmol;
2626
import org.biojava.nbio.structure.align.model.AFPChain;
27-
import org.biojava.nbio.structure.align.multiple.MultipleAlignment;
2827
import org.biojava.nbio.structure.align.util.UserConfiguration;
2928
import org.biojava.nbio.structure.align.webstart.WebStartMain;
3029

@@ -122,6 +121,7 @@ public static JMenuBar initJmolMenu(JFrame frame, AbstractAlignmentJmol parent,
122121
//Exit
123122
JMenuItem exitI = getExitMenuItem();
124123
file.add(exitI);
124+
125125
menu.add(file);
126126

127127
/// ALIGN MENU
@@ -130,7 +130,10 @@ public static JMenuBar initJmolMenu(JFrame frame, AbstractAlignmentJmol parent,
130130
//new Pairwise alignment
131131
JMenuItem pairI = getPairwiseAlignmentMenuItem();
132132
align.add(pairI);
133-
//new Multiple alignment TODO
133+
//new Multiple alignment
134+
JMenuItem multI = getMultipleAlignmentMenuItem();
135+
align.add(multI);
136+
134137
menu.add(align);
135138

136139
/// VIEW MENU
@@ -626,13 +629,21 @@ public void actionPerformed(ActionEvent e) {
626629
}
627630

628631

629-
/** provide a display for the pairwise structure alignment
630-
*
632+
/**
633+
* Provide a display for the pairwise structure alignment.
631634
*/
632635
private static void showPairDialog(){
633636
AlignmentGui gui = AlignmentGui.getInstance();
634637
gui.setVisible(true);
635638
}
639+
640+
/**
641+
* Provide a display for the multiple structure alignment.
642+
*/
643+
private static void showMultipleDialog(){
644+
MultipleAlignmentGUI gui = MultipleAlignmentGUI.getInstance();
645+
gui.setVisible(true);
646+
}
636647

637648
/**
638649
* Show some info about this GUI
@@ -705,7 +716,7 @@ public void actionPerformed(ActionEvent e) {
705716
String cmd = e.getActionCommand();
706717

707718
if ( cmd.equals(MULTIPLE_ALIGN)){
708-
MenuCreator.showPairDialog();
719+
MenuCreator.showMultipleDialog();
709720
}
710721
}
711722
});
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
/*
2+
* BioJava development code
3+
*
4+
* This code may be freely distributed and modified under the
5+
* terms of the GNU Lesser General Public Licence. This should
6+
* be distributed with the code. If you do not have a copy,
7+
* see:
8+
*
9+
* http://www.gnu.org/copyleft/lesser.html
10+
*
11+
* Copyright for this code is held jointly by the individual
12+
* authors. These should be listed in @author doc comments.
13+
*
14+
* For more information on the BioJava project and its aims,
15+
* or to join the biojava-l mailing list, visit the home page
16+
* at:
17+
*
18+
* http://www.biojava.org/
19+
*
20+
* Created on Jul 16, 2006
21+
*
22+
*/
23+
package org.biojava.nbio.structure.align.gui;
24+
25+
import java.util.ArrayList;
26+
import java.util.List;
27+
28+
import org.biojava.nbio.structure.Atom;
29+
import org.biojava.nbio.structure.Structure;
30+
import org.biojava.nbio.structure.StructureException;
31+
import org.biojava.nbio.structure.StructureTools;
32+
import org.biojava.nbio.structure.align.MultipleStructureAligner;
33+
import org.biojava.nbio.structure.align.multiple.MultipleAlignment;
34+
import org.slf4j.Logger;
35+
import org.slf4j.LoggerFactory;
36+
37+
/**
38+
* A class that obtains structures via DAS and aligns them.
39+
* This is done in a separate thread.
40+
* It is possible to register Event listeners to get notification of when
41+
* the download has finished.
42+
*
43+
* @author Aleix Lafita
44+
* @since 4.1.1
45+
*
46+
*/
47+
public class MultipleAlignmentCalc implements AlignmentCalculationRunnable {
48+
49+
private static final Logger logger =
50+
LoggerFactory.getLogger(MultipleAlignmentCalc.class);
51+
52+
private boolean interrupted = false;
53+
private List<String> names;
54+
private List<Structure> structures;
55+
56+
private MultipleAlignmentGUI parent;
57+
58+
/**
59+
* Requests an alignment of the pdbs.
60+
* If they are empty strings, they are ignored.
61+
*
62+
* @param parent the gui frame that interacts with this class
63+
* @param structures
64+
* @param names
65+
*/
66+
public MultipleAlignmentCalc(MultipleAlignmentGUI parent,
67+
List<Structure> structures, List<String> names) {
68+
69+
this.parent= parent;
70+
this.structures = structures;
71+
this.names = names;
72+
}
73+
74+
@Override
75+
public void run() {
76+
77+
MultipleStructureAligner algorithm =
78+
parent.getMultipleStructureAligner();
79+
try {
80+
81+
List<Atom[]> atomArrays = new ArrayList<Atom[]>();
82+
for (Structure s:structures){
83+
Atom[] ca = StructureTools.getRepresentativeAtomArray(s);
84+
atomArrays.add(ca);
85+
}
86+
87+
MultipleAlignment msa = algorithm.align(atomArrays);
88+
msa.getEnsemble().setStructureNames(names);
89+
90+
MultipleAlignmentDisplay.display(msa);
91+
92+
} catch (StructureException e) {
93+
e.printStackTrace();
94+
logger.warn(e.getMessage());
95+
}
96+
97+
parent.notifyCalcFinished();
98+
}
99+
100+
@Override
101+
public void interrupt() {
102+
interrupted = true;
103+
}
104+
105+
@Override
106+
public void cleanup() {
107+
108+
parent.notifyCalcFinished();
109+
parent=null;
110+
structures = null;
111+
names = null;
112+
}
113+
114+
@Override
115+
public void setNrCPUs(int useNrCPUs) {
116+
// TODO Auto-generated method stub
117+
}
118+
}

0 commit comments

Comments
 (0)