Skip to content

Commit

Permalink
Fix for charge parsing in PDB files, based on the patch by Nils <nils…
Browse files Browse the repository at this point in the history
…@users.sf.net>

Change-Id: I7414228850ac87880febdebfc6e912647638f2c6
Signed-off-by: John May <john.wilkinsonmay@gmail.com>
  • Loading branch information
egonw committed Feb 19, 2012
1 parent e2eb007 commit 7c7248a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/main/org/openscience/cdk/io/PDBReader.java
Expand Up @@ -671,9 +671,19 @@ private PDBAtom readAtom(String cLine, int lineLength) {
// oAtom.setSymbol((new String(cLine.substring(76, 78))).trim());
// }
if (lineLength >= 79) {
String frag = cLine.substring(78, 80).trim();
String frag;
if (lineLength >= 80) {
frag = cLine.substring(78, 80).trim();
} else {
frag = cLine.substring(78);
}
if (frag.length() > 0) {
oAtom.setCharge(Double.parseDouble(frag));
// see Format_v33_A4.pdf, p. 178
if (frag.endsWith("-") || frag.endsWith("+")) {
oAtom.setCharge(Double.parseDouble(new StringBuilder(frag).reverse().toString()));
} else {
oAtom.setCharge(Double.parseDouble(frag));
}
}
}

Expand Down

0 comments on commit 7c7248a

Please sign in to comment.