I'm running into a problem that I simply cannot wrap my head around. As part of my job, I need to run the fastaFromBed application of the "betdools" package, and that only works under Linux. We have an Ubuntu server here that I can run the programme on, but I need to call it from within a larger Java application, and I'm finding myself completely unable to do so, because fastaFromBed apparently fails to recognise input no matter what I do. I've simplified everything down to the very basics and I'm still running into a wall. Here's what I'm trying to do:
private void fastaFromBed() { try { ProcessBuilder builder = new ProcessBuilder("fastaFromBed -fi " + this.fastaFile.getAbsolutePath() + " -bed " + this.outputFile.getAbsolutePath() + " -fo test.fa"); builder.redirectErrorStream(true); Process fastaFromBed = builder.start(); BufferedReader reader = new BufferedReader(new InputStreamReader(fastaFromBed.getInputStream())); String line = reader.readLine(); while(line != null) { System.out.println(line); line = reader.readLine(); } fastaFromBed.destroy(); } catch(Exception exception) { exception.printStackTrace(); } }
All of the this.variables have values to them, I made sure in the larger class file, and they have the RIGHT values. For some reason, however, fastaFromBed does not recognise them. As a point of fact, it gives me this vexing output:
*****ERROR: Unrecognized parameter: -fi ***** *****ERROR: Unrecognized parameter: /home/malidictus/RuddTomato/genomic_fasta.fa ***** *****ERROR: Unrecognized parameter: -bed ***** *****ERROR: Unrecognized parameter: /home/malidictus/RuddTomato/temp/mixed_tomato_sorted.txt.output.gff3.fixed.gff ***** *****ERROR: Unrecognized parameter: -fo ***** *****ERROR: Unrecognized parameter: test.fa ***** Program: fastaFromBed (v2.12.0) Author: Aaron Quinlan (...) Summary: Extract DNA sequences into a fasta file based on feature coordinates. Usage: fastaFromBed [OPTIONS] -fi <fasta> -bed <bed/gff/vcf> -fo <fasta> Options: -fi Input FASTA file -bed BED/GFF/VCF file of ranges to extract from -fi -fo Output file (can be FASTA or TAB-delimited) -name Use the name field for the FASTA header -tab Write output in TAB delimited format. - Default is FASTA format. -s Force strandedness. If the feature occupies the antisense strand, the sequence will be reverse complemented. - By default, strand information is ignored.
It asks for -fi as a console argument yet does not recognise it. It asks for -bed and doesn't recognise that. It doesn't recognise its own parameters! That's only through Java, however. Running this through the actual linux console works, but trying to run it from Java bombs. Why? I thought it might have something with how I tokenize the input, but I tried everything I could think of. I gave it all as a single string and that bombed - linux interpreted it all as one file. I tried splitting it into two tokens - the programme and all the parameters, but then fastaFromBed read them all as one parameter and didn't recognise them. I then tried what I showed you - to break everything up into individual tokens and THAT didn't work because it still doesn't recognise it.
I'm out of ideas at this point. What does it all mean?