11package bio .singa .structure .parser .plip ;
22
3- import bio .singa .structure .model .families .AminoAcidFamily ;
43import bio .singa .features .identifiers .LeafIdentifier ;
54import org .slf4j .Logger ;
65import org .slf4j .LoggerFactory ;
@@ -85,35 +84,35 @@ public void startElement(String uri, String localName, String qName, Attributes
8584 currentTag = qName ;
8685 switch (qName ) {
8786 case "halogen_bond" :
88- currentInteraction = new HalogenBond (Integer .valueOf (atts .getValue ("id" )));
87+ currentInteraction = new HalogenBond (Integer .parseInt (atts .getValue ("id" )));
8988 interactionType = InteractionType .HALOGEN_BOND ;
9089 break ;
9190 case "hydrophobic_interaction" :
92- currentInteraction = new HydrophobicInteraction (Integer .valueOf (atts .getValue ("id" )));
91+ currentInteraction = new HydrophobicInteraction (Integer .parseInt (atts .getValue ("id" )));
9392 interactionType = InteractionType .HYDROPHOBIC_INTERACTION ;
9493 break ;
9594 case "hydrogen_bond" :
96- currentInteraction = new HydrogenBond (Integer .valueOf (atts .getValue ("id" )));
95+ currentInteraction = new HydrogenBond (Integer .parseInt (atts .getValue ("id" )));
9796 interactionType = InteractionType .HYDROGEN_BOND ;
9897 break ;
9998 case "water_bridge" :
100- currentInteraction = new WaterBridge (Integer .valueOf (atts .getValue ("id" )));
99+ currentInteraction = new WaterBridge (Integer .parseInt (atts .getValue ("id" )));
101100 interactionType = InteractionType .WATER_BRIDGE ;
102101 break ;
103102 case "salt_bridge" :
104- currentInteraction = new SaltBridge (Integer .valueOf (atts .getValue ("id" )));
103+ currentInteraction = new SaltBridge (Integer .parseInt (atts .getValue ("id" )));
105104 interactionType = InteractionType .SALT_BRIDGE ;
106105 break ;
107106 case "pi_stack" :
108- currentInteraction = new PiStacking (Integer .valueOf (atts .getValue ("id" )));
107+ currentInteraction = new PiStacking (Integer .parseInt (atts .getValue ("id" )));
109108 interactionType = InteractionType .PI_STACKING ;
110109 break ;
111110 case "pi_cation_interaction" :
112- currentInteraction = new PiCation (Integer .valueOf (atts .getValue ("id" )));
111+ currentInteraction = new PiCation (Integer .parseInt (atts .getValue ("id" )));
113112 interactionType = InteractionType .PI_CATION_INTERACTION ;
114113 break ;
115114 case "metal_complex" :
116- currentInteraction = new MetalComplex (Integer .valueOf (atts .getValue ("id" )));
115+ currentInteraction = new MetalComplex (Integer .parseInt (atts .getValue ("id" )));
117116 interactionType = InteractionType .METAL_COMPLEX ;
118117 break ;
119118 case "ligcoo" :
@@ -148,6 +147,11 @@ public void endElement(String uri, String localName, String qName) {
148147
149148 @ Override
150149 public void characters (char [] ch , int start , int length ) {
150+ // String testString = new String(ch, start, length);
151+ // if (currentTag.isEmpty() || testString.isBlank()) {
152+ // return;
153+ // }
154+ // System.out.println(currentTag + ": ("+length+") " + testString);
151155 switch (currentTag ) {
152156 case "resnr" :
153157 firstLeafSerial = new String (ch , start , length );
@@ -233,12 +237,8 @@ public void characters(char[] ch, int start, int length) {
233237 as (WaterBridge .class ).setAcceptor (asInteger (ch , start , length ));
234238 break ;
235239 case "sidechain" :
236- switch (interactionType ) {
237- case HYDROGEN_BOND :
238- as (HydrogenBond .class ).setSidechain (asBoolean (ch , start , length ));
239- break ;
240- default :
241- break ;
240+ if (interactionType == InteractionType .HYDROGEN_BOND ) {
241+ as (HydrogenBond .class ).setSidechain (asBoolean (ch , start , length ));
242242 }
243243 break ;
244244 case "protisdon" :
@@ -341,11 +341,6 @@ public void characters(char[] ch, int start, int length) {
341341 case "ligcarbonidx" :
342342 as (HydrophobicInteraction .class ).setAtom2 (asInteger (ch , start , length ));
343343 break ;
344- case "restype_lig" :
345- String restype = new String (ch , start , length );
346- if (!AminoAcidFamily .getAminoAcidTypeByThreeLetterCode (restype ).isPresent ()) {
347- // this.noResidueInteraction = true;
348- }
349344 }
350345
351346 }
@@ -371,7 +366,7 @@ private <InteractionClass extends Interaction> InteractionClass as(Class<Interac
371366
372367 private void addInteraction () {
373368 // skip all interactions that are not between standard amino acids
374- // TODO This may be going down for amino acid ligands or modified amino acids
369+ // TODO This may be failing for amino acid ligands or modified amino acids
375370 if (noResidueInteraction ) {
376371 noResidueInteraction = false ;
377372 return ;
@@ -386,8 +381,8 @@ private void addInteraction() {
386381 return ;
387382 }
388383 // generate identifiers
389- final LeafIdentifier source = new LeafIdentifier (currentPdbIdentifier , 1 , firstLeafChain , Integer .valueOf (firstLeafSerial ));
390- final LeafIdentifier target = new LeafIdentifier (currentPdbIdentifier , 1 , secondLeafChain , Integer .valueOf (secondLeafSerial ));
384+ final LeafIdentifier source = new LeafIdentifier (currentPdbIdentifier , 1 , firstLeafChain , Integer .parseInt (firstLeafSerial ));
385+ final LeafIdentifier target = new LeafIdentifier (currentPdbIdentifier , 1 , secondLeafChain , Integer .parseInt (secondLeafSerial ));
391386 // FIXME for metal complexes this seems to be not valid to take the first occurring entry as source: at atom level source is always the ion
392387 currentInteraction .setSource (source );
393388 currentInteraction .setTarget (target );
@@ -399,15 +394,15 @@ private void addInteraction() {
399394 }
400395
401396 private double asDouble (char [] ch , int start , int length ) {
402- return Double .valueOf (new String (ch , start , length ));
397+ return Double .parseDouble (new String (ch , start , length ));
403398 }
404399
405400 private int asInteger (char [] ch , int start , int length ) {
406- return Integer .valueOf (new String (ch , start , length ));
401+ return Integer .parseInt (new String (ch , start , length ));
407402 }
408403
409404 private boolean asBoolean (char [] ch , int start , int length ) {
410- return Boolean .valueOf (new String (ch , start , length ));
405+ return Boolean .parseBoolean (new String (ch , start , length ));
411406 }
412407
413408
0 commit comments