Skip to content

Commit

Permalink
We need to also handle residues that are 100% C.sp2 and H
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmay authored and egonw committed Jan 3, 2022
1 parent 81b9240 commit 0d9f17e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
20 changes: 15 additions & 5 deletions storage/pdb/src/main/java/org/openscience/cdk/io/PDBReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringReader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -115,6 +116,7 @@ public class PDBReader extends DefaultChemObjectReader {
private AtomTypeFactory cdkAtomTypeFactory;

private static final String hetDictionaryPath = "type_map.txt";
private static final String resDictionaryPath = "type_res.txt";

/**
*
Expand Down Expand Up @@ -742,11 +744,10 @@ else if (hetResidues.contains(resName) && atomName.startsWith("C"))
}

private void readHetDictionary() {
try {
InputStream ins = getClass().getResourceAsStream(hetDictionaryPath);
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(ins));
hetDictionary = new HashMap<>();
hetResidues = new HashSet<>();
hetDictionary = new HashMap<>();
hetResidues = new HashSet<>();
try (InputStream ins = getClass().getResourceAsStream(hetDictionaryPath);
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(ins, StandardCharsets.UTF_8))) {
String line;
while ((line = bufferedReader.readLine()) != null) {
int colonIndex = line.indexOf(':');
Expand All @@ -766,6 +767,15 @@ private void readHetDictionary() {
} catch (IOException ioe) {
logger.error(ioe.getMessage());
}

// additional residue names where all atom types are C.sp2/H
try (InputStream ins = getClass().getResourceAsStream(resDictionaryPath);
BufferedReader brdr = new BufferedReader(new InputStreamReader(ins, StandardCharsets.UTF_8))) {
brdr.lines().filter(l -> !l.startsWith("#"))
.forEach(hetResidues::add);
} catch (IOException ioe) {
logger.error(ioe.getMessage());
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# These residues are composed entirely of C.sp2 and H sod don't appear in
# type_map.txt
AN3
BNL
BNZ
NPY
PEY

0 comments on commit 0d9f17e

Please sign in to comment.