I have a text file in fasta format, which looks like...
>SequenceID|1234_Gene1
ATGTGTGTGTGTGTGT (DNA Sequence)>SequenceID|9876_Gene2
CTGTCGCTCGGAAAG (DNA Sequence)I am trying to write a script that will pull this data from a txt file in the command line into a hash and then sort it by length. The hash would be set up as the SequenceID has the key and DNA sequence as the value.
This is what I have so far and it works, except I set up the hash inside the script and not from a txt file added in the command line, I am not sure how to do this. I do not want to use BioPerl.
Thank youmy %sequences = ( "SequenceID|1234_Gene1" => 'CTTTTAAGCTGATTAGGCTTTTATACCATTAGATTTA +GTAACTATTGTCTTTTAA', "SequenceID|9876_Gene2" => 'GTGCTGTCTTAAGTTGAACAGAGTGTGGGAGGAAATA +TAAGCAAAGTTATTCCGTAGAATT', "SequenceID|4567_Gene3" => 'CATCCTCCTTTACACCCCACAAACATTTGGCAACCCCT +GATAGGTTTCTTTCTTGTGGA', ); foreach my $key (keys %sequences) { my $len = length ($sequences{$key}); print "$key:$len\n"; }
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |