SimpleFastaCmd implements FastaCmd { private BioSequence getSingle( Object key, String database, String blastHome ) throws IOException { if ( blastHome == null ) { blastHome = SimpleFastaCmd.blastDbHome; } String[] opts = new String[] { "BLASTDB=" + blastHome }; String command = SimpleFastaCmd.fastaCmdExecutable + " -long_seqids -target_only -" + dbOption + " " + database + " -" + queryOption + " " + key; Process pr = Runtime.getRuntime().exec( command, opts ); log.info( StringUtils.join( opts, " " ) ); SimpleFastaCmd.log.info( command ); Collection<BioSequence> sequences = this.getSequencesFromFastaCmdOutput( pr ); if ( sequences.size() == 0 ) { return null; } if ( sequences.size() == 1 ) { return sequences.iterator().next(); } throw new IllegalStateException( "Got more than one sequence!" ); } 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 testGetSingle() { if ( this.fastaCmdExecutableNotExists() ) { return; } SimpleFastaCmd fastaCmd = new SimpleFastaCmd(); BioSequence bs = fastaCmd.getByIdentifier( 1435867, SimpleFastaCmdTest.TESTBLASTDB, testBlastDbPath ); assertNotNull( bs ); String expected = "CCACCTTTCCCTCCACTCCTCACGTTCTCACCTGTAAAGCGTCCCTCCCTCATCCCCATGCCCCCTTACCCTGCAGGGTA" + "GAGTAGGCTAGAAACCAGAGAGCTCCAAGCTCCATCTGTGGAGAGGTGCCATCCTTGGGCTGCAGAGAGAGGAGAATTTG" + "CCCCAAAGCTGCCTGCAGAGCTTCACCACCCTTAGTCTCACAAAGCCTTGAGTTCATAGCATTTCTTGAGTTTTCACCCT" + "GCCCAGCAGGACACTGCAGCACCCAAAGGGCTTCCCAGGAGTAGGGTTGCCCTCAAGAGGCTCTTGGGTCTGATGGCCAC" + "ATCCTGGAATTGTTTTCAAGTTGATGGTCACAGCCCTGAGGCATGTAGGGGCGTGGGGATGCGCTCTGCTCTGCTCTCCT" + "CTCCTGAACCCCTGAACCCTCTGGCTACCCCAGAGCACTTAGAGCCAG"; assertEquals( expected, bs.getSequence() ); }