Skip to content

Commit 63958d4

Browse files
committed
Fix for #631
1 parent 28646e7 commit 63958d4

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
@@ -558,6 +558,11 @@ public void testGetRepresentativeAtomsProtein() throws StructureException, IOExc
558558
assertEquals(98,atoms.length);
559559
}
560560

561+
/**
562+
* See https://github.com/biojava/biojava/issues/631
563+
* @throws StructureException
564+
* @throws IOException
565+
*/
561566
@Test
562567
public void testGetRepresentativeAtomsDna() throws StructureException, IOException {
563568

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)