-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathoverlap_mpileup_tped.pl
More file actions
42 lines (31 loc) · 977 Bytes
/
overlap_mpileup_tped.pl
File metadata and controls
42 lines (31 loc) · 977 Bytes
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
#!/usr/bin/perl
use strict;
my $tped = $ARGV[0];
my $mpile = $ARGV[1];
my %tped_hash;
my $line;
my @fields;
my $key;
open(TPEDFILE, "$tped");
#### Making the hash
while(<TPEDFILE>)
{
chomp($_);
@fields=split(/\t/,$_);
$key=$fields[0] ."_".$fields[3]; ## Make a hash where the key is the chr and the position coordinates
$tped_hash{$key}=$_; ## And the value is the line itself
}
close(TPEDFILE);
#### Scan the hash with mpileup file
my $chr;
open(MPILEUP, $mpile);
while(<MPILEUP>)
{
chomp($_);
@fields=split(/\t/,$_); ## The mpileup file is scanned the key is built with the chromosome and position coordinates
$fields[0] =~ s/chr//g; ## The hash built in the first loop is queried and the SNP coordinates (the map file line)
$key=$fields[0] ."_".$fields[1]; ## are printed followed by the homozygous allele
print $tped_hash{$key};
print "\t",uc($fields[6])," ",uc($fields[6]),"\n";
}
exit;