[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.14, Thu Feb 5 14:50:43 2009 UTC revision 1.15, Mon Apr 13 18:42:53 2009 UTC
# Line 3  Line 3 
3  #  A sequence entry is ( $id, $def, $seq )  #  A sequence entry is ( $id, $def, $seq )
4  #  A list of entries is a list of references  #  A list of entries is a list of references
5  #  #
6    #  Efficient reading of an entire file of sequences:
7    #
8  #  @seq_entries = read_fasta( )                     # STDIN  #  @seq_entries = read_fasta( )                     # STDIN
9  #  @seq_entries = read_fasta( \*FILEHANDLE )  #  @seq_entries = read_fasta( \*FILEHANDLE )
10  #  @seq_entries = read_fasta(  $filename )  #  @seq_entries = read_fasta(  $filename )
11    #
12    #  Reading sequences one at a time to conserve memory.  Calls to different
13    #  files can be intermixed.
14    #
15  #  @entry = read_next_fasta_seq( \*FILEHANDLE )  #  @entry = read_next_fasta_seq( \*FILEHANDLE )
16  # \@entry = read_next_fasta_seq( \*FILEHANDLE )  # \@entry = read_next_fasta_seq( \*FILEHANDLE )
17  #  @entry = read_next_fasta_seq(  $filename )  #  @entry = read_next_fasta_seq(  $filename )
18  # \@entry = read_next_fasta_seq(  $filename )  # \@entry = read_next_fasta_seq(  $filename )
19  #  @entry = read_next_fasta_seq()                   # STDIN  #  @entry = read_next_fasta_seq()                   # STDIN
20  # \@entry = read_next_fasta_seq()                   # STDIN  # \@entry = read_next_fasta_seq()                   # STDIN
21    #
22    #  Legacy interface:
23  #  @seq_entries = read_fasta_seqs( \*FILEHANDLE )   # Original form  #  @seq_entries = read_fasta_seqs( \*FILEHANDLE )   # Original form
24    #
25    #  Reading clustal alignment.
26    #
27  #  @seq_entries = read_clustal( )                   # STDIN  #  @seq_entries = read_clustal( )                   # STDIN
28  #  @seq_entries = read_clustal( \*FILEHANDLE )  #  @seq_entries = read_clustal( \*FILEHANDLE )
29  #  @seq_entries = read_clustal(  $filename )  #  @seq_entries = read_clustal(  $filename )
30    #
31    #  Legacy interface:
32  #  @seq_entries = read_clustal_file(  $filename )  #  @seq_entries = read_clustal_file(  $filename )
33  #  #
34  #  $seq_ind   = index_seq_list( @seq_entries );   # hash from ids to entries  #  $seq_ind   = index_seq_list( @seq_entries );   # hash from ids to entries
# Line 26  Line 39 
39  #  ( $id, $def ) = parse_fasta_title( $title )  #  ( $id, $def ) = parse_fasta_title( $title )
40  #  ( $id, $def ) = split_fasta_title( $title )  #  ( $id, $def ) = split_fasta_title( $title )
41  #  #
42  #  print_seq_list_as_fasta( \*FILEHANDLE, @seq_entry_list );  # Original form  #  Write a fasta format file from sequences.
43    #
44  #  print_alignment_as_fasta(                @seq_entry_list ); # STDOUT  #  print_alignment_as_fasta(                @seq_entry_list ); # STDOUT
45  #  print_alignment_as_fasta(               \@seq_entry_list ); # STDOUT  #  print_alignment_as_fasta(               \@seq_entry_list ); # STDOUT
46  #  print_alignment_as_fasta( \*FILEHANDLE,  @seq_entry_list );  #  print_alignment_as_fasta( \*FILEHANDLE,  @seq_entry_list );
47  #  print_alignment_as_fasta( \*FILEHANDLE, \@seq_entry_list );  #  print_alignment_as_fasta( \*FILEHANDLE, \@seq_entry_list );
48  #  print_alignment_as_fasta(  $filename,    @seq_entry_list );  #  print_alignment_as_fasta(  $filename,    @seq_entry_list );
49  #  print_alignment_as_fasta(  $filename,   \@seq_entry_list );  #  print_alignment_as_fasta(  $filename,   \@seq_entry_list );
50    #
51    #  Legacy interface:
52    #  print_seq_list_as_fasta( \*FILEHANDLE, @seq_entry_list );  # Original form
53    #
54    #  Interface that it really meant for internal use to write the next sequence
55    #  to an open file:
56    #
57    #  print_seq_as_fasta( \*FILEHANDLE, $id, $desc, $seq );
58    #  print_seq_as_fasta(               $id, $desc, $seq );
59    #  print_seq_as_fasta( \*FILEHANDLE, $id,        $seq );
60    #  print_seq_as_fasta(               $id,        $seq );
61    #
62    #  Write PHYLIP alignment.  Names might be altered to fit 10 character limit:
63    #
64  #  print_alignment_as_phylip(                @seq_entry_list ); # STDOUT  #  print_alignment_as_phylip(                @seq_entry_list ); # STDOUT
65  #  print_alignment_as_phylip(               \@seq_entry_list ); # STDOUT  #  print_alignment_as_phylip(               \@seq_entry_list ); # STDOUT
66  #  print_alignment_as_phylip( \*FILEHANDLE,  @seq_entry_list );  #  print_alignment_as_phylip( \*FILEHANDLE,  @seq_entry_list );
67  #  print_alignment_as_phylip( \*FILEHANDLE, \@seq_entry_list );  #  print_alignment_as_phylip( \*FILEHANDLE, \@seq_entry_list );
68  #  print_alignment_as_phylip(  $filename,    @seq_entry_list );  #  print_alignment_as_phylip(  $filename,    @seq_entry_list );
69  #  print_alignment_as_phylip(  $filename,   \@seq_entry_list );  #  print_alignment_as_phylip(  $filename,   \@seq_entry_list );
70    #
71    #  Write basic NEXUS alignment for PAUP.
72    #
73  #  print_alignment_as_nexus(               [ \%label_hash, ]  @seq_entry_list );  #  print_alignment_as_nexus(               [ \%label_hash, ]  @seq_entry_list );
74  #  print_alignment_as_nexus(               [ \%label_hash, ] \@seq_entry_list );  #  print_alignment_as_nexus(               [ \%label_hash, ] \@seq_entry_list );
75  #  print_alignment_as_nexus( \*FILEHANDLE, [ \%label_hash, ]  @seq_entry_list );  #  print_alignment_as_nexus( \*FILEHANDLE, [ \%label_hash, ]  @seq_entry_list );
76  #  print_alignment_as_nexus( \*FILEHANDLE, [ \%label_hash, ] \@seq_entry_list );  #  print_alignment_as_nexus( \*FILEHANDLE, [ \%label_hash, ] \@seq_entry_list );
77  #  print_alignment_as_nexus(  $filename,   [ \%label_hash, ]  @seq_entry_list );  #  print_alignment_as_nexus(  $filename,   [ \%label_hash, ]  @seq_entry_list );
78  #  print_alignment_as_nexus(  $filename,   [ \%label_hash, ] \@seq_entry_list );  #  print_alignment_as_nexus(  $filename,   [ \%label_hash, ] \@seq_entry_list );
79  #  print_seq_as_fasta( \*FILEHANDLE, $id, $desc, $seq );  #
 #  print_seq_as_fasta(               $id, $desc, $seq );  
80  #  print_gb_locus( \*FILEHANDLE, $locus, $def, $accession, $seq );  #  print_gb_locus( \*FILEHANDLE, $locus, $def, $accession, $seq );
81  #  #
82    # Remove extra columns of alignment gaps from an alignment:
83    #
84  #   @packed_seqs = pack_alignment(  @seqs )  #   @packed_seqs = pack_alignment(  @seqs )
85  #   @packed_seqs = pack_alignment( \@seqs )  #   @packed_seqs = pack_alignment( \@seqs )
86  #  \@packed_seqs = pack_alignment(  @seqs )  #  \@packed_seqs = pack_alignment(  @seqs )
87  #  \@packed_seqs = pack_alignment( \@seqs )  #  \@packed_seqs = pack_alignment( \@seqs )
88  #  #
89    # Basic sequence manipulation functions:
90    #
91  #  @entry  = subseq_DNA_entry( @seq_entry, $from, $to [, $fix_id] );  #  @entry  = subseq_DNA_entry( @seq_entry, $from, $to [, $fix_id] );
92  #  @entry  = subseq_RNA_entry( @seq_entry, $from, $to [, $fix_id] );  #  @entry  = subseq_RNA_entry( @seq_entry, $from, $to [, $fix_id] );
93  #  $DNAseq = DNA_subseq(  $seq, $from, $to );  #  $DNAseq = DNA_subseq(  $seq, $from, $to );
# Line 732  Line 766 
766    
767    
768  #-----------------------------------------------------------------------------  #-----------------------------------------------------------------------------
769  #  Print one sequence in fasta format to an open file  #  Print one sequence in fasta format to an open file.
770  #  #
771  #     print_seq_as_fasta( \*FILEHANDLE, $id, $desc, $seq );  #     print_seq_as_fasta( \*FILEHANDLE, $id, $desc, $seq );
772  #     print_seq_as_fasta(               $id, $desc, $seq );  #     print_seq_as_fasta(               $id, $desc, $seq );
773    #     print_seq_as_fasta( \*FILEHANDLE, $id,        $seq );
774    #     print_seq_as_fasta(               $id,        $seq );
775    #
776    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
777    #  print_seq_as_fasta() is meant more as a internal support routine than an
778    #  external interface.  To print a single sequence to a named file use:
779    #
780    #     print_alignment_as_fasta( $filename, [ $id, $desc, $seq ] );
781    #     print_alignment_as_fasta( $filename, [ $id,        $seq ] );
782  #-----------------------------------------------------------------------------  #-----------------------------------------------------------------------------
783  sub print_seq_as_fasta  sub print_seq_as_fasta
784  {  {
785      my $fh = ( ref $_[0] eq 'GLOB' ) ? shift : \*STDOUT;      my $fh = ( ref $_[0] eq 'GLOB' ) ? shift : \*STDOUT;
786      print $fh $_[1] =~ /\S/ ? ">$_[0] $_[1]\n" : ">$_[0]\n";      #  Print header line
787      print $fh join( "\n", $_[2] =~ m/.{1,60}/g ), "\n";      print $fh  ( @_ == 3 && $_[1] =~ /\S/ ) ? ">$_[0] $_[1]\n" : ">$_[0]\n";
788        #  Print sequence, 60 chars per line
789        print $fh  join( "\n", $_[-1] =~ m/.{1,60}/g ), "\n";
790  }  }
791    
792    

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3