public static Group [ ] cloneGroups ( Atom [ ] ca ) { Group [ ] newGroup = new Group [ ca . length ] ; List < Chain > model = new ArrayList < Chain > ( ) ; int apos = - 1 ; for ( Atom a : ca ) { apos ++ ; Group parentG = a . getGroup ( ) ; Chain parentC = parentG . getChain ( ) ; Chain newChain = null ; for ( Chain c : model ) { if ( c . getName ( ) . equals ( parentC . getName ( ) ) ) { newChain = c ; break ; } } if ( newChain == null ) { newChain = new ChainImpl ( ) ; newChain . setName ( parentC . getName ( ) ) ; model . add ( newChain ) ; } Group ng = ( Group ) parentG . clone ( ) ; newGroup [ apos ] = ng ; newChain . addGroup ( ng ) ; } return newGroup ; }
Clone a set of representative Atoms but returns the parent groups