convert interproscan output

4 views
Skip to first unread message

Qiang Lin

unread,
Sep 6, 2011, 4:59:30 AM9/6/11
to bioinformatics_linq26
#!/usr/bin/perl
eval 'exec /usr/bin/perl -S $0 ${1+"$@"}' if 0; # not running under
some shell
#===============================================================================
#
# NAME:
#
# AUTHOR: LinQiang
#
# COMMENT:Perl script template.
#
# VERSION:
#
#===============================================================================
# Include Modules
#===============================================================================
use strict;
use warnings;
use Pod::Usage;
use Getopt::Long;
#===============================================================================
# Global Variables Declaration
#===============================================================================
my %opts;
my $version=1.0;
my %name;
my %go;
#===============================================================================
# Argument Check
#===============================================================================
GetOptions(\%opts,"input=s","output=s","h");
&usage if (!(defined ($opts{input} and $opts{output})) || defined
$opts{h});

#===============================================================================
# Prototypes Section
#===============================================================================

#===============================================================================
# main()
#===============================================================================

open IN,$opts{input};
while (<IN>) {
chomp;
my @tt=split/\t/,$_;
next if $tt[3] eq "Seg";
next if $tt[3] eq "Coil";
my $id=$tt[0];
( $name{$id}=() and $go{$id}=() ) if !exists $name{$id};
my $method=$tt[3];
my $dsp=$tt[5];
my $fun=$tt[13];
$name{$id}.="[".$method."|".$dsp."]";
next unless $fun;
next unless $fun=~/\((GO\:\d+)\)/;
foreach ($fun=~/\((GO\:\d+)\)/g) {
$go{$id}.="$1|";
}
}
my %go2;
foreach (keys %go) {
my @tmp=split/\|/,$go{$_};
my %saw;
@saw{@tmp}=();
my $out=join("|",sort keys %saw);
$go2{$_}=$out;
}

open OUT1,">$opts{output}";
#open OUT2,">$opts{output}\.golist";
foreach (keys %name) {
print OUT1 "$_\tNA\t$name{$_}\n" if !exists $go2{$_};
print OUT1 "$_\t$go2{$_}\t$name{$_}\n" if exists $go2{$_};

}


sub usage{
print <<"USAGE";
Version $version
Usage:
$0 -input -output
options:
[REQUIRED]
-h help
-input inproscan output with raw format
USAGE
exit(1);
}

__END__

Davy

unread,
Sep 6, 2011, 5:01:27 AM9/6/11
to bioinforma...@googlegroups.com
在perl里很少有人用长变量名么?那样可读性会更好一些~
Reply all
Reply to author
Forward
0 new messages