[Bio] / FigKernelScripts / find_gaps.pl Repository:
ViewVC logotype

Diff of /FigKernelScripts/find_gaps.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3, Mon Aug 7 10:49:16 2006 UTC revision 1.4, Thu Sep 14 17:36:43 2006 UTC
# Line 35  Line 35 
35  }  }
36    
37  $trouble = 0;  $trouble = 0;
38  ($org_id = shift @ARGV) || (($trouble = 1) && (warn "No Org-ID given"));  ($org_id = shift @ARGV)     || (($trouble = 1) && (print STDERR "\nNo Org-ID given"));
39    ($org_id =~ m/^\d+\.\d+$/o) || (($trouble = 1) && (print STDERR "\nOrg-ID $org_id is malformed"));
40    
41  for ($i=0; $i < @ARGV; ++$i)  for ($i=0; $i < @ARGV; ++$i)
42  {  {
43      if (!-e $ARGV[$i])      if (!-e $ARGV[$i])
44      {      {
45          $trouble = 1;          $trouble = 1;
46          print STDERR "ERROR: File $ARGV[$i] does not exist\n";          print STDERR "\nERROR: File $ARGV[$i] does not exist";
47      }      }
48  }  }
49  die "\n\nAborting due to invalid args\n\nusage: $usage\n\n" if $trouble;  die "\n\nAborting due to invalid args\n\nusage: $usage\n\n" if $trouble;
# Line 57  Line 58 
58  # die Dumper($features);  # die Dumper($features);
59    
60  $gap_num = 0;  $gap_num = 0;
61  foreach $contig (sort keys %$regions)  foreach $contig (sort keys %$len_of)
62  {  {
63        print STDERR "Scanning $contig ...\n" if $ENV{VERBOSE};
64    
65      $x = $regions->{$contig};      $x = $regions->{$contig};
66        $x = defined($x) ? $x : [];
67    
68    #   if ($x->[0]  > 1)                  { unshift @$x, [0, 0]; }
69    #   if ($x->[-1] > $len_of->{$contig}) { push    @$x, [1+$len_of->{$contig}, 1+$len_of->{$contig}]; }
70    
71      if ($x->[0]  > 1)                  { unshift @$x, [0, 0]; }      unshift @$x, [0, 0];
72      if ($x->[-1] > $len_of->{$contig}) { push    @$x, [1+$len_of->{$contig}, 1+$len_of->{$contig}]; }      push    @$x, [1+$len_of->{$contig}, 1+$len_of->{$contig}];
73    
74      for ($i=1; $i < @$x; ++$i)      for ($i=1; $i < @$x; ++$i)
75      {      {
# Line 74  Line 81 
81          print "fig|$org_id.gap.".(++$gap_num) . "\t$gap_loc\n";          print "fig|$org_id.gap.".(++$gap_num) . "\t$gap_loc\n";
82      }      }
83  }  }
84  print STDERR "\n$this_tool done\n\n";  print STDERR "\n$this_tool done\n\n" if $ENV{VERBOSE};
85  exit(0);  exit(0);
86    
87    
# Line 82  Line 89 
89  {  {
90      my ($contigs_file) = @_;      my ($contigs_file) = @_;
91    
92        my $num_contigs = 0;
93        my $num_chars   = 0;
94    
95      my $len_of = {};      my $len_of = {};
96    
97        print STDERR "Loading $contigs_file ...\n" if $ENV{VERBOSE};
98      open (CONTIGS, "<$contigs_file") or die "could not open $contigs_file to read";      open (CONTIGS, "<$contigs_file") or die "could not open $contigs_file to read";
99      while (($id, $seqP) = &FIG::read_fasta_record(\*CONTIGS))      while (($id, $seqP) = &FIG::read_fasta_record(\*CONTIGS))
100      {      {
101          $len_of->{$id} = length($$seqP);          ++$num_contigs;
102            $num_chars += $len_of->{$id} = length($$seqP);
103      }      }
104      close(CONTIGS) or die "could not close $contigs_file";      close(CONTIGS) or die "could not close $contigs_file";
105        print "Loaded $num_contigs contig lengths (total $num_chars chars) from $contigs_file\n\n" if $ENV{VERBOSE};
106    
107      return $len_of;      return $len_of;
108  }  }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3