Skip to content

Commit 01620a5

Browse files
authored
Merge pull request #779 from josemduarte/more-altloc-problems
Fixing an altloc issue
2 parents 0e3a597 + 749513c commit 01620a5

File tree

6 files changed

+290
-101
lines changed

6 files changed

+290
-101
lines changed

biojava-structure/src/main/java/org/biojava/nbio/structure/Chain.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ public interface Chain extends Serializable {
281281
/**
282282
* Returns the sequence of amino acids as it has been provided in the ATOM records.
283283
* Non-standard residues will be present in the string only if the property
284-
* {@value org.biojava.nbio.structure.io.PDBFileReader.LOAD_CHEM_COMP_PROPERTY} has been set.
284+
* {@value org.biojava.nbio.structure.io.PDBFileReader#LOAD_CHEM_COMP_PROPERTY} has been set.
285285
* @return amino acid sequence as string
286286
* @see #getSeqResSequence()
287287
*/

biojava-structure/src/main/java/org/biojava/nbio/structure/Group.java

Lines changed: 63 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,14 @@ public interface Group extends Serializable {
6464
public int size();
6565

6666
/**
67-
* Return true or false, depending if this group has 3D coordinates or not.
67+
* Return true or false, depending if this group has 3D coordinates or not.
6868
*
6969
* @return true if Group has 3D coordinates
7070
*/
7171
public boolean has3D ();
7272

73-
/** Flag if group has 3D data .
73+
/**
74+
* Flag if group has 3D data .
7475
*
7576
* @param flag true to set flag that this Group has 3D coordinates
7677
*/
@@ -84,21 +85,24 @@ public interface Group extends Serializable {
8485
*/
8586
public GroupType getType();
8687

87-
/** Add an atom to this group.
88+
/**
89+
* Add an atom to this group.
8890
*
8991
* @param atom an Atom object
9092
*/
9193
public void addAtom(Atom atom);
9294

93-
/** Get list of atoms.
95+
/**
96+
* Get list of atoms.
9497
*
9598
* @return a List object representing the atoms
9699
* @see #setAtoms(List)
97100
*/
98101
public List<Atom> getAtoms() ;
99102

100103

101-
/** Set the atoms of this group.
104+
/**
105+
* Set the atoms of this group.
102106
* @see {@link Atom}
103107
* @param atoms a list of atoms
104108
*/
@@ -180,21 +184,24 @@ public interface Group extends Serializable {
180184
public boolean hasAminoAtoms() ;
181185

182186

183-
/** tests in the Chemical Component Dictionary, if this group is a polymeric group
187+
/**
188+
* Check if this group is a polymeric group, from the definition in Chemical Component Dictionary
184189
*
185190
* @return true if a polymeric group
186191
*/
187192
public boolean isPolymeric();
188193

189194

190-
/** Tests in the Chemical Component Dictionary, if this group is an amino acid
195+
/**
196+
* Check if this group is an aminoacid group, from the definition in Chemical Component Dictionary
191197
*
192198
* @return true if an amino acid
193199
*/
194200
public boolean isAminoAcid();
195201

196202

197-
/** Tests in the Chemical Component Dictionary, if this group is a nucleotide
203+
/**
204+
* Check if this group is a nucleotide group, from the definition in Chemical Component Dictionary
198205
*
199206
* @return true if a nucleotide
200207
*/
@@ -213,38 +220,42 @@ public interface Group extends Serializable {
213220
*/
214221
public void setProperties(Map<String,Object> properties) ;
215222

216-
/** return properties.
223+
/**
224+
* Return properties.
217225
* @see #setProperties
218226
*
219227
* @return a HashMap object representing the properties value
220228
*/
221229
public Map<String,Object> getProperties() ;
222230

223-
/** set a single property .
231+
/**
232+
* Set a single property .
224233
*
225234
* @param key a String
226235
* @param value an Object
227236
* @see #getProperty
228-
229237
*/
230238
public void setProperty(String key, Object value) ;
231239

232-
/** get a single property .
240+
/**
241+
* Get a single property .
233242
*
234243
* @param key a String
235244
* @return an Object
236245
* @see #setProperty
237246
*/
238247
public Object getProperty(String key) ;
239248

240-
/** get an Atom Iterator.
249+
/**
250+
* Get an Atom Iterator.
241251
*
242252
* @return an Iterator object
243253
*/
244254
public Iterator<Atom> iterator() ;
245255

246256

247-
/** returns and identical copy of this Group object .
257+
/**
258+
* Returns and identical copy of this Group object .
248259
* @return and identical copy of this Group object
249260
*/
250261
public Object clone();
@@ -267,7 +278,7 @@ public interface Group extends Serializable {
267278
public Chain getChain() ;
268279

269280
/**
270-
* returns a dynamically created ResidueNumber for the group - this
281+
* Returns a dynamically created ResidueNumber for the group - this
271282
* contains the chainId, resNum and insCode of the group.
272283
* @see ResidueNumber
273284
* @return ResidueNumber for the group.
@@ -276,13 +287,15 @@ public interface Group extends Serializable {
276287
public ResidueNumber getResidueNumber();
277288

278289

279-
/** sets the ResidueNumber for this Group
290+
/**
291+
* Sets the ResidueNumber for this Group
280292
*
281293
* @param residueNumber the PDB residueNumber
282294
*/
283295
public void setResidueNumber(ResidueNumber residueNumber);
284296

285-
/** Utility method to temporarily set a chainID for a group, if a parent chain object does not exist yet.
297+
/**
298+
* Utility method to temporarily set a chainID for a group, if a parent chain object does not exist yet.
286299
* Not recommended for general use other than parsing.
287300
*
288301
* @param chainId
@@ -301,41 +314,66 @@ public interface Group extends Serializable {
301314
*/
302315
public String getChainId();
303316

304-
/** Set the Chemical Component that closer describes this group.
317+
/**
318+
* Set the Chemical Component that closer describes this group.
305319
*
306320
* @param cc the chemical component
307321
*/
308322
public void setChemComp(ChemComp cc);
309323

310-
/** Get the chemical component that closer describes this group. If the information does not exist yet, fetches the information from PDB web site.
324+
/**
325+
* Get the chemical component that closer describes this group. If the information does not exist yet, fetches the information from PDB web site.
311326
*
312327
* @return the Chemical Component definition for this Group.
313328
*/
314329
public ChemComp getChemComp();
315330

316331

317-
/** Test if this group has alternate locations.
332+
/**
333+
* Check if this group has alternate location groups.
318334
*
319335
* @return boolean flag if there are alternate locations.
336+
* @see #getAltLocs()
320337
*/
321338
public boolean hasAltLoc();
322339

323340

324-
/** Get the list of alternate locations.
341+
/**
342+
* Get the list of other alternate location groups.
343+
* <p>
344+
* The main group (this group) will contain the first altloc (be it the default '.' or 'A' or a mix of '.' and 'A').
345+
* <p>
346+
* This method will return the altloc groups that are not the main group, e.g.:
347+
*
348+
* <li> if '.' (default), 'A' and 'B' altlocs are present in file, the main group will contain
349+
* the default '.' and this method will return 2 altloc groups
350+
* </li>
351+
*
352+
* <li> if 'A' and 'B' are present in file without a default '.' group, then the main group will contain the 'A'
353+
* location whilst this method will return only 1 altloc group with the 'B' location
354+
* </li>
355+
*
356+
* <p>
357+
* Note that atoms with the default altloc (.) are included in all groups. Atoms with other altlocs (typically A, B, etc)
358+
* will be sorted into groups by altloc.
359+
* <p>
360+
* Thus it can happen that an altloc group duplicate the contents of the main group.
325361
*
326362
* @return List of other groups that are on alternate locations
327363
*/
328364
public List<Group> getAltLocs();
329365

330-
/** Add a group that is an alternate location for this group.
366+
/**
367+
* Add a group that is an alternate location for this group.
331368
*
369+
* @param g the altloc group to add
332370
*/
333371
public void addAltLoc(Group g);
334372

335373
/**
336374
* Determines if this group is water.
337375
*
338-
* @see {@link GroupType#WATERNAMES}
376+
* @see GroupType#WATERNAMES
339377
* @return true if it's water, false otherwise.
340378
*/
341379
public boolean isWater();
@@ -349,7 +387,8 @@ public interface Group extends Serializable {
349387
public Group getAltLocGroup(Character altLoc);
350388

351389

352-
/** attempts to reduce the memory imprint of this group by trimming
390+
/**
391+
* Attempts to reduce the memory imprint of this group by trimming
353392
* all internal Collection objects to the required size.
354393
*
355394
*/

biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,7 +1842,8 @@ public static boolean isChainWaterOnly(Chain c) {
18421842
return c.isWaterOnly();
18431843
}
18441844

1845-
/** @deprecated use {@link Chain#isPureNonPolymer()} instead.
1845+
/**
1846+
* @deprecated use {@link Chain#isPureNonPolymer()} instead.
18461847
*/
18471848
@Deprecated
18481849
public static boolean isChainPureNonPolymer(Chain c) {
@@ -1851,8 +1852,9 @@ public static boolean isChainPureNonPolymer(Chain c) {
18511852
}
18521853

18531854
/**
1854-
* Cleans up the structure's alternate location groups. All alternate location groups should have all atoms (except in the case of microheterogenity) or when a deuetuim exiss.
1855-
* Ensure that all the alt loc groups have all the atoms in the main group
1855+
* Cleans up the structure's alternate location (altloc) groups. All alternate location groups should have all atoms (except
1856+
* in the case of microheterogenity) or when a deuterium exists.
1857+
* Ensure that all the alt loc groups have all the atoms in the main group.
18561858
* @param structure The Structure to be cleaned up
18571859
*/
18581860
public static void cleanUpAltLocs(Structure structure) {
@@ -1866,10 +1868,7 @@ public static void cleanUpAltLocs(Structure structure) {
18661868
// Fix for microheterogenity
18671869
if (altLocGroup.getPDBName().equals(group.getPDBName())) {
18681870
// If it's a Hydrogen then we check for it's Deuterated brother
1869-
if(hasDeuteratedEquiv(groupAtom, altLocGroup)){
1870-
1871-
}
1872-
else{
1871+
if(!hasDeuteratedEquiv(groupAtom, altLocGroup)){
18731872
altLocGroup.addAtom(groupAtom);
18741873
}
18751874
}
@@ -1896,7 +1895,7 @@ public static boolean hasNonDeuteratedEquiv(Atom atom, Group currentGroup) {
18961895
}
18971896

18981897
/**
1899-
* Check to see if a Hydorgen has a Deuterated brother in the group.
1898+
* Check to see if a Hydrogen has a Deuterated brother in the group.
19001899
* @param atom the input atom that is putatively hydorgen
19011900
* @param currentGroup the group the atom is in
19021901
* @return true if the atom is hydrogen and it's Deuterium equiv exists.
@@ -1915,4 +1914,5 @@ private static String replaceFirstChar(String name, char c, char d) {
19151914
}
19161915
return name;
19171916
}
1917+
19181918
}

0 commit comments

Comments
 (0)