ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/gclib/scripts/jigsaw2iit.pl
Revision: 24
Committed: Tue Jul 26 21:46:39 2011 UTC (13 years ago) by gpertea
File size: 1452 byte(s)
Log Message:
Line File contents
1 #!/usr/bin/perl
2 use strict;
3 #use Getopt::Std;
4 #use FindBin;use lib $FindBin::Bin;
5
6 my $usage = q/Usage:
7 jigsaw2itt.pl <input_jigsaw_gff> <output_iit_file>
8
9 /;
10 umask 0002;
11 my ($infile, $outfile) = @ARGV;
12 die("$usage\nOutput file name required!\n") unless $outfile;
13
14 my $inh;
15
16 if ($infile eq '-') {
17 $inh=\*STDIN;
18 }
19 else {
20 open(INFILE, $infile) || die("Error opening input file $infile!\n");
21 $inh=\*INFILE;
22 }
23
24 my $curmodel; #current model name
25 my $curtag; #chromosome and strand for current model
26 my @exd; #exons for current model
27
28 open(TOIIT, '| iit_store -o '.$outfile)
29 || die("Error opening pipe to iit_store ($!)!\n");
30 while (<$inh>) {
31 next if m/^\s*#/;
32 chomp;
33 my ($chr, $jsver, $exontype, $exonstart, $exonend, $jscore,
34 $strand, $frame, $lnum)=split(/\t/);
35 next unless $lnum>0;
36 ($exonstart, $exonend)=($exonend, $exonstart) if $exonend<$exonstart;
37 my $locus=$chr.'.jsm.'.$lnum;
38 if ($locus ne $curmodel) {
39 &writeModel() if $curmodel;
40 $curmodel=$locus;
41 $curtag=$chr.$strand;
42 @exd=([$exonstart, $exonend]);
43 next;
44 }
45 push(@exd, [$exonstart, $exonend]);
46 }
47
48 writeModel() if $curmodel;
49
50 close(INFILE) unless $infile eq '-';
51 close(TOIIT);
52
53 sub writeModel {
54 my @ex= sort { $main::a->[0] <=> $main::b->[0] } @exd;
55 my ($mstart, $mend)=($ex[0]->[0], $ex[-1]->[1]);
56 my @exw = map { $_->[0].'-'.$_->[1] } @ex;
57 print TOIIT ">$curmodel $mstart $mend $curtag\n";
58 print TOIIT join(',',@exw)."\n";
59 }

Properties

Name Value
svn:executable *