Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
463145cfd6
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
142 lines (119 sloc) 3.33 KB
#!/usr/bin/perl
use warnings;
use strict;
use Getopt::Long();
sub usage($);
sub version($);
sub createBatchJob($);
sub runCellranger($$$$);
MAIN:
{
# define inputs
my $version_tag = "version 1.0, October 2018";
my $version;
my $help;
my $path_fastq;
my $path_genome_index;
my $path_output;
my $opts_cellranger;
# set-up paramters
Getopt::Long::GetOptions(
"f|fastq=s" => \$path_fastq,
"o|output-dir=s" => \$path_output,
"g|genome=s" => \$path_genome_index,
"p|opts=s" => \$opts_cellranger,
"h|help" => \$help,
"v|version" => \$version
) or usage("Error::invalid command line options");
# parse inputs
version($version_tag) if($version);
usage($version_tag) if($help);
usage("Error::path to FastQ files is required") unless defined($path_fastq);
usage("Error::path to output location is required") unless defined($path_output);
usage("Error::path to genome index is required") unless defined($path_genome_index);
# create batch job
my $batch_job = createBatchJob($path_fastq);
# run cellranger count
runCellranger($batch_job, $path_output, $path_genome_index, $opts_cellranger);
}
sub runCellranger($$$$)
{
my $batch_job = $_[0];
my $path_output = $_[1];
my $path_genome_index = $_[2];
my $opts_cellranger = $_[3];
foreach my $id (sort keys %{$batch_job})
{
my $command = "cellranger count" .
" --id=" . $id .
" --fastqs=" . $batch_job->{$id} .
" --transcriptome=" . $path_genome_index .
" --sample=" . $id;
$command .= " " . $opts_cellranger if (defined($opts_cellranger));
print $command,"\n";
#system($command);
# move result to output folder
if (-d $id)
{
$path_output =~ s/\/$//g;
$command = "mv " . $id . " " . $path_output . '/' . $id;
print $command,"\n";
#system($command);
}
}
}
sub createBatchJob($)
{
my $path_fastq = $_[0];
my %tags = ();
$path_fastq =~ s/\/$//g;
opendir(my $dh, $path_fastq);
while (my $path_tag = readdir $dh)
{
my $path_full = $path_fastq . '/' . $path_tag;
next unless -d $path_full;
next if ($path_tag =~ m/^\./);
$tags{$path_tag} = $path_full;
}
closedir($dh);
return \%tags;
}
sub usage($)
{
my $message = $_[0];
if (defined $message && length($message))
{
$message .= "\n" unless($message =~/\n$/);
}
my $command = $0;
$command =~ s#^.*/##;
print STDERR (
$message,
"usage: $command\n" .
"-f|--fastq\n" .
"\t path to FastQ files (required)\n" .
"-o|--output-dir\n" .
"\t path to output directory (required)\n" .
"-g|--genome\n" .
"\t path to genome index (required)\n" .
"-p|--opts\n" .
"\t additional Cellranger Count parameters\n" .
"-h|--help\n" .
"\t print help message\n" .
"-v|--version\n" .
"\t print current version\n"
);
die("\n");
}
sub version($)
{
my $message = $_[0];
print STDERR (
$message,"\n",
"Scientific Computing Facility\n",
"Max-Planck Institute For Brain Research\n",
"bug reports to:\n",
"\tsciclist\@brain.mpg.de\n"
);
die("\n");
}