-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTrimCountsInput.pl
72 lines (54 loc) · 1.57 KB
/
TrimCountsInput.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/perl
use strict;
##################################################
###### Details ######
##################################################
# author: Steven Yates
# contact: [email protected]
# Year: 2020
# Citation: TBA
##################################################
###### Description ######
##################################################
# Perl script for filtering the count data based on
# reads which align
# its’ arguments are the filtered ‘sam’ file and
# the count data
# output is written to standard output,
# so needs piping to file
##################################################
###### Usage ######
##################################################
# perl TrimCountsInput.pl filter.sam Count.data > filter.data
##################################################
###### Script ######
##################################################
my @files; #also sample IDs
my %haps;
my $counter = 0;
### read in the SAM file
open(INPUT, @ARGV[0]) or die "could not open file";
while (<INPUT>)
{
chomp;
my $line =$_;
my @data = split("\t",$line);
#print $data[0];
$data[0] =~ s/@//;
$haps{$data[0]} = 0;
}
close(INPUT);
# now read the counts file
open(COUNT, @ARGV[1]) or die "could not open file";
while (<COUNT>)
{
chomp;
my $line =$_;
if ($counter == 0) {print $line, "\n"};
$counter++;
my @data = split("\t",$line);
$data[0] =~ s/@//;
#print $data[0],"\n";
if (exists($haps{$data[0]})) { print $line,"\n";}
}
close(COUNT);