public void add ( LCMSRange range ) { Integer msLevel = range . getMsLevel ( ) ; DoubleRange mzRange = range . getMzRange ( ) ; Range < Integer > scanRange = range . getScanRange ( ) ; if ( msLevel == null ) { // add to the top level range set anyLvlSet . add ( scanRange ) ; // remove from all underlying sets for ( Map . Entry < Integer , MsLevelRangeSet > lvlMapEntry : lvlMap . entrySet ( ) ) { MsLevelRangeSet msLevelRangeSet = lvlMapEntry . getValue ( ) ; msLevelRangeSet . removeFromAll ( range ) ; } return ; } TreeRangeSet < Integer > scanRangeLeft = TreeRangeSet . create ( ) ; scanRangeLeft . removeAll ( anyLvlSet ) ; if ( scanRangeLeft . isEmpty ( ) ) { return ; // if there's nothing left in the scan range, just stop } MsLevelRangeSet msLvlRanges = lvlMap . get ( msLevel ) ; if ( msLvlRanges == null ) { msLvlRanges = new MsLevelRangeSet ( ) ; lvlMap . put ( msLevel , msLvlRanges ) ; } if ( mzRange == null ) { // add to any-mz-range range set msLvlRanges . anyPrecursorSet . addAll ( scanRangeLeft ) ; // remove from all specific mz-range sets msLvlRanges . removeFromSpecific ( range ) ; return ; } scanRangeLeft . removeAll ( msLvlRanges . anyPrecursorSet ) ; if ( scanRangeLeft . isEmpty ( ) ) { return ; } RangeSet < Integer > rangeSetForMzRange = msLvlRanges . rngMap . get ( mzRange ) ; if ( rangeSetForMzRange == null ) { rangeSetForMzRange = TreeRangeSet . create ( ) ; msLvlRanges . rngMap . put ( mzRange , rangeSetForMzRange ) ; } rangeSetForMzRange . addAll ( scanRangeLeft ) ; }
This add method gradually removes scan - ranges from the input range as it descends down the hierarchy .