private static int getMonomerCountFromMonomerNotation ( MonomerNotation monomerNotation ) { int multiply ; try { multiply = Integer . parseInt ( monomerNotation . getCount ( ) ) ; if ( multiply < 1 ) { multiply = 1 ; } } catch ( NumberFormatException e ) { multiply = 1 ; } if ( monomerNotation instanceof MonomerNotationGroup ) { return 1 * multiply ; } if ( monomerNotation instanceof MonomerNotationList ) { int count = 0 ; for ( MonomerNotation unit : ( ( MonomerNotationList ) monomerNotation ) . getListofMonomerUnits ( ) ) { count += getMonomerCountFromMonomerNotation ( unit ) ; } return count * multiply ; } if ( monomerNotation instanceof MonomerNotationUnitRNA ) { int count = 0 ; for ( MonomerNotationUnit unit : ( ( MonomerNotationUnitRNA ) monomerNotation ) . getContents ( ) ) { count += getMonomerCountFromMonomerNotation ( unit ) ; } return count * multiply ; } return 1 * multiply ; }
method to get the number of all existing monomers from one MonomerNotation