public final static MonomerNotationList replaceMonomerNotationList ( MonomerNotationList object , String existingMonomerID , String newMonomerID ) throws NotationException , ChemistryException , CTKException , MonomerLoadingException { MonomerNotationList newObject = null ; boolean hasChanged = false ; StringBuilder sb = new StringBuilder ( ) ; String id = "" ; for ( MonomerNotation element : object . getListofMonomerUnits ( ) ) { if ( element instanceof MonomerNotationUnitRNA ) { List < String > result = generateIDForNucleotide ( ( ( MonomerNotationUnitRNA ) element ) , existingMonomerID , newMonomerID ) ; id = result . get ( 0 ) ; if ( result . get ( 1 ) != null ) { hasChanged = true ; } } else { if ( element . getUnit ( ) . equals ( existingMonomerID ) ) { hasChanged = true ; id = generateIDMonomerNotation ( newMonomerID , element . getCount ( ) , element . getAnnotation ( ) ) ; } else { id = generateIDMonomerNotation ( element . getUnit ( ) , element . getCount ( ) , element . getAnnotation ( ) ) ; } } sb . append ( id + "." ) ; } if ( hasChanged ) { sb . setLength ( sb . length ( ) - 1 ) ; newObject = new MonomerNotationList ( sb . toString ( ) , object . getType ( ) ) ; newObject . setCount ( object . getCount ( ) ) ; if ( object . isAnnotationTrue ( ) ) { newObject . setAnnotation ( object . getAnnotation ( ) ) ; } } return newObject ; }
method to replace the MonomerNotationList having the MonomerID with the new MonomerID