SimpleFastaCmd implements FastaCmd { private Collection<BioSequence> getMultiple( Collection<?> keys, String database, String blastHome ) throws IOException { if ( StringUtils.isBlank( SimpleFastaCmd.fastaCmdExecutable ) ) throw new IllegalStateException( "No fastacmd executable: You must set " + SimpleFastaCmd.FASTA_CMD_ENV_VAR + " in your environment." ); if ( blastHome == null ) { throw new IllegalArgumentException( "No blast database location specified, you must set this in your environment" ); } File tmp = File.createTempFile( "sequenceIds", ".txt" ); try (Writer tmpOut = new FileWriter( tmp )) { for ( Object object : keys ) { if ( object instanceof String ) { String acc = object.toString().replaceFirst( "\\.[0-9]+", "" ); tmpOut.write( acc + "\n" ); } else { tmpOut.write( object.toString() + "\n" ); } } } String[] opts = new String[] { "BLASTDB=" + blastHome }; String command = SimpleFastaCmd.fastaCmdExecutable + " -long_seqids -target_only -" + dbOption + " " + database + " -" + entryBatchOption + " " + tmp.getAbsolutePath(); SimpleFastaCmd.log.info( command ); Process pr; SimpleFastaCmd.log.info( "BLASTDB=" + blastHome ); pr = Runtime.getRuntime().exec( command, opts ); return this.getSequencesFromFastaCmdOutput( pr ); } SimpleFastaCmd(); @Override BioSequence getByAccession( String accession, String database ); @Override BioSequence getByIdentifier( int identifier, String database ); @Override Collection<BioSequence> getBatchAccessions( Collection<String> accessions, String database ); @Override Collection<BioSequence> getBatchIdentifiers( Collection<Integer> identifiers, String database ); @Override BioSequence getByAccession( String accession, String database, String blastHome ); @Override BioSequence getByIdentifier( int identifier, String database, String blastHome ); @Override Collection<BioSequence> getBatchAccessions( Collection<String> accessions, String database,
            String blastHome ); @Override Collection<BioSequence> getBatchIdentifiers( Collection<Integer> identifiers, String database,
            String blastHome ); static final String FASTA_CMD_ENV_VAR; }
@Test public void testGetMultiple() { if ( this.fastaCmdExecutableNotExists() ) { return; } SimpleFastaCmd fastaCmd = new SimpleFastaCmd(); Collection<Integer> input = new ArrayList<>(); input.add( 1435867 ); input.add( 1435868 ); Collection<BioSequence> bs = fastaCmd .getBatchIdentifiers( input, SimpleFastaCmdTest.TESTBLASTDB, testBlastDbPath ); assertNotNull( bs ); assertEquals( 2, bs.size() ); }