private int getClosestDataDiff ( IsotopeContainer isoContainer , IsotopePattern pattern ) { double diff = 100 ; int posi = - 1 ; for ( int i = 0 ; i < pattern . getNumberOfIsotopes ( ) ; i ++ ) { double tempDiff = Math . abs ( ( isoContainer . getMass ( ) ) - pattern . getIsotopes ( ) . get ( i ) . getMass ( ) ) ; if ( tempDiff <= ( tolerance_ppm / isoContainer . getMass ( ) ) && tempDiff < diff ) { diff = tempDiff ; posi = i ; } } return posi ; }
Search and find the closest difference in an array in terms of mass and intensity . Always return the position in this List .