String line;
while (!(line = br.readLine()).matches("\\s*")) {
try {
// X -C -C -X 4 14.50 180.0 2. Junmei et al, 1999
FortranFormat formatter = new FortranFormat(
"(A2,1X,A2,1X,A2,1X,A2,I4,3F15.2)");
ArrayList<Object> lineObjects = formatter.parse(line);
AtomIdentifier i = AtomIdentifierFactory
.getAtomIdentifier((String) lineObjects.get(0));
AtomIdentifier j = AtomIdentifierFactory
.getAtomIdentifier((String) lineObjects.get(1));
AtomIdentifier k = AtomIdentifierFactory
.getAtomIdentifier((String) lineObjects.get(2));
AtomIdentifier l = AtomIdentifierFactory
.getAtomIdentifier((String) lineObjects.get(3));
if (!atomTypes.contains(i)) {
throw new RuntimeException("Unknown atom type " + i);
}
if (!atomTypes.contains(j)) {
throw new RuntimeException("Unknown atom type " + j);
}
if (!atomTypes.contains(k)) {
throw new RuntimeException("Unknown atom type " + k);
}
if (!atomTypes.contains(l)) {
throw new RuntimeException("Unknown atom type " + l);
}
ProperDihedralType properDihedralType = new ProperDihedralType(
i, j, k, l, (Integer) lineObjects.get(4),
(Double) lineObjects.get(5),
(Double) lineObjects.get(6),
(Double) lineObjects.get(7));
/*
* Replace any existing properDihedralType with any new ones.
*/
if (dihedralTypes.contains(properDihedralType)) {
int indexOfDihedralTypeToBeRemoved = dihedralTypes
.indexOf(properDihedralType);
dihedralTypes.remove(indexOfDihedralTypeToBeRemoved);
dihedralTypes.add(properDihedralType);
LOG.warn("Replacing dihedralType:\n"
+ dihedralTypes.get(indexOfDihedralTypeToBeRemoved)
+ "\nwith\n" + properDihedralType);
}
// Multitermed dihedral; peroidicity is negative
if (((Double) lineObjects.get(7)) < 0.0) {
LOG.debug("Found multilined term" + properDihedralType);
// Read the rest of the dihedral terms
while (!(line = br.readLine()).matches("\\s*")) {
LOG.debug("Adding sub term");
lineObjects = formatter.parse(line);
properDihedralType
.setBarrierHeight((Double) lineObjects.get(5));
properDihedralType
.setPhase((Double) lineObjects.get(6));