private static boolean processPolymerSgroups ( CharIter iter , CxSmilesState state ) { if ( state . sgroups == null ) state . sgroups = new ArrayList <> ( ) ; int beg = iter . pos ; while ( iter . hasNext ( ) && ! isSgroupDelim ( iter . curr ( ) ) ) iter . next ( ) ; final String keyword = iter . substr ( beg , iter . pos ) ; if ( ! iter . nextIf ( ' ' ) ) return false ; final List < Integer > atomset = new ArrayList <> ( ) ; if ( ! processIntList ( iter , COMMA_SEPARATOR , atomset ) ) return false ; String subscript ; String supscript ; if ( ! iter . nextIf ( ' ' ) ) return false ; // "If the subscript equals the keyword of the Sgroup this field can be empty", ergo // if omitted it equals the keyword beg = iter . pos ; while ( iter . hasNext ( ) && ! isSgroupDelim ( iter . curr ( ) ) ) iter . next ( ) ; subscript = unescape ( iter . substr ( beg , iter . pos ) ) ; if ( subscript . isEmpty ( ) ) subscript = keyword ; // "In the superscript only connectivity and flip information is allowed.", default // appears to be "eu" either/unspecified if ( ! iter . nextIf ( ' ' ) ) return false ; beg = iter . pos ; while ( iter . hasNext ( ) && ! isSgroupDelim ( iter . curr ( ) ) ) iter . next ( ) ; supscript = unescape ( iter . substr ( beg , iter . pos ) ) ; if ( supscript . isEmpty ( ) ) supscript = "eu" ; if ( iter . nextIf ( ' ' ) || iter . curr ( ) == ' ' ) { state . sgroups . add ( new CxSmilesState . PolymerSgroup ( keyword , atomset , subscript , supscript ) ) ; return true ; } // not supported: crossing bond info (difficult to work out from doc) and bracket orientation return false ; }
Polymer Sgroups describe variations of repeating units . Only the atoms and not crossing bonds are written .