This is a test version of Biostars. For the public version, visit https://www.biostars.org.
BBMap randomreads.sh exact path to ref error: Could not find or load main class

I am trying to create synthetic reads from a fasta reference using BBMap's randomreads. Using this command from within the BBMap /sh directory:

[cmp07 sh]$ java -ea -Xmx23g -cp /home/mina/tools/BBMap-master/current/align2/RandomReads3.java ref=/home/mina/reference-genomes/N1a1.fasta reads=1258301 length=301 overwrite=f seed=-1 snprate=0.001 maxq=40 midq=30 minq=10 overlap=50

Unfortunately this produces and error:

Error: Could not find or load main class ref=.home.mina.reference-genomes.N1a1.fasta

How do I provide the path to my reference fasta file? Is there something I am missing about how to use this tool? Why are the slashes being converted to dots in the file path in the error message?

bbmap java

If you are not using this program on WIndows, I suggest that you just use randomreads.sh the wrapper script to run this.

@genomax I had tried running randomreads.sh as well using this command:

[cmp07 sh]$ ./randomreads.sh ref=/home/mina/reference-genomes/N1a1.fasta reads=1258301 length=301 overwrite=f seed=-1 length=301 overwrite=f seed=-1 snprate=0.001 maxq=40 midq=30 minq=10 overlap=50

Unfortunately that method give me this error message:

 Error: Could not find or load main class align2.RandomReads3

Which led me to believe that I needed to run it using the original version of the command I asked about.

Have you moved any of the folder contents after downloading BBMap suite?

No, I have not moved any of the folder contents. My first thought is to add the full path to the randomreads.sh script but after trying that still I get an error message. Any ideas on what I could do?

Are you running the latest BBMap version? I just tried your command with BBmap v. 38.22 and was able to get an output file. You seem to be missing out=file.fq.gz in your command line but that should not cause the error you see.

Very good point genomax. I realized I wasn't running the latest version. I downloaded version 38.32 and untarred/zipped the file. Now when running randomreads.sh I get a different error:

[cmp07 bbmap]$ ./randomreads.sh ref = /home/mina/reference-genomes/N1a1.fasta out=/home/mina/reference-genomes/N1a1_synth.fastq length = 171 reads = 1258301 overwrite = f seed = -1 snprate = 0.001 maxq = 40 midq = 30 minq = 10
java -ea -Xmx106951m -cp /home/mina/bbmap/current/ align2.RandomReads3 build=1 ref = /home/mina/reference-genomes/N1a1.fasta out=/home/mina/reference-genomes/N1a1_synth.fastq length = 171 reads = 1258301 overwrite = f seed = -1 snprate = 0.001 maxq = 40 midq = 30 minq = 10
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
        at shared.PreParser.<init>(PreParser.java:74)
        at shared.PreParser.<init>(PreParser.java:31)
        at align2.RandomReads3.main(RandomReads3.java:39)

Are you using 64-bit java on a 64-bit OS?

java -version
openjdk version "1.8.0_191"
OpenJDK Runtime Environment (build 1.8.0_191-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)

I tried your command line with human genome on my machine (albeit with 10G of RAM) and I am able to get an output file without any issues.

Can you try (I assume you have 10G of free memory available):

./randomreads.sh -Xmx10g ref = /home/mina/reference-genomes/N1a1.fasta out=/home/mina/reference-genomes/N1a1_synth.fastq length = 171 reads = 1258301 overwrite = f seed = -1 snprate = 0.001 maxq = 40 midq = 30 minq = 10

I tried your change and still get this error:

[cmp07 bbmap]$ ./randomreads.sh -Xmx10g ref = /home/mina/reference-genomes/N1a1.fasta out= /home/mina/reference-genomes/N1a1-synth.fastq length = 171 reads = 1258301 overwrite = f seed = -1 snprate = 0.001 maxq = 40 midq = 30 minq = 10

java -ea -Xmx10g -cp /home/mina/tools/bbmap/current/ align2.RandomReads3 build=1 -Xmx10g ref = /home/mina/reference-genomes/N1a1.fasta out= /home/mina/reference-genomes/N1a1-synth.fastq length = 171 reads = 1258301 overwrite = f seed = -1 snprate = 0.001 maxq = 40 midq = 30 minq = 10

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
        at shared.PreParser.<init>(PreParser.java:74)
        at shared.PreParser.<init>(PreParser.java:31)
        at align2.RandomReads3.main(RandomReads3.java:39)

Is N1a1.fasta bigger or smaller than human genome?

N1a1.fastq is much smaller. It is a human mitochondrial genome so ~16.5K base pairs long.

Can you try reducing number of reads to 10000 and see if that works? Since the genome is so small bbmap may be running out sequence in trying to generate the number of reads you are asking of 171 bp length.

I tried reducing the number of reads to 10000 and unfortunately it gave me the same error message referencing the ArrayIndexOutOfBounds Exception.

Not sure what to tell you. I downloaded human mitochondrial genome (~17kb) and tried your original command as well as one for 10,000 reads and both worked without error.

I am using version 38.32 which I downloaded and untarred today. I downloaded this from https://sourceforge.net/projects/bbmap/ . If there is a different version I should be using, please let me know where to find it.

1 answer

I finally figured out the issue. I had a space before and or after the = signs in the command. When I removed all spaces around the = signs, the tool worked as expected.

I did download and install the latest version today which was 38.34.

Thank you to @genomax and @Pierre Lindenbaum for their efforts in troubleshooting this for me.

Log in to answer this question.