Skip to content

Commit

Permalink
Add CRAM reference to the options in the wrapper.
Browse files Browse the repository at this point in the history
Relates to #54
  • Loading branch information
Andrewss authored and Andrewss committed Aug 18, 2020
1 parent 36d48a4 commit 26f7005
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
19 changes: 17 additions & 2 deletions fastqc
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ if ($^O =~/darwin/) {
my $version;
my $help;
my $outdir;
my $reference;
my $unzip;
my $format;
my $contaminant;
Expand All @@ -110,6 +111,7 @@ my $result = GetOptions('version' => \$version,
'nogroup' => \$nogroup,
'expgroup' => \$expgroup,
'outdir=s' => \$outdir,
'reference=s' -> \$reference,
'extract!' => \$unzip,
'format=s' => \$format,
'threads=i' => \$threads,
Expand Down Expand Up @@ -146,6 +148,14 @@ if ($outdir) {
push @java_args ,"-Dfastqc.output_dir=$outdir";
}

if ($reference) {
unless(-e $reference and -f $reference) {
die "Specified reference file '$reference' does not exist\n";
}

push @java_args ,"-Dfastqc.reference=$reference";
}

if ($contaminant) {
unless (-e $contaminant and -r $contaminant) {
die "Contaminant file '$contaminant' did not exist, or could not be read\n";
Expand Down Expand Up @@ -387,7 +397,12 @@ DESCRIPTION
-f --format Bypasses the normal sequence file format detection and
forces the program to use the specified format. Valid
formats are bam,sam,bam_mapped,sam_mapped and fastq
formats are bam,sam,cram,bam_mapped,sam_mapped,cram_mapped
and fastq
-r --reference Only relevant when parsing CRAM files. Specifies a fasta format
file of reference sequences which can be used to decode the
CRAM entries.
-t --threads Specifies the number of files which can be processed
simultaneously. Each thread will be allocated 250MB of
Expand Down Expand Up @@ -427,6 +442,6 @@ DESCRIPTION
BUGS
Any bugs in fastqc should be reported either to simon.andrews@babraham.ac.uk
or in www.bioinformatics.babraham.ac.uk/bugzilla/
or in https://github.com/s-andrews/fastqc/issues
11 changes: 10 additions & 1 deletion uk/ac/babraham/FastQC/FastQCConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class FastQCConfig {
public Integer threads = null;
public boolean showUpdates = true;
public File output_dir = null;
public File reference = null;
public boolean casava = false;
public boolean nano = false;
public boolean nofilter = false;
Expand All @@ -52,7 +53,15 @@ private FastQCConfig () {
throw new IllegalArgumentException("Output dir "+output_dir+" doesn't exist or isn't writeable");
}
}


// CRAM Reference
if (System.getProperty("fastqc.reference") != null) {
reference = new File(System.getProperty("fastqc.reference"));
if (!(reference.exists() && reference.canRead())) {
throw new IllegalArgumentException("Reference file "+reference+" doesn't exist or can't be read");
}
}

// Contaminant file
if (System.getProperty("fastqc.contaminant_file") != null) {
contaminant_file = new File(System.getProperty("fastqc.contaminant_file"));
Expand Down
8 changes: 7 additions & 1 deletion uk/ac/babraham/FastQC/Sequence/BAMFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import htsjdk.samtools.SamReader;
import htsjdk.samtools.SamReaderFactory;
import htsjdk.samtools.ValidationStringency;
import uk.ac.babraham.FastQC.FastQCConfig;


public class BAMFile implements SequenceFile {
Expand Down Expand Up @@ -63,7 +64,12 @@ protected BAMFile (File file, boolean onlyMapped) throws SequenceFormatException

SamInputResource sir = SamInputResource.of(fis);

br = SamReaderFactory.makeDefault().validationStringency(ValidationStringency.SILENT).referenceSequence(new File("c:/Users/andrewss/Desktop/phix-illumina.fa")).open(sir);
if (FastQCConfig.getInstance().reference != null) {
br = SamReaderFactory.makeDefault().validationStringency(ValidationStringency.SILENT).referenceSequence(FastQCConfig.getInstance().reference).open(sir);
}
else {
br = SamReaderFactory.makeDefault().validationStringency(ValidationStringency.SILENT).open(sir);
}

it = br.iterator();
readNext();
Expand Down

0 comments on commit 26f7005

Please sign in to comment.