[Bio] / FigKernelPackages / gjoseqlib.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/gjoseqlib.pm

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

revision 1.7, Sun Jun 10 17:34:54 2007 UTC revision 1.9, Thu Nov 1 20:07:42 2007 UTC
# Line 51  Line 51 
51  #  #
52  #  @entry  = subseq_DNA_entry( @seq_entry, $from, $to [, $fix_id] );  #  @entry  = subseq_DNA_entry( @seq_entry, $from, $to [, $fix_id] );
53  #  @entry  = subseq_RNA_entry( @seq_entry, $from, $to [, $fix_id] );  #  @entry  = subseq_RNA_entry( @seq_entry, $from, $to [, $fix_id] );
54    #  $DNAseq = DNA_subseq(  $seq, $from, $to );
55    #  $DNAseq = DNA_subseq( \$seq, $from, $to );
56    #  $RNAseq = RNA_subseq(  $seq, $from, $to );
57    #  $RNAseq = RNA_subseq( \$seq, $from, $to );
58  #  @entry  = complement_DNA_entry( @seq_entry [, $fix_id] );  #  @entry  = complement_DNA_entry( @seq_entry [, $fix_id] );
59  #  @entry  = complement_RNA_entry( @seq_entry [, $fix_id] );  #  @entry  = complement_RNA_entry( @seq_entry [, $fix_id] );
60  #  $DNAseq = complement_DNA_seq( $NA_seq );  #  $DNAseq = complement_DNA_seq( $NA_seq );
# Line 67  Line 71 
71  #  User-supplied genetic code must be upper case index and match the  #  User-supplied genetic code must be upper case index and match the
72  #  DNA versus RNA type of sequence  #  DNA versus RNA type of sequence
73  #  #
74    #  $seq = translate_seq_with_user_code( $seq, $gen_code_hash [, $met_start] )
75    #
76  #  Locations (= oriented intervals) are ( id, start, end )  #  Locations (= oriented intervals) are ( id, start, end )
77  #  Intervals are ( id, left, right )  #  Intervals are ( id, left, right )
78  #  #
# Line 93  Line 99 
99  #  #
100    
101  use strict;  use strict;
102    use Carp;
103    
104  #  Exported global variables:  #  Exported global variables:
105    
# Line 138  Line 145 
145    
146          subseq_DNA_entry          subseq_DNA_entry
147          subseq_RNA_entry          subseq_RNA_entry
148            DNA_subseq
149            RNA_subseq
150          complement_DNA_entry          complement_DNA_entry
151          complement_RNA_entry          complement_RNA_entry
152          complement_DNA_seq          complement_DNA_seq
# Line 439  Line 448 
448      my ( $fh, undef, $close, $unused ) = output_filehandle( shift );      my ( $fh, undef, $close, $unused ) = output_filehandle( shift );
449      ( unshift @_, $unused ) if $unused;      ( unshift @_, $unused ) if $unused;
450    
451      ( ref( $_[0] ) eq "ARRAY" ) or die "Bad sequence entry passed to print_alignment_as_fasta\n";      ( ref( $_[0] ) eq "ARRAY" ) or confess "Bad sequence entry passed to print_alignment_as_fasta\n";
452    
453      #  Expand the sequence entry list if necessary:      #  Expand the sequence entry list if necessary:
454    
# Line 851  Line 860 
860  }  }
861    
862    
863    sub DNA_subseq
864    {
865        my ( $seq, $from, $to ) = @_;
866    
867        my $len = ref( $seq ) eq 'SCALAR' ? length( $$seq )
868                                          : length(  $seq );
869        if ( ( $from eq '$' ) || ( $from eq "" ) ) { $from = $len }
870        if ( ( $to   eq '$' ) || ( ! $to       ) ) { $to   = $len }
871    
872        my $left  = ( $from < $to ) ? $from : $to;
873        my $right = ( $from < $to ) ? $to   : $from;
874        if ( ( $right < 1 ) || ( $left > $len ) ) { return "" }
875        if ( $right > $len ) { $right = $len }
876        if ( $left  < 1    ) { $left  =    1 }
877    
878        my $subseq = ref( $seq ) eq 'SCALAR' ? substr( $$seq, $left-1, $right-$left+1 )
879                                             : substr(  $seq, $left-1, $right-$left+1 );
880    
881        if ( $from > $to )
882        {
883            $subseq = reverse $subseq;
884            $subseq =~ tr[ACGTUKMRSWYBDHVNacgtukmrswybdhvn]
885                         [TGCAAMKYSWRVHDBNtgcaamkyswrvhdbn];
886        }
887    
888        $subseq
889    }
890    
891    
892    sub RNA_subseq
893    {
894        my ( $seq, $from, $to ) = @_;
895    
896        my $len = ref( $seq ) eq 'SCALAR' ? length( $$seq )
897                                          : length(  $seq );
898        if ( ( $from eq '$' ) || ( $from eq "" ) ) { $from = $len }
899        if ( ( $to   eq '$' ) || ( ! $to       ) ) { $to   = $len }
900    
901        my $left  = ( $from < $to ) ? $from : $to;
902        my $right = ( $from < $to ) ? $to   : $from;
903        if ( ( $right < 1 ) || ( $left > $len ) ) { return "" }
904        if ( $right > $len ) { $right = $len }
905        if ( $left  < 1    ) { $left  =    1 }
906    
907        my $subseq = ref( $seq ) eq 'SCALAR' ? substr( $$seq, $left-1, $right-$left+1 )
908                                             : substr(  $seq, $left-1, $right-$left+1 );
909    
910        if ( $from > $to )
911        {
912            $subseq = reverse $subseq;
913            $subseq =~ tr[ACGTUKMRSWYBDHVNacgtukmrswybdhvn]
914                         [UGCAAMKYSWRVHDBNugcaamkyswrvhdbn];
915        }
916    
917        $subseq
918    }
919    
920    
921  sub complement_DNA_entry {  sub complement_DNA_entry {
922      my ($id, $desc, $seq, $fix_id) = @_;      my ($id, $desc, $seq, $fix_id) = @_;
923      $fix_id ||= 0;     #  fix undef values      $fix_id ||= 0;     #  fix undef values
# Line 1058  Line 1125 
1125  }  }
1126    
1127    
1128  #  Construct the genetic code with selanocysteine by difference:  #  Construct the genetic code with selenocysteine by difference:
1129    
1130  %genetic_code_with_U = map { $_ => $genetic_code{ $_ } } keys %genetic_code;  %genetic_code_with_U = map { $_ => $genetic_code{ $_ } } keys %genetic_code;
1131  $genetic_code_with_U{ TGA } = "U";  $genetic_code_with_U{ TGA } = "U";

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3