Skip to content

Commit afd6fcb

Browse files
committed
Fix for #631
1 parent 0d07e69 commit afd6fcb

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

biojava-integrationtest/src/test/java/org/biojava/nbio/structure/test/StructureToolsTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,11 @@ public void testGetRepresentativeAtomsProtein() throws StructureException, IOExc
494494
assertEquals(98,atoms.length);
495495
}
496496

497+
/**
498+
* See https://github.com/biojava/biojava/issues/631
499+
* @throws StructureException
500+
* @throws IOException
501+
*/
497502
@Test
498503
public void testGetRepresentativeAtomsDna() throws StructureException, IOException {
499504

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

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,36 @@ public Atom getP() {
9393

9494
}
9595

96-
// no need to implement clone here, it's already in super class
96+
// note we need to implement a clone here, despite there's one in super class already,
97+
// that's due to issue https://github.com/biojava/biojava/issues/631 - JD 2017-01-21
98+
@Override
99+
public Object clone() {
100+
101+
NucleotideImpl n = new NucleotideImpl();
102+
n.setPDBFlag(has3D());
103+
n.setResidueNumber(getResidueNumber());
104+
105+
n.setPDBName(getPDBName());
106+
107+
// copy the atoms
108+
for (Atom atom1 : atoms) {
109+
Atom atom = (Atom) atom1.clone();
110+
n.addAtom(atom);
111+
atom.setGroup(n);
112+
}
113+
114+
// copying the alt loc groups if present, otherwise they stay null
115+
if (getAltLocs()!=null && !getAltLocs().isEmpty()) {
116+
for (Group altLocGroup:this.getAltLocs()) {
117+
Group nAltLocGroup = (Group)altLocGroup.clone();
118+
n.addAltLoc(nAltLocGroup);
119+
}
120+
}
121+
122+
if (chemComp!=null)
123+
n.setChemComp(chemComp);
124+
125+
126+
return n;
127+
}
97128
}

0 commit comments

Comments
 (0)