[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.2, Thu Jun 8 17:43:12 2006 UTC revision 1.5, Wed Jul 11 14:51:34 2007 UTC
# Line 1  Line 1 
1  # -*- perl -*-  # -*- perl -*-
2  #  ########################################################################
3  # Copyright (c) 2003-2006 University of Chicago and Fellowship  # Copyright (c) 2003-2006 University of Chicago and Fellowship
4  # for Interpretations of Genomes. All Rights Reserved.  # for Interpretations of Genomes. All Rights Reserved.
5  #  #
# Line 14  Line 14 
14  # at info@ci.uchicago.edu or the Fellowship for Interpretation of  # at info@ci.uchicago.edu or the Fellowship for Interpretation of
15  # Genomes at veronika@thefig.info or download a copy from  # Genomes at veronika@thefig.info or download a copy from
16  # http://www.theseed.org/LICENSE.TXT.  # http://www.theseed.org/LICENSE.TXT.
17  #  ########################################################################
   
18    
19  use FIG;  use FIG;
20  $fig = new FIG;  $fig = new FIG;
# Line 35  Line 34 
34  }  }
35    
36  $trouble = 0;  $trouble = 0;
37  ($org_id = shift @ARGV) || (($trouble = 1) && (warn "No Org-ID given"));  ($org_id = shift @ARGV)     || (($trouble = 1) && (print STDERR "\nNo Org-ID given"));
38    ($org_id =~ m/^\d+\.\d+$/o) || (($trouble = 1) && (print STDERR "\nOrg-ID $org_id is malformed"));
39    
40  for ($i=0; $i < @ARGV; ++$i)  for ($i=0; $i < @ARGV; ++$i)
41  {  {
42      if (!-e $ARGV[$i])      if (!-e $ARGV[$i])
43      {      {
44          $trouble = 1;          $trouble = 1;
45          print STDERR "ERROR: File $ARGV[$i] does not exist\n";          print STDERR "\nERROR: File $ARGV[$i] does not exist";
46      }      }
47  }  }
48  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 56  Line 56 
56  $regions = &load_regions(@tbls);  $regions = &load_regions(@tbls);
57  # die Dumper($features);  # die Dumper($features);
58    
59  foreach $contig (keys %$regions)  $gap_num = 0;
60    foreach $contig (sort keys %$len_of)
61  {  {
62        print STDERR "Scanning $contig ...\n" if $ENV{VERBOSE};
63    
64      $x = $regions->{$contig};      $x = $regions->{$contig};
65        $x = defined($x) ? $x : [];
66    
67    #   if ($x->[0]  > 1)                  { unshift @$x, [0, 0]; }
68    #   if ($x->[-1] > $len_of->{$contig}) { push    @$x, [1+$len_of->{$contig}, 1+$len_of->{$contig}]; }
69    
70      if ($x->[0]  > 1)                  { unshift @$x, [0, 0]; }      unshift @$x, [0, 0];
71      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}];
72    
73      for ($i=1; $i < @$x; ++$i)      for ($i=1; $i < @$x; ++$i)
74      {      {
# Line 70  Line 77 
77          $gap_len = $gap_end - $gap_beg + 1;          $gap_len = $gap_end - $gap_beg + 1;
78          $gap_loc = "$contig\_$gap_beg\_$gap_end";          $gap_loc = "$contig\_$gap_beg\_$gap_end";
79    
80          print "fig|$org_id.gap.".($i+1) . "\t$gap_loc\n";          print "fig|$org_id.gap.".(++$gap_num) . "\t$gap_loc\n";
81      }      }
82  }  }
83  print STDERR "$this_tool done\n\n";  print STDERR "\n$this_tool done\n\n" if $ENV{VERBOSE};
84  exit(0);  exit(0);
85    
86    
# Line 81  Line 88 
88  {  {
89      my ($contigs_file) = @_;      my ($contigs_file) = @_;
90    
91        my $num_contigs = 0;
92        my $num_chars   = 0;
93    
94      my $len_of = {};      my $len_of = {};
95    
96        print STDERR "Loading $contigs_file ...\n" if $ENV{VERBOSE};
97      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";
98      while (($id, $seqP) = &FIG::read_fasta_record(\*CONTIGS))      while (($id, $seqP) = &FIG::read_fasta_record(\*CONTIGS))
99      {      {
100          $len_of->{$id} = length($$seqP);          ++$num_contigs;
101            $num_chars += $len_of->{$id} = length($$seqP);
102      }      }
103      close(CONTIGS) or die "could not close $contigs_file";      close(CONTIGS) or die "could not close $contigs_file";
104        print STDERR "Loaded $num_contigs contig lengths (total $num_chars chars) from $contigs_file\n\n" if $ENV{VERBOSE};
105    
106      return $len_of;      return $len_of;
107  }  }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.5

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3