public static Map < BioPAXElement , List < Match > > search ( final Collection < ? extends BioPAXElement > eles , final Pattern pattern ) { final Map < BioPAXElement , List < Match > > map = new ConcurrentHashMap < BioPAXElement , List < Match > > ( ) ; final ExecutorService exec = Executors . newFixedThreadPool ( 10 ) ; for ( final BioPAXElement ele : eles ) { if ( ! pattern . getStartingClass ( ) . isAssignableFrom ( ele . getModelInterface ( ) ) ) continue ; exec . execute ( new Runnable ( ) { @ Override public void run ( ) { List < Match > matches = search ( ele , pattern ) ; if ( ! matches . isEmpty ( ) ) { map . put ( ele , matches ) ; } } } ) ; } exec . shutdown ( ) ; try { exec . awaitTermination ( 10 , TimeUnit . MINUTES ) ; } catch ( InterruptedException e ) { throw new RuntimeException ( "search, failed due to exec timed out." , e ) ; } return Collections . unmodifiableMap ( new HashMap < BioPAXElement , List < Match > > ( map ) ) ; }
Searches the given pattern starting from the given elements .