code: protected ArrayList<SAXMotif> getAllMotifs(GrammarRules grammarRules) {
  
      // result
      ArrayList<SAXMotif> allMotifs = new ArrayList<SAXMotif>();
  
      int ruleNumber = grammarRules.size();
  
      // iterate over all rules
      for (int i = 0; i < ruleNumber; i++) {
  
        // iterate over all segments/motifs/sub-sequences which correspond
        // to the rule
        ArrayList<RuleInterval> arrPos = grammarRules.getRuleRecord(i).getRuleIntervals();
        for (RuleInterval saxPos : arrPos) {
          SAXMotif motif = new SAXMotif();
          motif.setPos(saxPos);
          motif.setRuleIndex(i);
          motif.setClassified(false);
          allMotifs.add(motif);
        }
  
      }
  
      // ascending order
      Collections.sort(allMotifs);
      return allMotifs;
    }
docs: Stores all the sub-sequences that generated by Sequitur rules into an array list sorted by
  sub-sequence length in ascending order.
  
  @param grammarRules the set of grammar rules.
  @return the list of all sub-sequences sorted by length in ascending order.