ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/gclib/scripts/iso2fasta.pl
Revision: 24
Committed: Tue Jul 26 21:46:39 2011 UTC (13 years, 1 month ago) by gpertea
File size: 985 byte(s)
Log Message:
Line File contents
1 #!/usr/bin/perl
2 use strict;
3
4 my ($fastafile,$isofile,$outbase, $count)=@ARGV;
5
6 #my ($fastafile,$isofile,$outfile)=@ARGV;
7
8 open(F,$fastafile);
9 my $line=<F>;
10 chomp($line);
11 my ($header,$offset)=split(/\s+/,$line);
12 if ($offset) {
13 die ("Invalid fasta defline for this script: a numeric offset is expected after seqID\n")
14 unless $offset=~m/^\d+$/;
15 }
16 my $seq='';
17 while (<F>) {
18 chomp;
19 last if m/^>/;
20 $seq.=$_;
21 }
22 close(F);
23
24 open(F,$isofile);
25 while(<F>) {
26 next if m/^\s*#/;
27 chomp;
28 my @a=split(/\t/);
29 my $beg=$a[3];
30 my ($len)=($a[8]=~m/len=(\d+)/);
31 my $outfile=$outbase.'.'.$count;
32 open(FO,">$outfile") || die ("Error creating $outfile!\n");
33 $count++;
34 my $subseq=substr($seq,$beg-1,$len);
35 print FO "$header ".($offset+$beg-1)."\n";
36 &printfa($subseq);
37 close(FO);
38
39
40 }
41 #select(STDOUT);
42 close(F);
43
44 sub printfa {
45 my $seqlen=length($_[0]);
46 my $pos=0;
47 while ($pos<$seqlen) {
48 print FO substr($_[0],$pos,60)."\n";
49 $pos+=60;
50 }
51 }

Properties

Name Value
svn:executable *