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;

	}
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

@param object
MonomerNotationList to change
@param existingMonomerID
monomer to change
@param newMonomerID
new monomer
@return MonomerNotationList, if it had the old MonomerID, null otherwise
@throws NotationException
if notation is not valid
@throws ChemistryException
if chemistry could not be initialized
@throws CTKException
general ChemToolKit exception passed to HELMToolKit
@throws MonomerLoadingException
could not load monomers from source