Skip to content

Commit 1ee85f7

Browse files
committed
Static methods for Jmol display methods, for consistency
1 parent c58b7fb commit 1ee85f7

4 files changed

Lines changed: 75 additions & 157 deletions

File tree

Lines changed: 9 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,128 +1,27 @@
11
package demo;
22

33
import java.io.IOException;
4-
import java.util.ArrayList;
5-
import java.util.Arrays;
6-
import java.util.List;
7-
8-
import org.biojava.nbio.structure.Atom;
94
import org.biojava.nbio.structure.StructureException;
105
import org.biojava.nbio.structure.align.gui.MultipleAlignmentDisplay;
11-
import org.biojava.nbio.structure.align.multiple.Block;
12-
import org.biojava.nbio.structure.align.multiple.BlockImpl;
13-
import org.biojava.nbio.structure.align.multiple.BlockSet;
14-
import org.biojava.nbio.structure.align.multiple.BlockSetImpl;
156
import org.biojava.nbio.structure.align.multiple.MultipleAlignment;
16-
import org.biojava.nbio.structure.align.multiple.MultipleAlignmentEnsemble;
17-
import org.biojava.nbio.structure.align.multiple.MultipleAlignmentEnsembleImpl;
18-
import org.biojava.nbio.structure.align.multiple.MultipleAlignmentImpl;
19-
import org.biojava.nbio.structure.align.multiple.MultipleAlignmentScorer;
20-
import org.biojava.nbio.structure.align.multiple.MultipleSuperimposer;
21-
import org.biojava.nbio.structure.align.multiple.ReferenceSuperimposer;
22-
import org.biojava.nbio.structure.align.util.AtomCache;
7+
import org.biojava.nbio.structure.align.multiple.TestSampleGenerator;
238

249
/**
25-
* Demo for visualizing the results of a Multiple Alignment, from a sample MultipleAlignment object.
10+
* Demo for visualizing the results of a Multiple Alignment,
11+
* from a sample MultipleAlignment object.
2612
*
2713
* @author Aleix Lafita
2814
*
2915
*/
3016
public class DemoMultipleAlignmentJmol {
3117

32-
public static void main(String[] args) throws IOException, StructureException {
33-
34-
//Specify the structures to align
35-
//List<String> names = Arrays.asList("1tim.a", "1vzw", "1nsj", "3tha.a"); //TIM barrels
36-
List<String> names = Arrays.asList("1mbc", "1hlb", "1thb.a", "1ith.a"); //globins
37-
38-
//Load the CA atoms of the structures
39-
AtomCache cache = new AtomCache();
40-
List<Atom[]> atomArrays = new ArrayList<Atom[]>();
41-
for (String name:names) atomArrays.add(cache.getAtoms(name));
42-
43-
//Here the multiple structural alignment algorithm comes in place to generate the alignment object
44-
MultipleAlignment fakeMultAln = fakeMultipleAlignment("globins", atomArrays);
45-
fakeMultAln.getEnsemble().setStructureNames(names);
18+
public static void main(String[] args)
19+
throws StructureException, IOException{
4620

47-
//Generate a pairwise alignment and convert it to a MultipleAlignment
48-
//FatCat fatcat = new FatCat();
49-
//AFPChain afpChain = fatcat.alignRigid(atomArrays.get(0),atomArrays.get(1));
50-
//MultipleAlignmentEnsemble ensemble = new MultipleAlignmentEnsembleImpl(afpChain, atomArrays.get(0),atomArrays.get(1));
51-
//MultipleAlignment pairwise = ensemble.getMultipleAlignments().get(0);
21+
//Obtain a sample MultipleAlignment from the tests
22+
MultipleAlignment msa = TestSampleGenerator.testAlignment2();
5223

53-
MultipleAlignmentDisplay.display(fakeMultAln);
54-
//StructureAlignmentDisplay.display(pairwise);
55-
//For comparison display the original AFP
56-
//StructureAlignmentDisplay.display(afpChain,atomArrays.get(0),atomArrays.get(1));
24+
//Displaying a MultipleAlignment is a one line code
25+
MultipleAlignmentDisplay.display(msa);
5726
}
58-
59-
/**
60-
* Method that constructs a fake MultipleAlignment with two BlockSets, with two and one Blocks respectively. Used to
61-
* test the correctness of the DataStructure. In the future it will be in the Test packages.
62-
* @param family name of the protein family
63-
* @param atomArrays
64-
* @return MultipleAlignment
65-
* @throws StructureException
66-
*/
67-
private static MultipleAlignment fakeMultipleAlignment(String family, List<Atom[]>atomArrays) throws StructureException {
68-
69-
//Initialize the multiple alignment parent ensemble
70-
MultipleAlignmentEnsemble ensemble = new MultipleAlignmentEnsembleImpl();
71-
ensemble.setAtomArrays(atomArrays);
72-
ensemble.setAlgorithmName("fakeAlgorithm");
73-
ensemble.setVersion("1.0");
74-
MultipleAlignment fakeMultAln = new MultipleAlignmentImpl(ensemble);
75-
76-
if (family == "globins"){
77-
78-
BlockSet blockSet1 = new BlockSetImpl(fakeMultAln); //first BlockSet with 2 Blocks
79-
BlockSet blockSet2 = new BlockSetImpl(fakeMultAln); //second BlockSet with 1 Block
80-
81-
Block block1 = new BlockImpl(blockSet1);
82-
block1.setAlignRes(new ArrayList<List<Integer>>());
83-
Block block2 = new BlockImpl(blockSet1);
84-
block2.setAlignRes(new ArrayList<List<Integer>>());
85-
Block block3 = new BlockImpl(blockSet2);
86-
block3.setAlignRes(new ArrayList<List<Integer>>());
87-
88-
//Alignment obtained from MUSTANG multiple alignment (just some of the residues, not the whole alignment)
89-
List<Integer> aligned11 = Arrays.asList(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21);
90-
List<Integer> aligned12 = Arrays.asList(29,30,31,32,33,34,35,36,38);
91-
List<Integer> aligned13 = Arrays.asList(123,124,125,126,127,128,129,130,131,132,133,134);
92-
93-
List<Integer> aligned21 = Arrays.asList(10,11,12,13,null,15,16,17,null,19,20,21,22,23,24,25,null,27,28,29,30,null);
94-
List<Integer> aligned22 = Arrays.asList(39,40,41,42,43,44,45,46,48);
95-
List<Integer> aligned23 = Arrays.asList(133,134,135,136,137,138,139,140,141,142,143,144);
96-
97-
List<Integer> aligned31 = Arrays.asList(0,1,2,3,null,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21);
98-
List<Integer> aligned32 = Arrays.asList(29,30,31,32,33,34,35,36,38);
99-
List<Integer> aligned33 = Arrays.asList(117,118,119,120,121,122,123,124,125,126,127,128);
100-
101-
List<Integer> aligned41 = Arrays.asList(0,1,2,3,null,5,6,7,8,9,10,11,12,13,14,15,null,17,18,19,20,21);
102-
List<Integer> aligned42 = Arrays.asList(30,31,32,33,34,35,36,37,39);
103-
List<Integer> aligned43 = Arrays.asList(121,122,123,124,125,126,127,128,129,130,131,132);
104-
105-
block1.getAlignRes().add(aligned11);
106-
block1.getAlignRes().add(aligned21);
107-
block1.getAlignRes().add(aligned31);
108-
block1.getAlignRes().add(aligned41);
109-
110-
block2.getAlignRes().add(aligned12);
111-
block2.getAlignRes().add(aligned22);
112-
block2.getAlignRes().add(aligned32);
113-
block2.getAlignRes().add(aligned42);
114-
115-
block3.getAlignRes().add(aligned13);
116-
block3.getAlignRes().add(aligned23);
117-
block3.getAlignRes().add(aligned33);
118-
block3.getAlignRes().add(aligned43);
119-
120-
//Calculating all information in the alignment is as easy as that line, once the residue equivalencies are set
121-
MultipleSuperimposer imposer = new ReferenceSuperimposer();
122-
imposer.superimpose(fakeMultAln);
123-
MultipleAlignmentScorer.calculateScores(fakeMultAln);
124-
}
125-
return fakeMultAln;
126-
}
127-
12827
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ else if (pos < ca.length) {
7878
* @param colors
7979
* @throws StructureException
8080
*/
81-
public static void showMultipleAligmentPanel(MultipleAlignment multAln, AbstractAlignmentJmol jmol, ColorBrewer colorPattelete) throws StructureException {
81+
public static void showMultipleAligmentPanel(MultipleAlignment multAln, AbstractAlignmentJmol jmol) throws StructureException {
8282

8383
MultipleAligPanel me = new MultipleAligPanel(multAln, jmol);
8484
JFrame frame = new JFrame();

0 commit comments

Comments
 (0)