forked from chiulab/surpi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_tab_delimited_table.pl
executable file
·66 lines (52 loc) · 1.38 KB
/
create_tab_delimited_table.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
#!/usr/bin/perl
#
# create_tab_delimited_table.pl
#
# This program will return a simpler version of a SNAP or RAP output file that has been produced via the SURPI pipeline.
# Chiu Laboratory
# University of California, San Francisco
# January, 2014
#
# Copyright (C) 2014 Scot Federman - All Rights Reserved
# SURPI has been released under a modified BSD license.
# Please see license file for details.
# Last revised 1/26/2014
use Getopt::Std;
use strict;
our ($opt_f, $opt_h);
getopts('f:h');
if ($opt_h) {
print <<USAGE;
create_tab_delimited_table.pl
This program will return a simpler version of a SNAP or RAP output file that has been produced via the SURPI pipeline.
Output file is in the following format:
header gi species genus family
Usage:
create_tab_delimited_table.pl -f RAP sample8.Ecutoff1.virus.RAPSearch.annotated.sorted
create_tab_delimited_table.pl -f SNAP sample8.NT.snap.matched.Viruses.sorted
Command Line Switches:
-f Specify SNAP/RAP input format
USAGE
exit;
}
while (<>) {
my ($species, $genus, $family) = ("") x 3;
my @columns = split/\t/, $_;
if (/species--(.*?)\t/) {
$species = $1;
}
if (/genus--(.*?)\t/) {
$genus = $1;
}
if (/family--(.*?)\t/) {
$family = $1;
}
if ($opt_f eq "SNAP") {
print "$columns[0]\t$columns[2]\t";
}
else {
$columns[1] =~ /(gi\|\d+\|)/;
print "$columns[0]\t$1\t";
}
print "$species\t$genus\t$family\n";
}