in reply to Re^3: remove part of string (DNA)
in thread remove part of string (DNA)
Hopes this helps in the futurepackage fasta_utils; use Exporter 'import'; @EXPORT_OK = qw(fasta2hash); use strict; use warnings; use lib '/cs/prt/mrguy/lib'; ##Reading the fasta formats of the file into hash sub fasta2hash { my ($file) = @_; print "file = $file\n"; my $seq_ref = {}; open IN, $file; my ($sequence,$id); while (my $line = <IN>){ if ($line =~/^\s*$/){ next; } if ($line =~ /^>(.*?)$/){ if ($id){ $seq_ref->{$id} = $sequence; } $id = $1; $sequence = ""; } else { chomp $line; $line =~ s/\s//g; $sequence .= $line; } } ##Putting in the last sequence if ($id){ $seq_ref->{$id} = $sequence; } return $seq_ref; } 1;
|
|---|