int [ ] [ ] findNeighborIndices ( ) { // looking at a typical protein case, number of neighbours are from ~10 to ~50, with an average of ~30 int initialCapacity = 60 ; int [ ] [ ] nbsIndices = new int [ atomCoords . length ] [ ] ; for ( int k = 0 ; k < atomCoords . length ; k ++ ) { double radius = radii [ k ] + probe + probe ; List < Integer > thisNbIndices = new ArrayList <> ( initialCapacity ) ; for ( int i = 0 ; i < atomCoords . length ; i ++ ) { if ( i == k ) continue ; double dist = atomCoords [ i ] . distance ( atomCoords [ k ] ) ; if ( dist < radius + radii [ i ] ) { thisNbIndices . add ( i ) ; } } int [ ] indicesArray = new int [ thisNbIndices . size ( ) ] ; for ( int i = 0 ; i < thisNbIndices . size ( ) ; i ++ ) indicesArray [ i ] = thisNbIndices . get ( i ) ; nbsIndices [ k ] = indicesArray ; } return nbsIndices ; }
Returns the 2 - dimensional array with neighbor indices for every atom .