Skip to content

Commit ab7a992

Browse files
committed
Adjust the XML requirements and made attributes as optional if possible
Checked that all Elements and Isotopes used in AminoAcidComposition.xml can be found in ElementMass.xml git-svn-id: http://code.open-bio.org/repos/biojava/biojava-live/trunk@9030 7c6358e6-4a41-0410-a743-a5b2a554c398
1 parent 3991a22 commit ab7a992

10 files changed

Lines changed: 198 additions & 19 deletions

File tree

biojava3-aa-prop/TODO.TXT

Lines changed: 0 additions & 3 deletions
This file was deleted.

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

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,38 @@
3434

3535
/**
3636
* TODO
37-
* 13) Definition of the xml in the cook book
38-
* 2) How to write the formulae for Net Charge where there are summation and power. Likewise for Instability index - Use images if not possible
37+
*
3938
* 12) Write an email to in bio-javalist after solving all the above
39+
*
40+
*
41+
* 1) The question I have now is - What is the minimal requirements for defining compound? There should be a test case demonstrating them.
42+
*
43+
* Other test cases, and parts of your cookbook should demonstrate how to define
44+
1) Labelled amino acid.
45+
2) Phosphorilated or modified in any other way amino acid.
46+
3) any other compound which is not an amino acid. e.g. Glucose.
47+
4) Any or all of the above in the peptide chain
48+
49+
Calculate molecular weight for all of the above.
50+
Does it all fit well into an XML you have defined for the compound?
51+
52+
53+
54+
One more thing - what is the minimum requirement for defining an element?
55+
Which XML attributes are required and which are optional. You should also describe this in you cookbook, perhaps in a separate section to avoid overcomplicating more common use cases.
56+
57+
I know these are defined in the classes, but the test case and a cookbook entry would be helpful.
58+
4059
*
4160
* Meetings
4261
* Wednesday 6 July
4362
* Wednesday 13 July
4463
* Thursday 21 July
4564
*
4665
* DONE
47-
* Added annotations for AminoAcidComposition.java and Element.java.
48-
* Simplified MolecularWeight.xml and ElementMass.xml.
49-
* Work around and made the XML files annotated to requirements.
50-
* Use Hydrogen-1 isotope weight
66+
* Add CookBook pages on how Net Charge and Instability Index are computed.
67+
* Defined the standard XML files in the CookBook
68+
*
5169
*
5270
* Question
5371
*

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ public class AminoAcidComposition {
1919
/**
2020
* Amino acid short name - three characters
2121
*/
22-
@XmlAttribute(name = "shortname", required = true)
22+
@XmlAttribute(name = "shortname")
2323
private String shortName;
2424
/**
2525
* Amino acid full name
2626
*/
27-
@XmlAttribute(name = "name", required = true)
27+
@XmlAttribute(name = "name")
2828
private String name;
2929
/**
3030
* Stores the name of the element and the amount this amino acid contains

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,21 @@ public void computeMolecularWeight(ElementTable eTable){
4646
if(a.getElementList() != null){
4747
for(Name2Count element:a.getElementList()){
4848
element.getName();
49-
eTable.getElement(element.getName());
49+
if(eTable.getElement(element.getName()) == null){
50+
throw new Error("Element " + element.getName() + " could not be found. " +
51+
"\r\nPlease ensure that its name is correct in AminoAcidComposition.xml and is defined in ElementMass.xml.");
52+
}
5053
eTable.getElement(element.getName()).getMass();
5154
total += eTable.getElement(element.getName()).getMass() * element.getCount();
5255
}
5356
}
5457
if(a.getIsotopeList() != null){
5558
for(Name2Count isotope:a.getIsotopeList()){
5659
isotope.getName();
57-
eTable.getIsotope(isotope.getName());
60+
if(eTable.getIsotope(isotope.getName()) == null){
61+
throw new Error("Isotope " + isotope.getName() + " could not be found. " +
62+
"\r\nPlease ensure that its name is correct in AminoAcidComposition.xml and is defined in ElementMass.xml.");
63+
}
5864
eTable.getIsotope(isotope.getName()).getWeight();
5965
total += eTable.getIsotope(isotope.getName()).getWeight() * isotope.getCount();
6066
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ public class Element {
2525
/**
2626
* Element short name as in periodic table e.g. "H"
2727
*/
28-
@XmlAttribute(name = "symbol", required = true)
28+
@XmlAttribute(name = "symbol")
2929
private String symbol;
3030
/**
3131
* The atomic number of the element = number of protons.
3232
*/
33-
@XmlAttribute(name = "atomicnumber", required = true)
33+
@XmlAttribute(name = "atomicnumber")
3434
private int atomicNumber;
3535
/**
3636
* The computed mass based on isotopes and their abundances

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ public void populateMaps(){
4444
if(this.element != null){
4545
for(Element e:this.element){
4646
this.elementName2Element.put(e.getName(), e);
47-
for(Isotope i:e.getIsotopes()){
48-
this.isotopeName2Isotope.put(i.name(), i);
47+
if(e.getIsotopes() != null){
48+
for(Isotope i:e.getIsotopes()){
49+
this.isotopeName2Isotope.put(i.name(), i);
50+
}
4951
}
5052
}
5153
}

biojava3-aa-prop/src/main/resources/AminoAcidComposition.xsd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
<xs:element name="isotopes" type="name2Count" minOccurs="0" maxOccurs="unbounded"/>
1616
</xs:sequence>
1717
<xs:attribute name="symbol" type="xs:string" use="required"/>
18-
<xs:attribute name="shortname" type="xs:string" use="required"/>
19-
<xs:attribute name="name" type="xs:string" use="required"/>
18+
<xs:attribute name="shortname" type="xs:string"/>
19+
<xs:attribute name="name" type="xs:string"/>
2020
</xs:complexType>
2121

2222
<xs:complexType name="name2Count">
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<ns2:AminoAcidsTable xmlns:ns2="http://biojava.org">
3+
<aminoacid symbol="A">
4+
<elements count="3" name="Carbon"/>
5+
<elements count="1" name="Nitrogen"/>
6+
<elements count="1" name="Oxygen"/>
7+
<isotopes count="5" name="Hydrogen"/>
8+
</aminoacid>
9+
<aminoacid symbol="R">
10+
<elements count="6" name="Carbon"/>
11+
<elements count="4" name="Nitrogen"/>
12+
<elements count="1" name="Oxygen"/>
13+
<isotopes count="12" name="Hydrogen"/>
14+
</aminoacid>
15+
<aminoacid symbol="N">
16+
<elements count="4" name="Carbon"/>
17+
<elements count="2" name="Nitrogen"/>
18+
<elements count="2" name="Oxygen"/>
19+
<isotopes count="6" name="Hydrogen"/>
20+
</aminoacid>
21+
<aminoacid symbol="D">
22+
<elements count="4" name="Carbon"/>
23+
<elements count="1" name="Nitrogen"/>
24+
<elements count="3" name="Oxygen"/>
25+
<isotopes count="5" name="Hydrogen"/>
26+
</aminoacid>
27+
<aminoacid symbol="C">
28+
<elements count="3" name="Carbon"/>
29+
<elements count="1" name="Nitrogen"/>
30+
<elements count="1" name="Oxygen"/>
31+
<elements count="1" name="Sulfur"/>
32+
<isotopes count="5" name="Hydrogen"/>
33+
</aminoacid>
34+
<aminoacid symbol="E">
35+
<elements count="5" name="Carbon"/>
36+
<elements count="1" name="Nitrogen"/>
37+
<elements count="3" name="Oxygen"/>
38+
<isotopes count="7" name="Hydrogen"/>
39+
</aminoacid>
40+
<aminoacid symbol="Q">
41+
<elements count="5" name="Carbon"/>
42+
<elements count="2" name="Nitrogen"/>
43+
<elements count="2" name="Oxygen"/>
44+
<isotopes count="8" name="Hydrogen"/>
45+
</aminoacid>
46+
<aminoacid symbol="G">
47+
<elements count="2" name="Carbon"/>
48+
<elements count="1" name="Nitrogen"/>
49+
<elements count="1" name="Oxygen"/>
50+
<isotopes count="3" name="Hydrogen"/>
51+
</aminoacid>
52+
<aminoacid symbol="H">
53+
<elements count="6" name="Carbon"/>
54+
<elements count="3" name="Nitrogen"/>
55+
<elements count="1" name="Oxygen"/>
56+
<isotopes count="7" name="Hydrogen"/>
57+
</aminoacid>
58+
<aminoacid symbol="I">
59+
<elements count="6" name="Carbon"/>
60+
<elements count="1" name="Nitrogen"/>
61+
<elements count="1" name="Oxygen"/>
62+
<isotopes count="11" name="Hydrogen"/>
63+
</aminoacid>
64+
<aminoacid symbol="L">
65+
<elements count="6" name="Carbon"/>
66+
<elements count="1" name="Nitrogen"/>
67+
<elements count="1" name="Oxygen"/>
68+
<isotopes count="11" name="Hydrogen"/>
69+
</aminoacid>
70+
<aminoacid symbol="K">
71+
<elements count="6" name="Carbon"/>
72+
<elements count="2" name="Nitrogen"/>
73+
<elements count="1" name="Oxygen"/>
74+
<isotopes count="12" name="Hydrogen"/>
75+
</aminoacid>
76+
<aminoacid symbol="M">
77+
<elements count="5" name="Carbon"/>
78+
<elements count="1" name="Nitrogen"/>
79+
<elements count="1" name="Oxygen"/>
80+
<elements count="1" name="Sulfur"/>
81+
<isotopes count="9" name="Hydrogen"/>
82+
</aminoacid>
83+
<aminoacid symbol="F">
84+
<elements count="9" name="Carbon"/>
85+
<elements count="1" name="Nitrogen"/>
86+
<elements count="1" name="Oxygen"/>
87+
<isotopes count="9" name="Hydrogen"/>
88+
</aminoacid>
89+
<aminoacid symbol="P">
90+
<elements count="5" name="Carbon"/>
91+
<elements count="1" name="Nitrogen"/>
92+
<elements count="1" name="Oxygen"/>
93+
<isotopes count="7" name="Hydrogen"/>
94+
</aminoacid>
95+
<aminoacid symbol="S">
96+
<elements count="3" name="Carbon"/>
97+
<elements count="1" name="Nitrogen"/>
98+
<elements count="2" name="Oxygen"/>
99+
<isotopes count="5" name="Hydrogen"/>
100+
</aminoacid>
101+
<aminoacid symbol="T">
102+
<elements count="4" name="Carbon"/>
103+
<elements count="7" name="Hydrogen"/>
104+
<elements count="1" name="Nitrogen"/>
105+
<elements count="2" name="Oxygen"/>
106+
</aminoacid>
107+
<aminoacid symbol="W">
108+
<elements count="11" name="Carbon"/>
109+
<elements count="2" name="Nitrogen"/>
110+
<elements count="1" name="Oxygen"/>
111+
<isotopes count="10" name="Hydrogen"/>
112+
</aminoacid>
113+
<aminoacid symbol="Y">
114+
<elements count="9" name="Carbon"/>
115+
<elements count="1" name="Nitrogen"/>
116+
<elements count="2" name="Oxygen"/>
117+
<isotopes count="9" name="Hydrogen"/>
118+
</aminoacid>
119+
<aminoacid symbol="V">
120+
<elements count="5" name="Carbon"/>
121+
<elements count="1" name="Nitrogen"/>
122+
<elements count="1" name="Oxygen"/>
123+
<isotopes count="9" name="Hydrogen"/>
124+
</aminoacid>
125+
</ns2:AminoAcidsTable>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<ns2:elements xmlns:ns2="http://biojava.org">
3+
<element mass="1.00794" name="Hydrogen">
4+
<isotope weight="1.00782503207" name="Hydrogen"/>
5+
</element>
6+
<element mass="12.0107" name="Carbon"/>
7+
<element mass="14.0067" name="Nitrogen"/>
8+
<element mass="15.9994" name="Oxygen"/>
9+
<element mass="32.065" name="Sulfur"/>
10+
</ns2:elements>

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,27 @@ public void generateSchema() throws JAXBException, IOException{
2323
context.generateSchema(new SchemaGenerator("./src/main/resources/AminoAcidComposition.xsd"));
2424
}
2525

26+
@Test
27+
public void readMinXml() throws JAXBException, IOException{
28+
ElementTable iTable = new ElementTable();
29+
// Get a JAXB Context for the object we created above
30+
JAXBContext jc = JAXBContext.newInstance(iTable.getClass());
31+
Unmarshaller u = jc.createUnmarshaller();
32+
iTable = (ElementTable)u.unmarshal(new FileInputStream("./src/main/resources/MinElementMass.xml" ) );
33+
iTable.populateMaps();
34+
35+
AminoAcidCompositionTable aTable = new AminoAcidCompositionTable();
36+
// Get a JAXB Context for the object we created above
37+
JAXBContext jc2 = JAXBContext.newInstance(aTable.getClass());
38+
Unmarshaller u2 = jc2.createUnmarshaller();
39+
40+
aTable = (AminoAcidCompositionTable)u2.unmarshal(new FileInputStream("./src/main/resources/MinAminoAcidComposition.xml" ) );
41+
aTable.computeMolecularWeight(iTable);
42+
for(AminoAcidComposition a:aTable.getAminoacid()){
43+
System.out.println(a + ", " + aTable.getMolecularWeight(a.getSymbol()));
44+
}
45+
}
46+
2647
@Test
2748
public void readXml() throws JAXBException, IOException{
2849
ElementTable iTable = new ElementTable();

0 commit comments

Comments
 (0)