]> git.donarmstrong.com Git - biopieces.git/blobdiff - code_perl/Maasha/Fasta.pm
added seq/assemble.rb
[biopieces.git] / code_perl / Maasha / Fasta.pm
index 3110e8dae63a785d3fb7906dba326574885f5ca0..339885bdf4d304c917704ed8cf3c58bb35240f26 100644 (file)
@@ -30,6 +30,7 @@ package Maasha::Fasta;
 
 use warnings;
 use strict;
+use Exporter;
 use Data::Dumper;
 use Maasha::Common;
 use Maasha::Filesys;
@@ -95,7 +96,7 @@ sub put_entry
 {
     # Martin A. Hansen, January 2007.
 
-    # Writes FASTA entries to STDOUT or file.
+    # Writes a FASTA entry to a file handle.
 
     my ( $entry,     # a FASTA entries
          $fh,        # file handle to output file - OPTIONAL
@@ -119,6 +120,46 @@ sub put_entry
 }
 
 
+sub put_entries
+{
+    # Martin A. Hansen, September 2009
+
+    # Write FASTA entries to a file.
+
+    my ( $entries,   # list of FASTA entries
+         $file,      # output file
+         $wrap,      # line width  -  OPTIONAL
+       ) = @_;
+
+    # Returns nothing
+
+    my ( $fh );
+
+    $fh = Maasha::Filesys::file_write_open( $file );
+
+    map { put_entry( $_, $fh, $wrap ) } @{ $entries };
+
+    close $fh;
+}
+
+
+sub wrap
+{
+    # Martin A. Hansen, June 2007
+
+    # Wraps the sequence of a given FASTA entry
+    # to a given length.
+
+    my ( $entry,   # FASTA entry
+         $wrap,    # wrap length
+       ) = @_;
+
+    # Returns nothing.
+
+    Maasha::Seq::wrap( \$entry->[ SEQ ], $wrap );
+}
+
+
 sub fasta_index
 {
     # Martin A. Hansen, July 2008.