User Tools

Site Tools


gc_skew.pl

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

gc_skew.pl [2016/02/18 09:15]
hyjeong created
gc_skew.pl [2016/02/18 09:16] (current)
hyjeong
Line 1: Line 1:
-!/usr/bin/perl +  #!/usr/bin/perl 
- +   
-use Bio::SeqIO; +  use Bio::SeqIO; 
- +   
-$window = 5000; # 10 kb +  $window = 5000; # 10 kb 
-$shift = 5000;   # 2 kb +  $shift = 5000;   # 2 kb 
- +   
-$seqIn = Bio::SeqIO->new(-file => $ARGV[0], -format => 'fasta'); +  $seqIn = Bio::SeqIO->new(-file => $ARGV[0], -format => 'fasta'); 
-$seqObj = $seqIn->next_seq(); +  $seqObj = $seqIn->next_seq(); 
-$seqStr = $seqObj->seq(); +  $seqStr = $seqObj->seq(); 
-$length = $seqObj->length(); +  $length = $seqObj->length(); 
-@whole_seq = split //, $seqStr; +  @whole_seq = split //, $seqStr; 
- +   
-$cum_GC_skew = 0; +  $cum_GC_skew = 0; 
- +   
-for ($i = 1; $i <= $length; $i += $shift) { +  for ($i = 1; $i <= $length; $i += $shift) { 
-    $end = $i + $shift - 1; +      $end = $i + $shift - 1; 
-    $end = $length if $end > $length; +      $end = $length if $end > $length; 
-    $frag = $seqObj->trunc($i, $end)->seq(); +      $frag = $seqObj->trunc($i, $end)->seq(); 
-    $G = ($frag =~ s/g/G/ig); +      $G = ($frag =~ s/g/G/ig); 
-    $C = ($frag =~ s/c/C/ig); +      $C = ($frag =~ s/c/C/ig); 
-    $GC_skew = ($G - $C) / ($G + $C); +      $GC_skew = ($G - $C) / ($G + $C); 
-    $cum_GC_skew += $GC_skew; +      $cum_GC_skew += $GC_skew; 
-    $GC = ($G + $C) / $window; +      $GC = ($G + $C) / $window; 
-    print join "\t", $i, $GC_skew, $cum_GC_skew, $GC . "\n"; +      print join "\t", $i, $GC_skew, $cum_GC_skew, $GC . "\n"; 
- +  }
-}+
  
gc_skew.pl.txt · Last modified: 2016/02/18 09:16 by hyjeong