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

Diff of /FigKernelScripts/svr_trim_ali.pl

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

revision 1.7, Mon Nov 29 19:50:16 2010 UTC revision 1.8, Mon Dec 27 00:07:33 2010 UTC
# Line 46  Line 46 
46         -m              - trim to median ends only         -m              - trim to median ends only
47         -r              - first collapse seqs into representatives         -r              - first collapse seqs into representatives
48         -s max_reps_sim - threshold used to collapse seqs into representatives (D = 0.9)         -s max_reps_sim - threshold used to collapse seqs into representatives (D = 0.9)
49           -cd             - trim to conserved domains
50           -html file      - show clipped ends in lower letters in an html alignment
51    
52  =head2 Command-Line options  =head2 Command-Line options
53    
# Line 116  Line 118 
118  indicates less aggressive trimming, but it may have the opposite  indicates less aggressive trimming, but it may have the opposite
119  effect when fract_ends is very small.  effect when fract_ends is very small.
120    
121    =item -cd
122    
123    Trim to conserved domains. No psiblast search is attempted.
124    
125    =item -html file
126    
127    Generate an HTML file for visualizing trimmed alignment with clipped
128    ends in lower case.
129    
130  =back  =back
131    
132  =head2 Input  =head2 Input
# Line 151  Line 162 
162         -s  max_reps_sim - threshold used to collapse seqs into representatives (D = 0.9)         -s  max_reps_sim - threshold used to collapse seqs into representatives (D = 0.9)
163         -t  fract_ends   - minimum fraction of ends to be considered significant for uncov cutoff (D = 0.1)         -t  fract_ends   - minimum fraction of ends to be considered significant for uncov cutoff (D = 0.1)
164         -w  win_size     - size of sliding window used in calculating uncov cutoff (D = 10)         -w  win_size     - size of sliding window used in calculating uncov cutoff (D = 10)
165           -cd              - trim to conserved domains
166           -html file       - show clipped ends in lower letters in an html alignment
167    
168  End_of_Usage  End_of_Usage
169    
170  my ($help, $local, $tool, $coord, $dir, $prefix, $fc, $fe, $single, $median, $reps, $sim, $win);  my ($help, $local, $tool, $coord, $dir, $prefix, $fc, $fe,
171        $single, $median, $reps, $sim, $win, $cd, $html, $short);
172    
173  GetOptions("h|help"   => \$help,  GetOptions("h|help"   => \$help,
174             "l|local"  => \$local,             "l|local"  => \$local,
# Line 168  Line 182 
182             "r|rep"    => \$reps,             "r|rep"    => \$reps,
183             "s|sim=f"  => \$sim,             "s|sim=f"  => \$sim,
184             "t|fe=f"   => \$fe,             "t|fe=f"   => \$fe,
185             "w=i"      => \$win);             "w=i"      => \$win,
186               "cd"       => \$cd,
187               "html=s"   => \$html,
188               "short"    => \$short);
189    
190  $help and die $usage;  $help and die $usage;
191    
192  my $opts;  my $opts;
193    
194  $opts->{keep_def}      = 1                 if !$coord;  $opts->{keep_def}       = 1                 if !$coord && !$html;
195  $opts->{single_round}  = 1                 if $single;  $opts->{single_round}  = 1                 if $single;
196  $opts->{skip_psiblast} = 1                 if $median;  $opts->{skip_psiblast}  = 1                 if $median || $cd;
197    $opts->{to_domain}      = 1                 if $cd;
198  $opts->{use_reps}      = 1                 if $reps;  $opts->{use_reps}      = 1                 if $reps;
199  $opts->{fract_cov}     = $fc               if $fc;  $opts->{fract_cov}     = $fc               if $fc;
200  $opts->{fract_ends}    = $fe               if $fe;  $opts->{fract_ends}    = $fe               if $fe;
# Line 202  Line 220 
220    
221  gjoseqlib::print_alignment_as_fasta($trim);  gjoseqlib::print_alignment_as_fasta($trim);
222    
223    if ($html) {
224        my @ali2  = map { [@$_[0,1], uc($_->[2])] } @{$opts->{ali}};
225        my %coord = map { $_->[0] => $_->[1] } @$trim;
226        my ($beg, $end) = (0, length($ali2[0]->[2]));
227        for (@ali2) {
228            $_->[1] = $coord{$_->[0]};
229            my $i = 0;
230            my $j = length($_->[2]) - 1;
231            if ($coord{$_->[0]} =~ /.* \((\d+)-(\d+)\/(\d+)\)/) {
232                my ($b, $e, $l) = ($1, $2, $3);
233                my $nongap = 0;
234                while ($nongap < $b-1) {
235                    $nongap++ if substr($_->[2], $i++, 1) =~ /[A-Z]/i;
236                }
237                $nongap = 0;
238                while ($nongap < $l-$e) {
239                    $nongap++ if substr($_->[2], $j--, 1) =~ /[A-Z]/i;
240                }
241                substr($_->[2], 0, $i) = lc substr($_->[2], 0, $i) if $i > 0;
242                substr($_->[2], $j+1)  = lc substr($_->[2], $j+1)  if $j+1 < length($_->[2]);
243                $beg = $i if $i > $beg;
244                $end = $j if $j < $end;
245            }
246        }
247        my $show = 20;
248        if ($short && $end-$beg > 2*$show) {
249            for (@ali2) {
250                $_->[2] = join(' ', substr($_->[2],0, $beg),
251                               substr($_->[2],$beg, $show),
252                               '---OMITTED---',
253                               substr($_->[2], $end-$show+1, $show),
254                               substr($_->[2], $end+1));
255            }
256        }
257        open(HTML, ">$html") or die "Could not write to $html";
258        my ($seqs2, $legend ) = gjoalign2html::color_alignment_by_consensus( { align => \@ali2 } );
259        print HTML gjoalign2html::alignment_2_html_page($seqs2, { legend => $legend, title => "Alignment showing trimmed regions" });
260        close(HTML);
261    }

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3