ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/gclib/scripts/map_pfam_domains.pl
Revision: 24
Committed: Tue Jul 26 21:46:39 2011 UTC (8 years, 1 month ago) by gpertea
File size: 1379 byte(s)
Log Message:
Line File contents
1 #!/usr/bin/perl
2 use strict;
3 use Getopt::Std;
4 my $usage = q{
5 Usage:
6 map_pfam_domains.pl [-s <suffix>] <pfam_search_results>
7
8 Assumes tran6frames.pl with -t option was used to
9 generate the sequence names in the <pfam_search_results>, so it
10 separates the input data into <tag>-named files appropriately.
11
12 Use -s option to specify a custom suffix instead of the
13 default "pfam" one.
14
15 };
16
17 getopts('s:') || die($usage."\n");
18
19 my $suffix=$Getopt::Std::opt_s || 'pdom';
20 while(<>) {
21 chomp;
22 my @t=split;
23 my @ndata=split(/\|/,$t[0]);
24 my $coords=pop(@ndata);
25 my ($beg, $end)=split(/_/,$coords);
26 my $ftag=pop(@ndata);
27 $beg=1 if $beg eq '0';
28 $end=1 if $end eq '0';
29 die(qq/Parsing error: invalid seq ID $t[0]. It should have the format:
30 <seqname>|<filetag>|<coord1>_<coord2>/."\n") unless $beg && $end && $ftag;
31 my $seqid=join('|',@ndata); #remaining '|' fields
32 my ($newbeg, $newend) = ($beg<$end) ?
33 ($beg+($t[1]-1)*3, $beg+($t[2]-1)*3+2) :
34 ($beg-($t[1]-1)*3, $beg-($t[2]-1)*3-2);
35 my $newname=$ftag;
36 $newname=~s/(\.\d+)$/\.$suffix$1/;
37 open(OF, '>>'.$newname) || die("Error appending to file $newname!\n");
38 print OF join(' ',$seqid, $newbeg, $newend, @t[3..9])."\n";
39 close(OF);
40 #printf("%s %20d %10d %20s %5d %5d %5s %10s %s\n",
41 # $seqid,$newbeg,$newend,@t[3..9]);
42 }

Properties

Name Value
svn:executable *