lineData) {
- StructNcsOper sNcsOper = new StructNcsOper();
-
- int id = Integer.parseInt(lineData.get(loopFields.indexOf("id")));
- sNcsOper.setId(id);
- sNcsOper.setCode(lineData.get(loopFields.indexOf("code")));
-
- int detailsPos = loopFields.indexOf("details");
- if ( detailsPos > -1)
- sNcsOper.setDetails(lineData.get(detailsPos));
- Matrix4d op = new Matrix4d();
- op.setElement(3, 0, 0.0);
- op.setElement(3, 1, 0.0);
- op.setElement(3, 2, 0.0);
- op.setElement(3, 3, 1.0);
-
-
- for (int i = 1 ; i <=3 ; i++){
- for (int j =1 ; j <= 3 ; j++){
- String max = String.format("matrix[%d][%d]",i,j);
- String val = lineData.get(loopFields.indexOf(max));
- Double d = Double.parseDouble(val);
- op.setElement(i-1,j-1,d);
-
- }
- }
-
-
- for ( int i = 1; i <=3 ; i++){
- String v = String.format("vector[%d]",i);
- String val = lineData.get(loopFields.indexOf(v));
- Double d = Double.parseDouble(val);
- op.setElement(i-1, 3, d);
- }
-
- sNcsOper.setOperator(op);
-
- return sNcsOper;
- }
-
public void triggerNewStructNcsOper(StructNcsOper sNcsOper) {
for(MMcifConsumer c : consumers){
c.newStructNcsOper(sNcsOper);
@@ -939,6 +893,23 @@ public void triggerNewStructNcsOper(StructNcsOper sNcsOper) {
}
+ /**
+ * Populates a bean object from the {@link org.biojava.nbio.structure.io.mmcif.model} package,
+ * from the data read from a CIF file.
+ * It uses reflection to lookup the field and setter method names given the category
+ * found in the CIF file.
+ *
+ * Due to limitations in variable names in java, not all fields can have names
+ * exactly as defined in the CIF categories. In those cases the {@link CIFLabel} tag
+ * can be used in the field names to give the appropriate name that corresponds to the
+ * CIF category, which is the name that will be then looked up here.
+ * The {@link IgnoreField} tag can also be used to exclude fields from being looked up.
+ * @param className
+ * @param loopFields
+ * @param lineData
+ * @param warnings
+ * @return
+ */
private Object buildObject(String className, List loopFields, List lineData, Set warnings) {
Object o = null;
@@ -950,17 +921,16 @@ private Object buildObject(String className, List loopFields, List methodMap = new HashMap();
@@ -968,68 +938,84 @@ private Object buildObject(String className, List loopFields, List names2fields = new HashMap<>();
+ for (int i=0;i[] pType = m.getParameterTypes();
+ Class>[] pType = setter.getParameterTypes();
+
try {
if ( pType[0].getName().equals(Integer.class.getName())) {
if ( val != null && ! val.equals("?") && !val.equals(".")) {
Integer intVal = Integer.parseInt(val);
- m.invoke(o, intVal);
+ setter.invoke(o, intVal);
+
}
} else {
- // default val is a String
- m.invoke(o, val);
+ // default val is a String
+ setter.invoke(o, val);
}
- } catch (IllegalAccessException e) {
- logger.error("Could not invoke setter {} with value {} for class {}", methodName, val, className);
- } catch (InvocationTargetException e) {
- logger.error("Could not invoke setter {} with value {} for class {}", methodName, val, className);
- }
+ } catch (IllegalAccessException|InvocationTargetException e) {
+ logger.error("Could not invoke setter {} with value {} for class {}", setterMethodName, val, className);
+ }
}
return o;
}
+
+ private void produceWarning(String key, String val, Class> c, Set warnings) {
+
+ String warning = "Trying to set field " + key + " in "+ c.getName() +" found in file, but no corresponding field could be found in model class (value:" + val + ")";
+ String warnkey = key+"-"+c.getName();
+ // Suppress duplicate warnings or attempts to store empty data
+ if( val.equals("?") || val.equals(".") || ( warnings != null && warnings.contains(warnkey)) ) {
+ logger.debug(warning);
+ } else {
+ logger.warn(warning);
+ }
+
+ if(warnings != null) {
+ warnings.add(warnkey);
+ }
+
+ }
public void triggerGeneric(String category, List loopFields, List lineData){
for(MMcifConsumer c : consumers){
diff --git a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/model/CIFLabel.java b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/model/CIFLabel.java
new file mode 100644
index 0000000000..54e501eec1
--- /dev/null
+++ b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/model/CIFLabel.java
@@ -0,0 +1,18 @@
+package org.biojava.nbio.structure.io.mmcif.model;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation indicating that a specific field of a bean should be mapped to
+ * a different label
+ * @author Spencer Bliven
+ *
+ */
+@Target(value=ElementType.FIELD)
+@Retention(value=RetentionPolicy.RUNTIME)
+public @interface CIFLabel {
+ String label();
+}
diff --git a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/model/Cell.java b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/model/Cell.java
index c1bdf81cc9..21fdc56ea1 100644
--- a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/model/Cell.java
+++ b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/model/Cell.java
@@ -39,6 +39,8 @@ public class Cell extends AbstractBean {
String angle_alpha_esd;
String angle_beta_esd;
String angle_gamma_esd;
+
+ String volume;
public String getEntry_id() {
return entry_id;
@@ -130,6 +132,12 @@ public String getAngle_gamma_esd() {
public void setAngle_gamma_esd(String angle_gamma_esd) {
this.angle_gamma_esd = angle_gamma_esd;
}
+ public String getVolume() {
+ return volume;
+ }
+ public void setVolume(String volume) {
+ this.volume = volume;
+ }
}
diff --git a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/model/ChemComp.java b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/model/ChemComp.java
index 90d005dee6..cb38de1755 100644
--- a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/model/ChemComp.java
+++ b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/model/ChemComp.java
@@ -66,13 +66,19 @@ public class ChemComp implements Serializable, Comparable{
private String pdbx_processing_site;
private String mon_nstd_flag;
+ @IgnoreField
private List descriptors = new ArrayList();
+ @IgnoreField
private List bonds = new ArrayList();
+ @IgnoreField
private List atoms = new ArrayList();
// and some derived data for easier processing...
+ @IgnoreField
private ResidueType residueType;
+ @IgnoreField
private PolymerType polymerType;
+ @IgnoreField
private boolean standard;
@Override
diff --git a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/model/IgnoreField.java b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/model/IgnoreField.java
new file mode 100644
index 0000000000..ddb05de0de
--- /dev/null
+++ b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/model/IgnoreField.java
@@ -0,0 +1,17 @@
+package org.biojava.nbio.structure.io.mmcif.model;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation indicating that a specific field of a bean should be ignored
+ * @author Spencer Bliven
+ *
+ */
+@Target(value=ElementType.FIELD)
+@Retention(value=RetentionPolicy.RUNTIME)
+public @interface IgnoreField {
+
+}
diff --git a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/model/PdbxStructOperList.java b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/model/PdbxStructOperList.java
index 5fc6d92f43..34effb0657 100644
--- a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/model/PdbxStructOperList.java
+++ b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/model/PdbxStructOperList.java
@@ -30,12 +30,31 @@
import java.io.Serializable;
import java.util.Arrays;
+/**
+ * The bean for pdbx_struct_oper_list category
+ *
+ * _pdbx_struct_oper_list.id
+ * _pdbx_struct_oper_list.type
+ * _pdbx_struct_oper_list.symmetry_operation
+ * _pdbx_struct_oper_list.matrix[1][1]
+ * _pdbx_struct_oper_list.matrix[1][2]
+ * _pdbx_struct_oper_list.matrix[1][3]
+ * _pdbx_struct_oper_list.vector[1]
+ * _pdbx_struct_oper_list.matrix[2][1]
+ * _pdbx_struct_oper_list.matrix[2][2]
+ * _pdbx_struct_oper_list.matrix[2][3]
+ * _pdbx_struct_oper_list.vector[2]
+ * _pdbx_struct_oper_list.matrix[3][1]
+ * _pdbx_struct_oper_list.matrix[3][2]
+ * _pdbx_struct_oper_list.matrix[3][3]
+ * _pdbx_struct_oper_list.vector[3]
+ * _pdbx_struct_oper_list.name
+ *
+ */
@XmlAccessorType(XmlAccessType.PROPERTY)
public class PdbxStructOperList implements Serializable{
- /**
- *
- */
+
private static final long serialVersionUID = 8933552854747969787L;
@Override
@@ -48,14 +67,53 @@ public String toString() {
private String id;
private String type;
-
+
+ private String symmetry_operation;
+
+ @CIFLabel(label="matrix[1][1]")
+ String matrix11;
+ @CIFLabel(label="matrix[1][2]")
+ String matrix12;
+ @CIFLabel(label="matrix[1][3]")
+ String matrix13;
+
+ @CIFLabel(label="vector[1]")
+ String vector1;
+
+ @CIFLabel(label="matrix[2][1]")
+ String matrix21;
+ @CIFLabel(label="matrix[2][2]")
+ String matrix22;
+ @CIFLabel(label="matrix[2][3]")
+ String matrix23;
+
+ @CIFLabel(label="vector[2]")
+ String vector2;
+
+ @CIFLabel(label="matrix[3][1]")
+ String matrix31;
+ @CIFLabel(label="matrix[3][2]")
+ String matrix32;
+ @CIFLabel(label="matrix[3][3]")
+ String matrix33;
+
+ @CIFLabel(label="vector[3]")
+ String vector3;
+
+ String name;
+
+
+ // from here fields that are not in the cif category
+
+ @IgnoreField
private Matrix matrix;
-
+ @IgnoreField
private double[] vector;
public PdbxStructOperList(){
matrix = Matrix.identity(3,3);
+ vector = new double[3];
}
@XmlAttribute
@@ -91,35 +149,66 @@ public void setId(String id) {
this.id = id;
}
- public void setMatrix11(double val){
- matrix.set(0,0,val);
+ public void setMatrix11(String val){
+ matrix.set(0,0,Double.parseDouble(val));
}
- public void setMatrix21(double val){
- matrix.set(1,0,val);
+ public void setMatrix21(String val){
+ matrix.set(1,0,Double.parseDouble(val));
}
- public void setMatrix31(double val){
- matrix.set(2,0,val);
+ public void setMatrix31(String val){
+ matrix.set(2,0,Double.parseDouble(val));
}
- public void setMatrix12(double val){
- matrix.set(0,1,val);
+ public void setMatrix12(String val){
+ matrix.set(0,1,Double.parseDouble(val));
+ }
+ public void setMatrix22(String val){
+ matrix.set(1,1,Double.parseDouble(val));
}
- public void setMatrix22(double val){
- matrix.set(1,1,val);
+ public void setMatrix32(String val){
+ matrix.set(2,1,Double.parseDouble(val));
}
- public void setMatrix32(double val){
- matrix.set(2,1,val);
+ public void setMatrix13(String val){
+ matrix.set(0,2,Double.parseDouble(val));
}
- public void setMatrix13(double val){
- matrix.set(0,2,val);
+ public void setMatrix23(String val){
+ matrix.set(1,2,Double.parseDouble(val));
}
- public void setMatrix23(double val){
- matrix.set(1,2,val);
+ public void setMatrix33(String val){
+ matrix.set(2,2,Double.parseDouble(val));
}
- public void setMatrix33(double val){
- matrix.set(2,2,val);
+
+ public void setName(String name) {
+ this.name = name;
}
+ public String getVector1() {
+ return vector1;
+ }
+ public void setVector1(String vector1) {
+ vector[0] = Double.parseDouble(vector1);
+ }
+ public String getVector2() {
+ return vector2;
+ }
+ public void setVector2(String vector2) {
+ vector[1] = Double.parseDouble(vector2);
+ }
+ public String getVector3() {
+ return vector3;
+ }
+ public void setVector3(String vector3) {
+ vector[2] = Double.parseDouble(vector3);
+ }
+ public String getName() {
+ return name;
+ }
+ public String getSymmetry_operation() {
+ return symmetry_operation;
+ }
+ public void setSymmetry_operation(String symmetry_operation) {
+ this.symmetry_operation = symmetry_operation;
+ }
@XmlElement
public double getMatrix11(){
return matrix.get(0,0);
diff --git a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/model/Refine.java b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/model/Refine.java
index 3c7299e542..dceb35b5ac 100644
--- a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/model/Refine.java
+++ b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/model/Refine.java
@@ -45,7 +45,18 @@ public class Refine {
String occupancy_min;
String occupancy_max;
String B_iso_mean;
- String[][] aniso_B;
+ @CIFLabel(label="aniso_B[1][1]")
+ String aniso_B11;
+ @CIFLabel(label="aniso_B[2][2]")
+ String aniso_B22;
+ @CIFLabel(label="aniso_B[3][3]")
+ String aniso_B33;
+ @CIFLabel(label="aniso_B[1][2]")
+ String aniso_B12;
+ @CIFLabel(label="aniso_B[1][3]")
+ String aniso_B13;
+ @CIFLabel(label="aniso_B[2][3]")
+ String aniso_B23;
String solvent_model_details ;
String solvent_model_param_ksol;
String solvent_model_param_bsol;
@@ -87,7 +98,7 @@ public class Refine {
String ls_number_reflns_R_work;
public Refine(){
- aniso_B = new String[3][3];
+ //aniso_B = new String[3][3];
}
public String getEntry_id() {
@@ -284,14 +295,6 @@ public void setB_iso_mean(String b_iso_mean) {
B_iso_mean = b_iso_mean;
}
- public String[][] getAniso_B() {
- return aniso_B;
- }
-
- public void setAniso_B(String[][] aniso_B) {
- this.aniso_B = aniso_B;
- }
-
public String getSolvent_model_details() {
return solvent_model_details;
}
@@ -603,5 +606,53 @@ public void setLs_number_reflns_R_work(String ls_number_reflns_R_work) {
this.ls_number_reflns_R_work = ls_number_reflns_R_work;
}
+ public String getAniso_B11() {
+ return aniso_B11;
+ }
+
+ public void setAniso_B11(String aniso_B11) {
+ this.aniso_B11 = aniso_B11;
+ }
+
+ public String getAniso_B22() {
+ return aniso_B22;
+ }
+
+ public void setAniso_B22(String aniso_B22) {
+ this.aniso_B22 = aniso_B22;
+ }
+
+ public String getAniso_B33() {
+ return aniso_B33;
+ }
+
+ public void setAniso_B33(String aniso_B33) {
+ this.aniso_B33 = aniso_B33;
+ }
+
+ public String getAniso_B12() {
+ return aniso_B12;
+ }
+
+ public void setAniso_B12(String aniso_B12) {
+ this.aniso_B12 = aniso_B12;
+ }
+
+ public String getAniso_B13() {
+ return aniso_B13;
+ }
+
+ public void setAniso_B13(String aniso_B13) {
+ this.aniso_B13 = aniso_B13;
+ }
+
+ public String getAniso_B23() {
+ return aniso_B23;
+ }
+
+ public void setAniso_B23(String aniso_B23) {
+ this.aniso_B23 = aniso_B23;
+ }
+
}
diff --git a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/model/StructNcsOper.java b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/model/StructNcsOper.java
index 55f0cfbdfc..293c9e4d09 100644
--- a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/model/StructNcsOper.java
+++ b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/model/StructNcsOper.java
@@ -20,25 +20,78 @@
*/
package org.biojava.nbio.structure.io.mmcif.model;
-import javax.vecmath.Matrix4d;
/**
* A class containing the _struct_ncs_oper data
- * @author duarte_j
- *
+ *
+ *
+ * _struct_ncs_oper.id
+ * _struct_ncs_oper.code
+ * _struct_ncs_oper.details
+ * _struct_ncs_oper.matrix[1][1]
+ * _struct_ncs_oper.matrix[1][2]
+ * _struct_ncs_oper.matrix[1][3]
+ * _struct_ncs_oper.matrix[2][1]
+ * _struct_ncs_oper.matrix[2][2]
+ * _struct_ncs_oper.matrix[2][3]
+ * _struct_ncs_oper.matrix[3][1]
+ * _struct_ncs_oper.matrix[3][2]
+ * _struct_ncs_oper.matrix[3][3]
+ * _struct_ncs_oper.vector[1]
+ * _struct_ncs_oper.vector[2]
+ * _struct_ncs_oper.vector[3]
+ *
+ *
+ * @author Jose Duarte
*/
public class StructNcsOper extends AbstractBean {
- private int id;
+ private String id;
private String code;
private String details;
- private Matrix4d operator;
-
- public int getId() {
+
+ @CIFLabel(label="matrix[1][1]")
+ private String matrix11;
+
+ @CIFLabel(label="matrix[1][2]")
+ private String matrix12;
+
+ @CIFLabel(label="matrix[1][3]")
+ private String matrix13;
+
+ @CIFLabel(label="matrix[2][1]")
+ private String matrix21;
+
+ @CIFLabel(label="matrix[2][2]")
+ private String matrix22;
+
+ @CIFLabel(label="matrix[2][3]")
+ private String matrix23;
+
+ @CIFLabel(label="matrix[3][1]")
+ private String matrix31;
+
+ @CIFLabel(label="matrix[3][2]")
+ private String matrix32;
+
+ @CIFLabel(label="matrix[3][3]")
+ private String matrix33;
+
+ @CIFLabel(label="vector[1]")
+ private String vector1;
+
+ @CIFLabel(label="vector[2]")
+ private String vector2;
+
+ @CIFLabel(label="vector[3]")
+ private String vector3;
+
+
+ public String getId() {
return id;
}
- public void setId(int id) {
+ public void setId(String id) {
this.id = id;
}
@@ -58,11 +111,172 @@ public void setDetails(String details) {
this.details = details;
}
- public Matrix4d getOperator() {
- return operator;
+ /**
+ * @return the matrix11
+ */
+ public String getMatrix11() {
+ return matrix11;
+ }
+
+ /**
+ * @param matrix11 the matrix11 to set
+ */
+ public void setMatrix11(String matrix11) {
+ this.matrix11 = matrix11;
+ }
+
+ /**
+ * @return the matrix12
+ */
+ public String getMatrix12() {
+ return matrix12;
+ }
+
+ /**
+ * @param matrix12 the matrix12 to set
+ */
+ public void setMatrix12(String matrix12) {
+ this.matrix12 = matrix12;
+ }
+
+ /**
+ * @return the matrix13
+ */
+ public String getMatrix13() {
+ return matrix13;
+ }
+
+ /**
+ * @param matrix13 the matrix13 to set
+ */
+ public void setMatrix13(String matrix13) {
+ this.matrix13 = matrix13;
+ }
+
+ /**
+ * @return the matrix21
+ */
+ public String getMatrix21() {
+ return matrix21;
+ }
+
+ /**
+ * @param matrix21 the matrix21 to set
+ */
+ public void setMatrix21(String matrix21) {
+ this.matrix21 = matrix21;
+ }
+
+ /**
+ * @return the matrix22
+ */
+ public String getMatrix22() {
+ return matrix22;
+ }
+
+ /**
+ * @param matrix22 the matrix22 to set
+ */
+ public void setMatrix22(String matrix22) {
+ this.matrix22 = matrix22;
+ }
+
+ /**
+ * @return the matrix23
+ */
+ public String getMatrix23() {
+ return matrix23;
+ }
+
+ /**
+ * @param matrix23 the matrix23 to set
+ */
+ public void setMatrix23(String matrix23) {
+ this.matrix23 = matrix23;
}
- public void setOperator(Matrix4d operator) {
- this.operator = operator;
+ /**
+ * @return the matrix31
+ */
+ public String getMatrix31() {
+ return matrix31;
}
+
+ /**
+ * @param matrix31 the matrix31 to set
+ */
+ public void setMatrix31(String matrix31) {
+ this.matrix31 = matrix31;
+ }
+
+ /**
+ * @return the matrix32
+ */
+ public String getMatrix32() {
+ return matrix32;
+ }
+
+ /**
+ * @param matrix32 the matrix32 to set
+ */
+ public void setMatrix32(String matrix32) {
+ this.matrix32 = matrix32;
+ }
+
+ /**
+ * @return the matrix33
+ */
+ public String getMatrix33() {
+ return matrix33;
+ }
+
+ /**
+ * @param matrix33 the matrix33 to set
+ */
+ public void setMatrix33(String matrix33) {
+ this.matrix33 = matrix33;
+ }
+
+ /**
+ * @return the vector1
+ */
+ public String getVector1() {
+ return vector1;
+ }
+
+ /**
+ * @param vector1 the vector1 to set
+ */
+ public void setVector1(String vector1) {
+ this.vector1 = vector1;
+ }
+
+ /**
+ * @return the vector2
+ */
+ public String getVector2() {
+ return vector2;
+ }
+
+ /**
+ * @param vector2 the vector2 to set
+ */
+ public void setVector2(String vector2) {
+ this.vector2 = vector2;
+ }
+
+ /**
+ * @return the vector3
+ */
+ public String getVector3() {
+ return vector3;
+ }
+
+ /**
+ * @param vector3 the vector3 to set
+ */
+ public void setVector3(String vector3) {
+ this.vector3 = vector3;
+ }
+
}
diff --git a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/model/Symmetry.java b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/model/Symmetry.java
index 09597aaa05..d91ef11718 100644
--- a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/model/Symmetry.java
+++ b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/model/Symmetry.java
@@ -20,13 +20,13 @@
*/
package org.biojava.nbio.structure.io.mmcif.model;
+
public class Symmetry extends AbstractBean {
String entry_id;
- // next 2 fields have actually hyphen between H and M i.e. H-M
- // but java does not allow hyphens in variable names
- // this will have to be solved elsewhere down the line
+ @CIFLabel(label="space_group_name_H-M")
String space_group_name_H_M;
+ @CIFLabel(label="pdbx_full_space_group_name_H-M")
String pdbx_full_space_group_name_H_M;
String cell_setting;
String Int_Tables_number;
diff --git a/biojava-structure/src/test/java/org/biojava/nbio/structure/io/TestMMCIFWriting.java b/biojava-structure/src/test/java/org/biojava/nbio/structure/io/TestMMCIFWriting.java
index 377297c2e9..5fda97a2af 100644
--- a/biojava-structure/src/test/java/org/biojava/nbio/structure/io/TestMMCIFWriting.java
+++ b/biojava-structure/src/test/java/org/biojava/nbio/structure/io/TestMMCIFWriting.java
@@ -33,9 +33,12 @@
import org.biojava.nbio.structure.StructureException;
import org.biojava.nbio.structure.StructureIO;
import org.biojava.nbio.structure.align.util.AtomCache;
+import org.biojava.nbio.structure.io.mmcif.MMCIFFileTools;
import org.biojava.nbio.structure.io.mmcif.MMcifParser;
import org.biojava.nbio.structure.io.mmcif.SimpleMMcifConsumer;
import org.biojava.nbio.structure.io.mmcif.SimpleMMcifParser;
+import org.biojava.nbio.structure.io.mmcif.model.CIFLabel;
+import org.biojava.nbio.structure.io.mmcif.model.IgnoreField;
import org.junit.Test;
public class TestMMCIFWriting {
@@ -55,7 +58,7 @@ public void test1SMT() throws IOException, StructureException {
Structure originalStruct = StructureIO.getStructure("1SMT");
File outputFile = File.createTempFile("biojava_testing_", ".cif");
-
+ outputFile.deleteOnExit();
FileWriter fw = new FileWriter(outputFile);
fw.write(originalStruct.toMMCIF());
@@ -93,6 +96,8 @@ public void test1SMT() throws IOException, StructureException {
//assertEquals(origChain.getSeqResGroups().size(), readChain.getSeqResGroups().size());
}
+ // Test cell and symmetry
+ assertEquals(originalStruct.getCrystallographicInfo().getSpaceGroup(),readStruct.getCrystallographicInfo().getSpaceGroup());
}
/**
@@ -115,6 +120,7 @@ public void test2N3J() throws IOException, StructureException {
Structure originalStruct = StructureIO.getStructure("2N3J");
File outputFile = File.createTempFile("biojava_testing_", ".cif");
+ outputFile.deleteOnExit();
FileWriter fw = new FileWriter(outputFile);
@@ -179,6 +185,7 @@ public void test1A2C() throws IOException, StructureException {
Structure originalStruct = StructureIO.getStructure("1A2C");
File outputFile = File.createTempFile("biojava_testing_", ".cif");
+ outputFile.deleteOnExit();
FileWriter fw = new FileWriter(outputFile);
@@ -218,5 +225,44 @@ public void test1A2C() throws IOException, StructureException {
}
}
+
+ private static class DemoBean {
+ @IgnoreField
+ String not_a_field;
+
+ @SuppressWarnings("unused")//used by reflection
+ String default_field;
+
+ @CIFLabel(label="custom_label")
+ String custom_field;
+ public void setNot_a_field(String not_a_field) {
+ this.not_a_field = not_a_field;
+ }
+ public void setDefault_field(String default_field) {
+ this.default_field = default_field;
+ }
+ public void setCustom_field(String custom_field) {
+ this.custom_field = custom_field;
+ }
+ }
+
+ @Test
+ public void testBeanAnnotations() {
+ DemoBean bean = new DemoBean();
+ bean.setCustom_field("custom_field");
+ bean.setDefault_field(null);
+ bean.setNot_a_field("not_a_field");
+
+
+ // Test (1) should have custom_label (@CIFLabel)
+ // (2) shouldn't have not_a_field (@IgnoreField)
+ String newline = System.getProperty("line.separator");
+ String mmcif = MMCIFFileTools.toMMCIF("_demo", bean);
+ String expected =
+ "_demo.default_field ?" + newline
+ + "_demo.custom_label custom_field" + newline
+ + "#" + newline;
+ assertEquals(expected, mmcif);
+ }
}
diff --git a/biojava-survival/pom.xml b/biojava-survival/pom.xml
index 3b57f7242f..8d2875b813 100644
--- a/biojava-survival/pom.xml
+++ b/biojava-survival/pom.xml
@@ -4,7 +4,7 @@
org.biojava
biojava
- 4.2.2
+ 4.2.3
biojava-survival
diff --git a/biojava-ws/pom.xml b/biojava-ws/pom.xml
index fb469e0d69..ecc74b660e 100644
--- a/biojava-ws/pom.xml
+++ b/biojava-ws/pom.xml
@@ -3,7 +3,7 @@
biojava
org.biojava
- 4.2.2
+ 4.2.3
biojava-ws
biojava-ws
@@ -19,7 +19,7 @@
org.biojava
biojava-core
- 4.2.2
+ 4.2.3
compile
diff --git a/pom.xml b/pom.xml
index 864b9d9ff4..2b575db99b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -12,7 +12,7 @@
org.biojava
biojava
pom
- 4.2.2
+ 4.2.3
biojava
BioJava is an open-source project dedicated to providing a Java framework for processing biological
data. It provides analytical and statistical routines, parsers for common file formats and allows the
@@ -44,7 +44,7 @@
scm:git:git@github.com:biojava/biojava.git
https://github.com/biojava/biojava
- biojava-4.2.2
+ biojava-4.2.3