Skip to content

Commit 85378c8

Browse files
committed
Merge pull request biojava#278 from sbliven/multaln
Multiple Structure Alignment Datastructures
2 parents b6bb812 + 1c717b6 commit 85378c8

File tree

53 files changed

+6179
-499
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+6179
-499
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public static void main(String[] args){
9191
jmol.setTitle(algorithm.getAlgorithmName() + " : " + name1 + " vs. " + name2);
9292

9393
// here we open up the alignment - text panel that can interact with the 3D jmol display.
94-
DisplayAFP.showAlignmentImage(afpChain, ca1,ca2,jmol);
94+
DisplayAFP.showAlignmentPanel(afpChain, ca1,ca2,jmol);
9595

9696
// we can print an XML version
9797
//System.out.println(AFPChainXMLConverter.toXML(afpChain, ca1, ca2));
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package demo;
2+
3+
import java.io.IOException;
4+
import java.util.Arrays;
5+
import java.util.List;
6+
import java.util.ArrayList;
7+
import java.util.concurrent.ExecutionException;
8+
9+
import org.biojava.nbio.structure.Atom;
10+
import org.biojava.nbio.structure.StructureException;
11+
import org.biojava.nbio.structure.align.cemc.CeMcMain;
12+
import org.biojava.nbio.structure.align.gui.MultipleAlignmentDisplay;
13+
import org.biojava.nbio.structure.align.multiple.MultipleAlignment;
14+
import org.biojava.nbio.structure.align.util.AtomCache;
15+
16+
/**
17+
* Demo for running a CEMC Multiple Structure Alignment and visualizing the results.
18+
*
19+
* @author Aleix Lafita
20+
*
21+
*/
22+
public class DemoCEMC {
23+
24+
public static void main(String[] args) throws IOException, StructureException, InterruptedException, ExecutionException {
25+
26+
//Specify the structures to align
27+
//ASP-proteinases (CEMC paper)
28+
//List<String> names = Arrays.asList("3app", "4ape", "2apr", "5pep", "1psn", "4cms", "1bbs.A", "1smr.A", "2jxr.A", "1mpp", "2asi", "1am5");
29+
//Protein Kinases (CEMC paper)
30+
//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");
31+
//DHFR (Gerstein 1998 paper)
32+
List<String> names = Arrays.asList("d1dhfa_", "8dfr", "d4dfra_", "3dfr");
33+
//TIM barrels (MUSTA paper)
34+
//List<String> names = Arrays.asList("1tim.A", "1vzw", "1nsj", "3tha.A", "4enl", "2mnr", "7tim.A", "1tml", "1btc", "a1piia1", "6xia", "5rub.A", "2taa.B");
35+
//Helix-bundle (MUSTA paper)
36+
//List<String> names = Arrays.asList("1bbh.A", "1aep", "1bge.B", "256b.A", "2ccy.A", "2hmz.A", "3ink.C");
37+
//Calcium Binding (MUSTA paper)
38+
//List<String> names = Arrays.asList("4cpv", "2scp.A", "2sas", "1top", "1scm.B", "3icb");
39+
//Serine Rich Proteins SERP (MUSTA paper)
40+
//List<String> names = Arrays.asList("7api.A", "8api.A", "1hle.A", "1ova.A", "2ach.A", "9api.A", "1psi", "1atu", "1kct", "1ath.A", "1att.A");
41+
//Serine Proteases (MUSTA paper)
42+
//List<String> names = Arrays.asList("1cse.E", "1sbn.E", "1pek.E", "3prk", "3tec.E");
43+
//GPCRs
44+
//List<String> names = Arrays.asList("2z73.A", "1u19.A", "4ug2.A", "4xt3", "4or2.A", "3odu.A");
45+
//Immunoglobulins (MAMMOTH paper)
46+
//List<String> names = Arrays.asList("2hla.B", "3hla.B", "1cd8", "2rhe", "1tlk", "1ten", "1ttf");
47+
//Globins (MAMMOTH and MUSTA papers)
48+
//List<String> names = Arrays.asList("1mbc", "1hlb", "1thb.A", "1ith.A", "1idr.A", "1dlw", "1kr7.A", "1ew6.A", "1it2.A", "1eco", "3sdh.A", "1cg5.B", "1fhj.B", "1ird.A", "1mba", "2gdm", "1b0b", "1h97.A", "1ash.A", "1jl7.A");
49+
//Rossman-Fold (POSA paper)
50+
//List<String> names = Arrays.asList("d1heta2", "d1ek6a_", "d1obfo1", "2cmd", "d1np3a2", "d1bgva1", "d1id1a_", "d1id1a_", "d1oi7a1");
51+
52+
//Load the CA atoms of the structures
53+
AtomCache cache = new AtomCache();
54+
List<Atom[]> atomArrays = new ArrayList<Atom[]>();
55+
for (String name:names) {
56+
atomArrays.add(cache.getAtoms(name));
57+
}
58+
59+
//Here the multiple structural alignment algorithm comes in place to generate the alignment object
60+
CeMcMain algorithm = new CeMcMain();
61+
MultipleAlignment result = algorithm.align(atomArrays);
62+
result.getEnsemble().setStructureNames(names);
63+
64+
//Information about the alignment
65+
result.getEnsemble().setAlgorithmName(algorithm.getAlgorithmName());
66+
result.getEnsemble().setVersion(algorithm.getVersion());
67+
68+
MultipleAlignmentDisplay.display(result);
69+
}
70+
}
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
package demo;
2+
3+
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;
9+
import org.biojava.nbio.structure.StructureException;
10+
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;
15+
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.MultipleAlignmentWriter;
21+
import org.biojava.nbio.structure.align.multiple.MultipleSuperimposer;
22+
import org.biojava.nbio.structure.align.multiple.ReferenceSuperimposer;
23+
import org.biojava.nbio.structure.align.util.AtomCache;
24+
25+
/**
26+
* Demo for visualizing the results of a Multiple Alignment, from a sample MultipleAlignment object.
27+
*
28+
* @author Aleix Lafita
29+
*
30+
*/
31+
public class DemoMultipleAlignmentJmol {
32+
33+
public static void main(String[] args) throws IOException, StructureException {
34+
35+
//Specify the structures to align
36+
//List<String> names = Arrays.asList("1tim.a", "1vzw", "1nsj", "3tha.a"); //TIM barrels
37+
List<String> names = Arrays.asList("1mbc", "1hlb", "1thb.a", "1ith.a"); //globins
38+
39+
//Load the CA atoms of the structures
40+
AtomCache cache = new AtomCache();
41+
List<Atom[]> atomArrays = new ArrayList<Atom[]>();
42+
for (String name:names) atomArrays.add(cache.getAtoms(name));
43+
44+
//Here the multiple structural alignment algorithm comes in place to generate the alignment object
45+
MultipleAlignment fakeMultAln = fakeMultipleAlignment("globins", atomArrays);
46+
fakeMultAln.getEnsemble().setStructureNames(names);
47+
48+
//Generate a pairwise alignment and convert it to a MultipleAlignment
49+
//FatCat fatcat = new FatCat();
50+
//AFPChain afpChain = fatcat.alignRigid(atomArrays.get(0),atomArrays.get(1));
51+
//MultipleAlignmentEnsemble ensemble = new MultipleAlignmentEnsembleImpl(afpChain, atomArrays.get(0),atomArrays.get(1));
52+
//MultipleAlignment pairwise = ensemble.getMultipleAlignments().get(0);
53+
54+
System.out.println(MultipleAlignmentWriter.toFASTA(fakeMultAln));
55+
MultipleAlignmentDisplay.display(fakeMultAln);
56+
//StructureAlignmentDisplay.display(pairwise);
57+
//For comparison display the original AFP
58+
//StructureAlignmentDisplay.display(afpChain,atomArrays.get(0),atomArrays.get(1));
59+
}
60+
61+
/**
62+
* Method that constructs a fake MultipleAlignment with two BlockSets, with two and one Blocks respectively. Used to
63+
* test the correctness of the DataStructure. In the future it will be in the Test packages.
64+
* @param family name of the protein family
65+
* @param atomArrays
66+
* @return MultipleAlignment
67+
* @throws StructureException
68+
* @throws StructureAlignmentException
69+
*/
70+
private static MultipleAlignment fakeMultipleAlignment(String family, List<Atom[]>atomArrays) throws StructureException {
71+
72+
//Initialize the multiple alignment parent ensemble
73+
MultipleAlignmentEnsemble ensemble = new MultipleAlignmentEnsembleImpl();
74+
ensemble.setAtomArrays(atomArrays);
75+
ensemble.setAlgorithmName("fakeAlgorithm");
76+
MultipleAlignment fakeMultAln = new MultipleAlignmentImpl(ensemble);
77+
78+
if (family == "globins"){
79+
80+
BlockSet blockSet1 = new BlockSetImpl(fakeMultAln); //first BlockSet with 2 Blocks
81+
BlockSet blockSet2 = new BlockSetImpl(fakeMultAln); //second BlockSet with 1 Block
82+
83+
Block block1 = new BlockImpl(blockSet1);
84+
Block block2 = new BlockImpl(blockSet1);
85+
86+
Block block3 = new BlockImpl(blockSet2);
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,14,15,16,17,18,19,20,21,22,23,24,25,null,27,28,29,30,31);
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,4,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,4,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+
128+
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,13 @@ public void run() {
106106
title += " " + algorithm.getParameters().toString();
107107
jmol.setTitle(title);
108108

109-
DisplayAFP.showAlignmentImage(afpChain,ca1,ca2,jmol);
109+
DisplayAFP.showAlignmentPanel(afpChain,ca1,ca2,jmol);
110110

111111
System.out.println(afpChain.toCE(ca1,ca2));
112112

113113
} catch (StructureException e){
114114
e.printStackTrace();
115115
logger.warn(e.getMessage());
116-
117116
}
118117

119118

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ private void showAlignment( String name1, String name2){
338338

339339
//String rot = afpChain.toRotMat();
340340

341-
DisplayAFP.showAlignmentImage(afpChain, ca1,ca2,jmol);
341+
DisplayAFP.showAlignmentPanel(afpChain, ca1,ca2,jmol);
342342

343343

344344
} catch (Exception e){

0 commit comments

Comments
 (0)