Skip to content

Commit 72317d9

Browse files
committed
Fixing issue in cloning: was adding same group several times
1 parent f191d14 commit 72317d9

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,14 @@ public static final Atom[] cloneAtomArray(Atom[] ca) {
700700
Group parentN = (Group) parentG.clone();
701701

702702
newCA[apos] = parentN.getAtom(a.getName());
703-
newChain.addGroup(parentN);
703+
try {
704+
// if the group doesn't exist yet, this produces a StructureException
705+
newChain.getGroupByPDB(parentN.getResidueNumber());
706+
} catch (StructureException e) {
707+
// the group doesn't exist yet in the newChain, let's add it
708+
newChain.addGroup(parentN);
709+
}
710+
704711
}
705712
return newCA;
706713
}

0 commit comments

Comments
 (0)