Skip to content

Commit

Permalink
Merge pull request #444 from sanger-pathogens/farm5_snps
Browse files Browse the repository at this point in the history
Added some missing scripts to bin for snps pipeline
  • Loading branch information
kpepper authored Apr 21, 2020
2 parents d2ea2cb + ea2227c commit 42bf905
Show file tree
Hide file tree
Showing 4 changed files with 894 additions and 0 deletions.
48 changes: 48 additions & 0 deletions bin/make_indel_mask.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env perl
#
# usage: make_indel_mask.pl indel.calls.bed mask_size indels.mask.bed
#
# Author: Sendu Bala <[email protected]>
# PODNAME: bobby_tables.pl at /usr/local/share/perl/5.14.2/Pod/Weaver.pm line 73.

use strict;
use warnings;

use File::Spec;
use File::Basename;

# get user input
my ($in_bed, $mask_size, $out_bed) = @ARGV;
chomp($out_bed);

($in_bed && -e $in_bed && $mask_size && $out_bed) or die <<USAGE;
Creates a mask version of a bed file.
Usage: $0 indel.calls.bed mask_size indels.mask.bed
where indel.calls.bed is the input bed file, mask_size is the size in bases
(eg. 10), and indels.mask.bed is the output file
USAGE

open(my $ifh, $in_bed) || die "Could not open $in_bed\n";
open(my $ofh, '>', $out_bed) || die "Could not write to $out_bed\n";
$mask_size = int($mask_size);
$mask_size >= 1 || die "Invalid mask_size '$mask_size' (should be int >= 1)\n";


# covert to mask
while (<$ifh>) {
# chr1 71996 72005 -AAAAAAAAA:4/6
my ($chr, $start, $stop, $notes) = split;

$start -= $mask_size;
$stop += $mask_size;
$notes .= ":+/-$mask_size" ;

print $ofh join("\t", $chr, $start, $stop, $notes), "\n";
}
close($ifh);
close($ofh);

exit;
Loading

0 comments on commit 42bf905

Please sign in to comment.