Skip to content

Commit 0f96b46

Browse files
author
sprokopec
committed
added UMI extraction for capHLA
1 parent da37516 commit 0f96b46

File tree

1 file changed

+41
-3
lines changed

1 file changed

+41
-3
lines changed

scripts/trim_adapters.pl

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,26 @@ sub get_fastp_command {
7979
return($trim_command);
8080
}
8181

82+
# format command to run custom UMI trimming (ConcensusCruncher)
83+
sub get_extractUMI_command {
84+
my %args = (
85+
r1 => undef,
86+
r2 => undef,
87+
stem => undef,
88+
@_
89+
);
90+
91+
my $trim_command = join(' ',
92+
'python3 /cluster/projects/pughlab/src/ConsensusCruncher/scripts/extract_barcodes.py',
93+
'--blist /cluster/projects/pughlab/src/UMI-tools/idt_dual_index_barcodes.txt',
94+
'--read1', $args{r1},
95+
'--read2', $args{r2},
96+
'--outfile', $args{stem}
97+
);
98+
99+
return($trim_command);
100+
}
101+
82102
### MAIN ###########################################################################################
83103
sub main {
84104
my %args = (
@@ -138,16 +158,22 @@ sub main {
138158
print $log "\n Tool config used: $tool_config";
139159
print $log "\n Output directory: $output_directory";
140160
print $log "\n Sample config used: $data_config";
141-
print $log "\n---";
142161

143162
# set tools and versions
144163
my $trim_tool = '';
145-
if (defined($tool_data->{baits_bed})) {
164+
if ('caphla' eq $tool_data->{seq_type}) {
165+
print $log "\n\n Trimming using tool: ConsensusCruncher";
166+
$trim_tool = 'python3/3.7.2';
167+
} elsif (defined($tool_data->{baits_bed})) {
168+
print $log "\n\n Trimming using tool: trim_galore";
146169
$trim_tool = 'trim_galore/' . $tool_data->{trim_galore_version};
147170
} else {
171+
print $log "\n\n Trimming using tool: fastq";
148172
$trim_tool = 'fastp/' . $tool_data->{fastp_version};
149173
}
150174

175+
print $log "\n---";
176+
151177
# get user-specified tool parameters
152178
my $parameters = $tool_data->{trim_adapters}->{parameters};
153179

@@ -209,7 +235,18 @@ sub main {
209235
my $output_stem = join('/', $output_directory, $stem);
210236
my ($trim_command, $new_r1, $new_r2);
211237

212-
if (defined($tool_data->{baits_bed})) {
238+
if ('caphla' eq $tool_data->{seq_type}) {
239+
240+
$trim_command = get_extractUMI_command(
241+
r1 => $r1,
242+
r2 => $r2,
243+
stem => $output_stem
244+
);
245+
246+
$new_r1 = $output_stem . '_barcode_R1.fastq';
247+
$new_r2 = $output_stem . '_barcode_R2.fastq';
248+
249+
} elsif (defined($tool_data->{baits_bed})) {
213250

214251
$trim_command = get_trim_galore_command(
215252
r1 => $r1,
@@ -223,6 +260,7 @@ sub main {
223260
$new_r2 = join('/', $output_directory, basename($r2));
224261
$new_r2 =~ s/.fastq.gz/_val_2.fq.gz/;
225262

263+
226264
} else {
227265

228266
$trim_command = get_fastp_command(

0 commit comments

Comments
 (0)