[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.4, Fri Dec 15 00:09:52 2006 UTC revision 1.5, Sun Jun 10 17:17:40 2007 UTC
# Line 44  Line 44 
44  #  print_seq_as_fasta( \*FILEHANDLE, @seq_entry );  #  print_seq_as_fasta( \*FILEHANDLE, @seq_entry );
45  #  print_gb_locus( \*FILEHANDLE, $locus, $def, $accession, $seq );  #  print_gb_locus( \*FILEHANDLE, $locus, $def, $accession, $seq );
46  #  #
47    #  @seqs = pack_alignment( @seqs )
48    #
49  #  @entry  = subseq_DNA_entry( @seq_entry, $from, $to [, $fix_id] );  #  @entry  = subseq_DNA_entry( @seq_entry, $from, $to [, $fix_id] );
50  #  @entry  = subseq_RNA_entry( @seq_entry, $from, $to [, $fix_id] );  #  @entry  = subseq_RNA_entry( @seq_entry, $from, $to [, $fix_id] );
51  #  @entry  = complement_DNA_entry( @seq_entry [, $fix_id] );  #  @entry  = complement_DNA_entry( @seq_entry [, $fix_id] );
# Line 122  Line 124 
124          seq_desc_by_id          seq_desc_by_id
125          seq_data_by_id          seq_data_by_id
126    
127            pack_alignment
128    
129          subseq_DNA_entry          subseq_DNA_entry
130          subseq_RNA_entry          subseq_RNA_entry
131          complement_DNA_entry          complement_DNA_entry
# Line 674  Line 678 
678      return ${ $ind_ref->{$id} }[2];      return ${ $ind_ref->{$id} }[2];
679  }  }
680    
681    #-----------------------------------------------------------------------------
682    #  Remove columns of alignment gaps from sequences:
683    #
684    #  @packed_seqs = pack_alignment( @seqs )
685    #
686    #-----------------------------------------------------------------------------
687    
688    sub pack_alignment
689    {
690        my @seqs = ( ref( $_[0] ) eq 'ARRAY' and ref( $_[0]->[0] ) eq 'ARRAY' ) ? @{$_[0] } : @_;
691        @seqs or return wantarray ? () : [];
692    
693        my $mask  = pack_mask( $seqs[0]->[2] );
694        foreach ( @seqs[ 1 .. (@seqs-1) ] )
695        {
696            $mask |= pack_mask( $_->[2] );
697        }
698    
699        my $seq;
700        my @seqs2 = map { $seq = $_->[2] & $mask;
701                          $seq =~ tr/\000//d;
702                          [ $_->[0], $_->[1], $seq ]
703                        }
704                    @seqs;
705    
706        return wantarray ? @seqs2 : \@seqs2;
707    }
708    
709    sub pack_mask
710    {
711        my $mask = shift;
712        $mask =~ tr/-/\000/;
713        $mask =~ tr/\000/\377/c;
714        return $mask;
715    }
716    
717  #-----------------------------------------------------------------------------  #-----------------------------------------------------------------------------
718  #  Some simple sequence manipulations:  #  Some simple sequence manipulations:

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3