Skip to content

Commit 3310e09

Browse files
committed
Add one more method to enable the creation of aminoacidtable without explicit specification of elementmass.xml
improved the cookbook tester to use the newly added method and combined shortexample 4 with 5 git-svn-id: http://code.open-bio.org/repos/biojava/biojava-live/trunk@9027 7c6358e6-4a41-0410-a743-a5b2a554c398
1 parent 124967e commit 3310e09

5 files changed

Lines changed: 96 additions & 14 deletions

File tree

biojava3-aa-prop/src/main/java/org/biojava3/aaproperties/IPeptideProperties.java

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,25 @@
3434

3535
/**
3636
* TODO
37-
* 4) Write tutorials for BioJava - Cookbook BioJava Wiki -> ProteinStructure
3837
* 5) Make the xml file more restrictive.
3938
* 6) Simplify the MW.xml and give a isotope example.
39+
* 7) combine 4 and 5 and change into ".. Composition of Peptides.. "
40+
* 9) Check spellings especially physico-chemical properties
41+
* 13) Definition of the xml in the cook book
42+
* 2) How to write the formulae for Net Charge where there are summation and power. Likewise for Instability index - Use images if not possible
43+
* 12) Write an email to in bio-javalist after solving all the above
44+
*
45+
* Meetings
46+
* Wednesday 6 July
47+
* Tuesday 12 July
48+
* Thursday 21 July
4049
*
4150
* DONE
42-
* 9) Next week to be on wednesday
51+
* 10) Add one more method to improve the reading of amino acid table
52+
* 11) Improve the CookbookTester
4353
*
4454
* Question
45-
* 1) Where should the method auto locate the elementMass file
46-
* 2) How to write the formulae for Net Charge where there are summation and power. Likewise for Instability index
55+
*
4756
*
4857
*
4958
*
@@ -131,6 +140,21 @@ public interface IPeptideProperties{
131140
*/
132141
public double getMolecularWeightBasedOnXML(ProteinSequence sequence, AminoAcidCompositionTable aminoAcidCompositionTable) throws Exception;
133142

143+
/**
144+
* This method would initialize amino acid composition table based on the input xml files and stores the table for usage in future calls to
145+
* IPeptideProperties.getMolecularWeightBasedOnXML(ProteinSequence, AminoAcidCompositionTable).
146+
* Note that ElementMass.xml is assumed to be able to be seen in default location.
147+
*
148+
* @param aminoAcidCompositionFile
149+
* xml file that details the composition of amino acids
150+
* @return the initialized amino acid composition table
151+
* @throws JAXBException
152+
* thrown if unable to properly parse either elementMassFile or aminoAcidCompositionFile
153+
* @throws FileNotFoundException
154+
* thrown if either elementMassFile or aminoAcidCompositionFile are not found
155+
*/
156+
public AminoAcidCompositionTable obtainAminoAcidCompositionTable(File aminoAcidCompositionFile) throws JAXBException, FileNotFoundException;
157+
134158
/**
135159
* This method would initialize amino acid composition table based on the input xml files and stores the table for usage in future calls to
136160
* IPeptideProperties.getMolecularWeightBasedOnXML(ProteinSequence, AminoAcidCompositionTable).

biojava3-aa-prop/src/main/java/org/biojava3/aaproperties/PeptideProperties.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,24 @@ public static final double getMolecularWeight(String sequence, File aminoAcidCom
9999
return pp.getMolecularWeight(pSequence, aminoAcidCompositionFile);
100100
}
101101

102+
/**
103+
* An adaptor method would initialize amino acid composition table based on the input xml files and stores the table for usage in future calls to
104+
* IPeptideProperties.getMolecularWeightBasedOnXML(ProteinSequence, AminoAcidCompositionTable).
105+
* Note that ElementMass.xml is assumed to be able to be seen in default location.
106+
*
107+
* @param aminoAcidCompositionFile
108+
* xml file that details the composition of amino acids
109+
* @return the initialized amino acid composition table
110+
* @throws JAXBException
111+
* thrown if unable to properly parse either elementMassFile or aminoAcidCompositionFile
112+
* @throws FileNotFoundException
113+
* thrown if either elementMassFile or aminoAcidCompositionFile are not found
114+
*/
115+
public static final AminoAcidCompositionTable obtainAminoAcidCompositionTable(File aminoAcidCompositionFile) throws JAXBException, FileNotFoundException{
116+
IPeptideProperties pp = new PeptidePropertiesImpl();
117+
return pp.obtainAminoAcidCompositionTable(aminoAcidCompositionFile);
118+
}
119+
102120
/**
103121
* An adaptor method would initialize amino acid composition table based on the input xml files and stores the table for usage in future calls to
104122
* IPeptideProperties.getMolecularWeightBasedOnXML(ProteinSequence, AminoAcidCompositionTable).

biojava3-aa-prop/src/main/java/org/biojava3/aaproperties/PeptidePropertiesImpl.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,33 @@ public double getMolecularWeightBasedOnXML(ProteinSequence sequence, AminoAcidCo
132132
return value;
133133
}
134134

135+
@Override
136+
public AminoAcidCompositionTable obtainAminoAcidCompositionTable(File aminoAcidCompositionFile) throws JAXBException, FileNotFoundException{
137+
File elementMassFile = new File("./src/main/resources/ElementMass.xml");
138+
if(elementMassFile.exists() == false){
139+
throw new FileNotFoundException("Cannot locate ElementMass.xml. " +
140+
"Please use getMolecularWeight(ProteinSequence, File, File) to specify ElementMass.xml location.");
141+
}
142+
//Parse elementMassFile
143+
ElementTable iTable = new ElementTable();
144+
// Get a JAXB Context for the object we created above
145+
JAXBContext jc = JAXBContext.newInstance(iTable.getClass());
146+
Unmarshaller u = jc.createUnmarshaller();
147+
u.setEventHandler(new MyValidationEventHandler());
148+
iTable = (ElementTable)u.unmarshal(new FileInputStream(elementMassFile));
149+
iTable.populateMaps();
150+
151+
//Parse aminoAcidCompositionFile
152+
AminoAcidCompositionTable aTable = new AminoAcidCompositionTable();
153+
// Get a JAXB Context for the object we created above
154+
JAXBContext jc2 = JAXBContext.newInstance(aTable.getClass());
155+
Unmarshaller u2 = jc2.createUnmarshaller();
156+
u2.setEventHandler(new MyValidationEventHandler());
157+
aTable = (AminoAcidCompositionTable)u2.unmarshal(new FileInputStream(aminoAcidCompositionFile));
158+
aTable.computeMolecularWeight(iTable);
159+
return aTable;
160+
}
161+
135162
@Override
136163
public AminoAcidCompositionTable obtainAminoAcidCompositionTable(File elementMassFile, File aminoAcidCompositionFile) throws JAXBException, FileNotFoundException{
137164
//Parse elementMassFile

biojava3-aa-prop/src/main/java/org/biojava3/aaproperties/xml/AminoAcidComposition.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class AminoAcidComposition {
3535
/**
3636
* Stores the name of the element and the amount this amino acid contains
3737
*/
38+
3839
private Map<String, Integer> elementName2Count;
3940
/**
4041
* Stores the name of the isotope and the amount this amino acid contains

biojava3-aa-prop/src/test/java/org/biojava3/aaproperties/xml/CookBookTester.java

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ public void shortExample1(){
1919
@Test
2020
public void shortExample2() throws FileNotFoundException, JAXBException{
2121
String sequence = "QIKDLLVSSSTDLDTTLVLVNAIYFKGMWKTAFNAEDTREMPFHVTKQESKPVQMMCMNNSFNVATLPAE";
22-
File elementMassFile = new File("./src/main/resources/ElementMass.xml");
2322
File aminoAcidCompositionFile = new File("./src/main/resources/AminoAcidComposition.xml");
24-
System.out.println("Molecular Weight: " + PeptideProperties.getMolecularWeight(sequence, elementMassFile, aminoAcidCompositionFile));
23+
System.out.println("Molecular Weight: " + PeptideProperties.getMolecularWeight(sequence, aminoAcidCompositionFile));
2524
}
2625

2726
@Test
@@ -31,9 +30,8 @@ public void shortExample3() throws Exception{
3130
sequences[1] = "KMKILELPFASGDLSMLVLLPDEVSDLERIEKTINFEKLTEWTNPNTMEKRRVKVYLPQMKIEEKYNLTS";
3231
sequences[2] = "VLMALGMTDLFIPSANLTGISSAESLKISQAVHGAFMELSEDGIEMAGSTGVIEDIKHSPESEQFRADHP";
3332

34-
File elementMassFile = new File("./src/main/resources/ElementMass.xml");
3533
File aminoAcidCompositionFile = new File("./src/main/resources/AminoAcidComposition.xml");
36-
AminoAcidCompositionTable table = PeptideProperties.obtainAminoAcidCompositionTable(elementMassFile, aminoAcidCompositionFile);
34+
AminoAcidCompositionTable table = PeptideProperties.obtainAminoAcidCompositionTable(aminoAcidCompositionFile);
3735

3836
for(String sequence:sequences){
3937
System.out.println("Molecular Weight: " + PeptideProperties.getMolecularWeightBasedOnXML(sequence, table));
@@ -43,29 +41,43 @@ public void shortExample3() throws Exception{
4341
@Test
4442
public void shortExample4(){
4543
String sequence = "QIKDLLVSSSTDLDTTLVLVNAIYFKGMWKTAFNAEDTREMPFHVTKQESKPVQMMCMNNSFNVATLPAE";
44+
45+
//Enrichment of a specific amino acid type
4646
System.out.println("Composition of A: " + PeptideProperties.getEnrichment(sequence, "A"));
47-
}
48-
49-
@Test
50-
public void shortExample5(){
51-
String sequence = "QIKDLLVSSSTDLDTTLVLVNAIYFKGMWKTAFNAEDTREMPFHVTKQESKPVQMMCMNNSFNVATLPAE";
47+
48+
//Enrichment of a list of amino acid types
5249
Map<String, Double> composition = PeptideProperties.getAACompositionString(sequence);
5350
for(String aa:composition.keySet()){
5451
System.out.println("Composition of " + aa + ": " + composition.get(aa));
5552
}
5653
}
5754

55+
5856
@Test
59-
public void shortExample6(){
57+
public void shortExample5(){
6058
String sequence = "QIKDLLVSSSTDLDTTLVLVNAIYFKGMWKTAFNAEDTRECMPFHVTKQESKPVQMMCMNNSFNVATLPAE";
59+
60+
//Absorbance
6161
System.out.println("Absorbance (Cys Reduced): " + PeptideProperties.getAbsorbance(sequence, true));
6262
System.out.println("Absorbance (Cys Not Reduced): " + PeptideProperties.getAbsorbance(sequence, false));
63+
64+
//Extinction Coefficient
6365
System.out.println("Extinction Coefficient (Cys Reduced): " + PeptideProperties.getExtinctionCoefficient(sequence, true));
6466
System.out.println("Extinction Coefficient (Cys Not Reduced): " + PeptideProperties.getExtinctionCoefficient(sequence, false));
67+
68+
//Instability Index
6569
System.out.println("Instability Index: " + PeptideProperties.getInstabilityIndex(sequence));
70+
71+
//Apliphatic Index
6672
System.out.println("Apliphatic Index: " + PeptideProperties.getApliphaticIndex(sequence));
73+
74+
//Average Hydropathy Value
6775
System.out.println("Average Hydropathy Value: " + PeptideProperties.getAvgHydropathy(sequence));
76+
77+
//Isoelectric Point
6878
System.out.println("Isoelectric Point: " + PeptideProperties.getIsoelectricPoint(sequence));
79+
80+
//Net Charge
6981
System.out.println("Net Charge at pH 7: " + PeptideProperties.getNetCharge(sequence));
7082
}
7183
}

0 commit comments

Comments
 (0)