Commit af3a9c39 authored by kai.b's avatar kai.b
Browse files

removed trimming option that was under construciton

parent 7d66ebd8
Loading
Loading
Loading
Loading

BarcodeRecovery.pl

deleted100644 → 0
+0 −73
Original line number Diff line number Diff line
#!/usr/bin/perl

#########################################
#                                       #
#     Written by Kai Battenberg         #
#     Plant Symbiosis Research Team     #
#                                       #
#########################################

use strict;
use warnings;

#####Options#####
my $barcodefile = $ARGV[0];
my $adjust_length = $ARGV[1];
my $cellranger_dir = $ARGV[2];
##########



#####Main#####
#make a hash of original and adjusted barcodes
my %barcodes;
open (ORIGINAL, "<$barcodefile") or die "cannot open $barcodefile.\n";
while (my $line = <ORIGINAL>) {
    my $original = $line;
    $original =~ s/\r//sig;
    $original =~ s/\n//sig;
    
    my $adjusted = $original;
    if ($adjust_length >= 0) {
        my $length = $adjust_length;
        $adjusted = substr ($length, 0, $adjusted);
    }
    else {
        my $length = abs ($adjust_length);
        my $As = "A" x $length;
        $adjusted = $As.$adjusted;
    }
    
    $barcodes{$adjusted} = $original;
}
close (ORIGINAL);

#get modified barcode list (raw)
my $raw_file = $cellranger_dir."/outs/raw_feature_bc_matrix/barcodes.tsv.gz";
my $modified_barcodes_raw = `zcat $raw_file | cut -f1 -d'-'`;
$modified_barcodes_raw =~ s/\n$//;
my @modified_barcodes_raw = split (/\n/, $modified_barcodes_raw);

#get modified barcode list (filtered)
my $filtered_file = $cellranger_dir."/outs/filtered_feature_bc_matrix/barcodes.tsv.gz";
my $modified_barcodes_filtered = `zcat $filtered_file | cut -f1 -d'-'`;
$modified_barcodes_filtered =~ s/\n$//;
my @modified_barcodes_filtered = split (/\n/, $modified_barcodes_filtered);

#replace barcodes
my $temp = "barcodes.txt";
open (TEMP, ">$temp") or die "cannot open $temp.\n";
foreach my $barcode (@modified_barcodes_raw) {
    print TEMP "$barcodes{$barcode}-1\n";
}
close (TEMP);
system "gzip -c $temp > $raw_file";

open (TEMP, ">$temp") or die "cannot open $temp.\n";
foreach my $barcode (@modified_barcodes_filtered) {
    print TEMP "$barcodes{$barcode}-1\n";
}
close (TEMP);
system "gzip -c $temp > $filtered_file";
unlink ($temp);
##########
+2 −8
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@
install=false

######convert version#####
convertversion="0.3.0.90007"
convertversion="0.3.0.90008"
##########


@@ -43,7 +43,7 @@ if [[ $RDIR != $SDIR ]]; then
fi
echo "Running launch_universc.sh in '$SDIR'"

BARCODERECOVER=${SDIR}/BarcodeRecovery.pl
BARCODERECOVER=${SDIR}/RecoverBarcodes.pl
PERCELLSTATS=${SDIR}/ExtractBasicStats.pl
##########

@@ -69,7 +69,6 @@ Mandatory arguments to long options are mandatory for short options too.
  -R2, --read2 FILE             Read 2 FASTQ file to pass to cellranger
  -f,  --file NAME              Path and the name of FASTQ files to pass to cellranger (prefix before R1 or R2)
                                e.g. /path/to/files/Example_S1_L001
  --trim                        run adapter and quality trimming on R2 files prior to running cellranger (underconstruction)
  
  -i,  --id ID                  A unique run id, used to name output folder
  -d,  --description TEXT       Sample description to embed in output files.
@@ -207,11 +206,6 @@ for op in "$@"; do
                exit 1
            fi
            ;;
        --trim)
            trim=true
            next=false
            shift
            ;;
       -i|--id)
            shift
            if [[ "$1" != "" ]]; then