public final static MonomerNotation replaceMonomerNotation ( MonomerNotation monomerNotation , String existingMonomerID , String newMonomerID ) throws NotationException , ChemistryException , CTKException , MonomerLoadingException { /* Nucleotide */ if ( monomerNotation instanceof MonomerNotationUnitRNA ) { List < String > result = generateIDForNucleotide ( ( ( MonomerNotationUnitRNA ) monomerNotation ) , existingMonomerID , newMonomerID ) ; if ( result . get ( 1 ) != null ) { MonomerNotationUnitRNA newObject = new MonomerNotationUnitRNA ( result . get ( 0 ) , monomerNotation . getType ( ) ) ; newObject . setCount ( monomerNotation . getCount ( ) ) ; if ( monomerNotation . isAnnotationTrue ( ) ) { newObject . setAnnotation ( monomerNotation . getAnnotation ( ) ) ; } return newObject ; } } else if ( monomerNotation instanceof MonomerNotationUnit ) { /* Simple MonomerNotationUnit */ if ( monomerNotation . getUnit ( ) . equals ( existingMonomerID ) ) { return produceMonomerNotationUnitWithOtherID ( monomerNotation , newMonomerID ) ; } } else if ( monomerNotation instanceof MonomerNotationList ) { /* MonomerNotationList */ monomerNotation = replaceMonomerNotationList ( ( ( MonomerNotationList ) monomerNotation ) , existingMonomerID , newMonomerID ) ; if ( monomerNotation != null ) { return monomerNotation ; } } else if ( monomerNotation instanceof MonomerNotationGroup ) { /* MonomerNotatationGroup */ monomerNotation = replaceMonomerNotationGroup ( ( ( MonomerNotationGroup ) monomerNotation ) , existingMonomerID , newMonomerID ) ; if ( monomerNotation != null ) { return monomerNotation ; } } else { throw new NotationException ( "Unknown MonomerNotation Type " + monomerNotation . getClass ( ) ) ; } return null ; }
method to replace the MonomerNotation having the MonomerID with the new MonomerID