Skip to content

Commit 291fae5

Browse files
committed
Clean up of warnings and removed some old deprecations
1 parent fe7071b commit 291fae5

13 files changed

Lines changed: 128 additions & 507 deletions

File tree

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
import org.biojava.nbio.core.sequence.template.Sequence;
2727
import org.biojava.nbio.structure.io.FileParsingParameters;
28-
import org.biojava.nbio.structure.io.PDBFileReader;
2928

3029
import java.util.List;
3130

‎biojava-structure/src/main/java/org/biojava/nbio/structure/ChainImpl.java‎

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public class ChainImpl implements Chain, Serializable {
6464
private List <Group> groups;
6565
private List<Group> seqResGroups;
6666

67-
private EntityInfo mol;
67+
private EntityInfo entity;
6868
private Structure parent;
6969

7070
private Map<String, Integer> pdbResnumMap;
@@ -170,7 +170,7 @@ public Object clone() {
170170

171171
// NOTE the EntityInfo will be reset at the parent level (Structure) if cloning is happening from parent level
172172
// here we don't deep-copy it and just keep the same reference, in case the cloning is happening at the Chain level only
173-
n.setEntityInfo(this.mol);
173+
n.setEntityInfo(this.entity);
174174

175175
n.setInternalChainID(asymId);
176176

@@ -189,7 +189,7 @@ public Object clone() {
189189

190190
for (Group seqResGroup : seqResGroups) {
191191

192-
int i = findMathingGroupIndex(groups, seqResGroup);
192+
int i = groups.indexOf(seqResGroup);
193193

194194
Group g ;
195195

@@ -210,31 +210,20 @@ public Object clone() {
210210
return n ;
211211
}
212212

213-
private static int findMathingGroupIndex(List<Group> atomGroups, Group g) {
214-
int i = 0;
215-
for (Group atomGroup: atomGroups) {
216-
if (g==atomGroup) return i;
217-
i++;
218-
}
219-
return -1;
220-
}
221-
222-
223-
224213
/** {@inheritDoc}
225214
*
226215
*/
227216
@Override
228217
public void setEntityInfo(EntityInfo mol) {
229-
this.mol = mol;
218+
this.entity = mol;
230219
}
231220

232221
/** {@inheritDoc}
233222
*
234223
*/
235224
@Override
236225
public EntityInfo getEntityInfo() {
237-
return this.mol;
226+
return this.entity;
238227
}
239228

240229
/** set the Swissprot id of this chains .
@@ -516,9 +505,9 @@ public String toString(){
516505
String newline = System.getProperty("line.separator");
517506
StringBuilder str = new StringBuilder();
518507
str.append("Chain asymId:").append(getChainID()).append(" authId:").append(getName()).append(newline);
519-
if ( mol != null ){
520-
if ( mol.getDescription() != null){
521-
str.append(mol.getDescription()).append(newline);
508+
if ( entity != null ){
509+
if ( entity.getDescription() != null){
510+
str.append(entity.getDescription()).append(newline);
522511
}
523512
}
524513
str.append("total SEQRES length: ").append(getSeqResGroups().size()).append(" total ATOM length:")

‎biojava-structure/src/main/java/org/biojava/nbio/structure/EntityInfo.java‎

Lines changed: 20 additions & 185 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public class EntityInfo implements Serializable {
7575
/**
7676
* A map to cache residue number mapping, between ResidueNumbers and index (1-based) in aligned sequences (SEQRES).
7777
* Initialised lazily upon call to {@link #getAlignedResIndex(Group, Chain)}
78+
* Keys are asym_ids of chains, values maps of residue numbers to indices.
7879
*/
7980
private Map<String, Map<ResidueNumber,Integer>> chains2pdbResNums2ResSerials;
8081

@@ -215,10 +216,10 @@ public String toString(){
215216
StringBuilder buf = new StringBuilder();
216217
buf.append("EntityInfo: ").append(molId).append(" ");
217218
buf.append(description==null?"(no name)":"("+description+")");
218-
buf.append(" chainIds: ");
219+
buf.append(" asymIds: ");
219220
if (chains!=null) {
220221
for (int i=0;i<chains.size();i++) {
221-
buf.append(chains.get(i).getChainID());
222+
buf.append(chains.get(i).getId());
222223
if (i!=chains.size()-1) buf.append(",");
223224
}
224225
} else {
@@ -229,7 +230,7 @@ public String toString(){
229230

230231
/**
231232
* Get the representative Chain for this EntityInfo.
232-
* We choose the Chain with the first chain identifier after
233+
* We choose the Chain with the first asym_id chain identifier after
233234
* lexicographical sorting (case insensitive),
234235
* e.g. chain A if EntityInfo is composed of chains A,B,C,D,E
235236
* @return
@@ -238,13 +239,13 @@ public Chain getRepresentative() {
238239

239240
List<String> chainIds = new ArrayList<String>();
240241
for (Chain chain:chains) {
241-
chainIds.add(chain.getChainID());
242+
chainIds.add(chain.getId());
242243
}
243244

244245
Collections.sort(chainIds, String.CASE_INSENSITIVE_ORDER);
245246

246247
for (Chain chain:chains) {
247-
if (chain.getChainID().equals(chainIds.get(0))) {
248+
if (chain.getId().equals(chainIds.get(0))) {
248249
return chain;
249250
}
250251
}
@@ -271,169 +272,7 @@ public void setId(Long id) {
271272
}
272273

273274
/**
274-
* Print some debug statements to System.out
275-
*
276-
*
277-
*/
278-
public void showHeader(){
279-
this.showEntityInfo();
280-
this.showSource();
281-
}
282-
283-
public void showEntityInfo() {
284-
System.out.println("ENTITY INFO:");
285-
if (this.molId != -1) {
286-
System.out.println("Mol ID: " + this.molId);
287-
}
288-
if (this.chains != null) {
289-
StringBuilder buf = new StringBuilder();
290-
for (int i=0;i<chains.size();i++) {
291-
buf.append(chains.get(i).getChainID());
292-
if (i!=chains.size()-1) buf.append(",");
293-
}
294-
System.out.println("Chains: " + buf.toString());
295-
}
296-
if (this.description != null) {
297-
System.out.println("Mol Name: " + this.description);
298-
}
299-
if (this.title != null) {
300-
System.out.println("Title: " + this.title);
301-
}
302-
if (this.synonyms != null) {
303-
for (String x : this.synonyms) {
304-
System.out.println("Synomym: " + x);
305-
}
306-
}
307-
if (this.ecNums != null) {
308-
for (String x : this.ecNums) {
309-
System.out.println("EC: " + x);
310-
}
311-
}
312-
if (this.fragment != null) {
313-
System.out.println("Fragment? " + this.fragment);
314-
}
315-
if (this.engineered != null) {
316-
System.out.println("Engineered? " + this.engineered);
317-
}
318-
if (this.mutation != null) {
319-
System.out.println("Mutation? " + this.mutation);
320-
}
321-
if (this.biologicalUnit != null) {
322-
System.out.println("Biological Unit: " + this.biologicalUnit);
323-
}
324-
if (this.details != null) {
325-
System.out.println("Details: " + this.details);
326-
}
327-
if (this.numRes != null) {
328-
System.out.println("No. Residues: " + this.numRes);
329-
}
330-
//System.out.println( "\n"
331-
332-
}
333-
334-
335-
public void showSource() {
336-
System.out.println("SOURCE INFO:");
337-
if (this.synthetic != null) {
338-
System.out.println("Synthetic? " + this.synthetic);
339-
}
340-
if (this.fragment != null) {
341-
System.out.println("Fragment? " + this.fragment);
342-
}
343-
if (this.organismScientific != null) {
344-
System.out.println("Organism Scientific: " + this.organismScientific);
345-
}
346-
if (this.organismTaxId != null) {
347-
System.out.println("Organism Tax Id: " + this.organismTaxId);
348-
}
349-
if (this.organismCommon != null) {
350-
System.out.println("Organism Common: " + this.organismCommon);
351-
}
352-
if (this.strain != null) {
353-
System.out.println("Strain: " + this.strain);
354-
}
355-
if (this.variant != null) {
356-
System.out.println("Variant: " + this.variant);
357-
}
358-
if (this.cellLine != null) {
359-
System.out.println("Cell Line: " + this.cellLine);
360-
}
361-
if (this.atcc != null) {
362-
System.out.println("ATCC: " + this.atcc);
363-
}
364-
if (this.organ != null) {
365-
System.out.println("Organ: " + this.organ);
366-
}
367-
if (this.tissue != null) {
368-
System.out.println("Tissue: " + this.tissue);
369-
}
370-
if (this.cell != null) {
371-
System.out.println("Cell: " + this.cell);
372-
}
373-
if (this.organelle != null) {
374-
System.out.println("Organelle: " + this.organelle);
375-
}
376-
if (this.secretion != null) {
377-
System.out.println("Secretion: " + this.secretion);
378-
}
379-
if (this.gene != null) {
380-
System.out.println("Gene: " + this.gene);
381-
}
382-
if (this.cellularLocation != null) {
383-
System.out.println("Cellular Location: " + this.cellularLocation);
384-
}
385-
if (this.expressionSystem != null) {
386-
System.out.println("Expression System: " + this.expressionSystem);
387-
}
388-
if (this.expressionSystemTaxId != null) {
389-
System.out.println("Expression System Tax Id: " + this.expressionSystemTaxId);
390-
}
391-
if (this.expressionSystemStrain != null) {
392-
System.out.println("Expression System Strain: " + this.expressionSystemStrain);
393-
}
394-
if (this.expressionSystemVariant != null) {
395-
System.out.println("Expression System Variant: " + this.expressionSystemVariant);
396-
}
397-
if (this.expressionSystemCellLine != null) {
398-
System.out.println("Expression System Cell Line: " + this.expressionSystemCellLine);
399-
}
400-
if (this.expressionSystemAtccNumber != null) {
401-
System.out.println("Expression System ATCC Number: " + this.expressionSystemAtccNumber);
402-
}
403-
if (this.expressionSystemOrgan != null) {
404-
System.out.println("Expression System Organ: " + this.expressionSystemOrgan);
405-
}
406-
if (this.expressionSystemTissue != null) {
407-
System.out.println("Expression System Tissue: " + this.expressionSystemTissue);
408-
}
409-
if (this.expressionSystemCell != null) {
410-
System.out.println("Expression System Cell: " + this.expressionSystemCell);
411-
}
412-
if (this.expressionSystemOrganelle != null) {
413-
System.out.println("Expression System Organelle: " + this.expressionSystemOrganelle);
414-
}
415-
if (this.expressionSystemCellularLocation != null) {
416-
System.out.println("Expression System Cellular Location: " + this.expressionSystemCellularLocation);
417-
}
418-
if (this.expressionSystemVectorType != null) {
419-
System.out.println("Expression System Vector Type: " + this.expressionSystemVectorType);
420-
}
421-
if (this.expressionSystemVector != null) {
422-
System.out.println("Expression System Vector: " + this.expressionSystemVector);
423-
}
424-
if (this.expressionSystemPlasmid != null) {
425-
System.out.println("Expression System Plasmid: " + this.expressionSystemPlasmid);
426-
}
427-
if (this.expressionSystemGene != null) {
428-
System.out.println("Expression System Gene: " + this.expressionSystemGene);
429-
}
430-
if (this.expressionSystemOtherDetails != null) {
431-
System.out.println("Expression System Other Details: " + this.expressionSystemOtherDetails);
432-
}
433-
}
434-
435-
/**
436-
* Return the list of member chain IDs that are described by this EnityInfo,
275+
* Return the list of member chain ids (asym ids) that are described by this EntityInfo,
437276
* only unique chain IDs are contained in the list.
438277
* Note that in the case of multimodel structures this will return just the unique
439278
* chain identifiers whilst {@link #getChains()} will return a corresponding chain
@@ -446,7 +285,7 @@ public List<String> getChainIds() {
446285

447286
Set<String> uniqChainIds = new TreeSet<String>();
448287
for (int i=0;i<getChains().size();i++) {
449-
uniqChainIds.add(getChains().get(i).getChainID());
288+
uniqChainIds.add(getChains().get(i).getId());
450289
}
451290

452291
return new ArrayList<String>(uniqChainIds);
@@ -475,20 +314,20 @@ public int getAlignedResIndex(Group g, Chain c) {
475314

476315
boolean contained = false;
477316
for (Chain member:getChains()) {
478-
if (c.getChainID().equals(member.getChainID())) {
317+
if (c.getId().equals(member.getId())) {
479318
contained = true;
480319
break;
481320
}
482321
}
483322
if (!contained)
484-
throw new IllegalArgumentException("Given chain "+c.getChainID()+" is not a member of this entity: "+getChainIds().toString());
323+
throw new IllegalArgumentException("Given chain with asym_id "+c.getId()+" is not a member of this entity: "+getChainIds().toString());
485324

486-
if (!chains2pdbResNums2ResSerials.containsKey(c.getChainID())) {
325+
if (!chains2pdbResNums2ResSerials.containsKey(c.getId())) {
487326
// we do lazy initialisation of the map
488327
initResSerialsMap(c);
489328
}
490329
// if no seqres groups are available at all the map will be null
491-
Map<ResidueNumber,Integer> map = chains2pdbResNums2ResSerials.get(c.getChainID());
330+
Map<ResidueNumber,Integer> map = chains2pdbResNums2ResSerials.get(c.getId());
492331
int serial;
493332
if (map!=null) {
494333

@@ -497,12 +336,8 @@ public int getAlignedResIndex(Group g, Chain c) {
497336
// still it can happen that a group is in ATOM in one chain but not in other of the same entity.
498337
// This is what we try to find out here (analogously to what we do in initResSerialsMap() ):
499338
if (resNum==null && c.getSeqResGroups()!=null && !c.getSeqResGroups().isEmpty()) {
500-
int index = -1;
501-
for (int i=0;i<c.getSeqResGroups().size();i++) {
502-
if (g==c.getSeqResGroup(i)) {
503-
index = i; break;
504-
}
505-
}
339+
340+
int index = c.getSeqResGroups().indexOf(g);
506341

507342
resNum = findResNumInOtherChains(index, c);
508343

@@ -533,16 +368,16 @@ public int getAlignedResIndex(Group g, Chain c) {
533368

534369
private void initResSerialsMap(Chain c) {
535370
if (c.getSeqResGroups()==null || c.getSeqResGroups().isEmpty()) {
536-
logger.warn("No SEQRES groups found in chain {}, will use residue numbers as given (no insertion codes, not necessarily aligned). "
371+
logger.warn("No SEQRES groups found in chain with asym_id {}, will use residue numbers as given (no insertion codes, not necessarily aligned). "
537372
+ "Make sure your structure has SEQRES records and that you use FileParsingParameters.setAlignSeqRes(true)",
538-
c.getChainID());
373+
c.getId());
539374
// we add a explicit null to the map so that we flag it as unavailable for this chain
540-
chains2pdbResNums2ResSerials.put(c.getChainID(), null);
375+
chains2pdbResNums2ResSerials.put(c.getId(), null);
541376
return;
542377
}
543378

544379
Map<ResidueNumber,Integer> resNums2ResSerials = new HashMap<ResidueNumber, Integer>();
545-
chains2pdbResNums2ResSerials.put(c.getChainID(), resNums2ResSerials);
380+
chains2pdbResNums2ResSerials.put(c.getId(), resNums2ResSerials);
546381

547382
for (int i=0;i<c.getSeqResGroups().size();i++) {
548383

@@ -572,8 +407,8 @@ private ResidueNumber findResNumInOtherChains(int i, Chain chain) {
572407
Group seqResGroup = c.getSeqResGroup(i);
573408

574409
if (seqResGroup==null) {
575-
logger.warn("The SEQRES group is null for index {} in chain {}, whilst it wasn't null in chain {}",
576-
i, c.getChainID(), chain.getChainID());
410+
logger.warn("The SEQRES group is null for index {} in chain with asym_id {}, whilst it wasn't null in chain with asym_id {}",
411+
i, c.getId(), chain.getId());
577412
continue;
578413
}
579414

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,7 @@ public interface Group {
269269

270270
/**
271271
* Utility method for returning the chainId of the Group or null if no
272-
* Chain has been set. This replaces the need to use the expression
273-
* group.getChain().getId()
272+
* Chain has been set. This is equivalent to calling getChain().getId()
274273
* @since 3.0
275274
* @return the ID of the chain
276275
*/

‎biojava-structure/src/main/java/org/biojava/nbio/structure/HetatomImpl.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ public String getChainId() {
467467
if (parent == null) {
468468
return "";
469469
}
470-
return parent.getChainID();
470+
return parent.getId();
471471
}
472472

473473
/**

0 commit comments

Comments
 (0)