-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsnprelat2evec
51 lines (35 loc) · 960 Bytes
/
snprelat2evec
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
#!/usr/bin/perl
# Converts files that are produced by the SNPRelat R package
# into the same format that eigenstrat produces
my $out;
$len=(@ARGV);
if ($len==0) {
print "Usage: ".
" snprelat2evec INPUT \n".
" snprelat2evec INPUT OUTPUT\n".
" \n".
" INPUT is the file name of a file produced by SNRelat\n".
" If no output file is given, output is to standard output.\n".
" If OUTPUT is given a file with that name is created, deleting any existing file with that name.\n";
}
$finp = $ARGV[0];
if ($len == 1) {
$out = *STDOUT;
}
if ($len == 2) {
$fout=$ARGV[1];
open($out,">$fout");
}
open(INP,$finp);
while ($line = <INP>) {
if (substr($line,0,1) eq "#") {
print $out $line;
next;
}
if ($line =~ /\s*\w+\s+(\w+)(\s+|-)(\w+)\s+(.*)/) {
} else {
print "No match:$line\n";
}
print $out "$1:$3\t$4\n";
}
close($out);