Skip to content

Commit 46b30b3

Browse files
committed
Back-porting cloning fix (see #541) into bugfixes-4.2
1 parent 234d0da commit 46b30b3

File tree

3 files changed

+12
-30
lines changed

3 files changed

+12
-30
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ public Object clone() {
183183
n.addAltLoc(nAltLocGroup);
184184
}
185185
}
186+
187+
if (chemComp!=null)
188+
n.setChemComp(chemComp);
189+
186190

187191
return n;
188192
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public static enum PerformanceBehavior {
8888

8989
private Map<String,Atom> atomNameLookup;
9090

91-
private ChemComp chemComp ;
91+
protected ChemComp chemComp ;
9292

9393
private List<Group> altLocs;
9494

@@ -402,6 +402,9 @@ public Object clone() {
402402
n.addAltLoc(nAltLocGroup);
403403
}
404404
}
405+
406+
if (chemComp!=null)
407+
n.setChemComp(chemComp);
405408

406409
return n;
407410
}

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

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@
2727

2828

2929
/**
30-
*
31-
* A nucleotide group is almost the same as a Hetatm group.
32-
* @see HetatomImpl
33-
* @see AminoAcidImpl
30+
* A nucleotide group is almost the same as a Hetatm group.
31+
* @see HetatomImpl
32+
* @see AminoAcidImpl
3433
* @author Andreas Prlic
3534
* @since 1.4
3635
* @version %I% %G%
@@ -94,29 +93,5 @@ public Atom getP() {
9493

9594
}
9695

97-
@Override
98-
public Object clone(){
99-
NucleotideImpl n = new NucleotideImpl();
100-
101-
n.setPDBFlag(has3D());
102-
n.setResidueNumber(getResidueNumber());
103-
104-
n.setPDBName(getPDBName());
105-
106-
// copy the atoms
107-
for (Atom atom1 : atoms) {
108-
Atom atom = (Atom) atom1.clone();
109-
n.addAtom(atom);
110-
atom.setGroup(n);
111-
}
112-
113-
// copying the alt loc groups if present, otherwise they stay null
114-
if (getAltLocs()!=null && !getAltLocs().isEmpty()) {
115-
for (Group altLocGroup:this.getAltLocs()) {
116-
Group nAltLocGroup = (Group)altLocGroup.clone();
117-
n.addAltLoc(nAltLocGroup);
118-
}
119-
}
120-
return n;
121-
}
96+
// no need to implement clone here, it's already in super class
12297
}

0 commit comments

Comments
 (0)