Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
19
Task/FASTA-format/Perl/fasta-format-1.pl
Normal file
19
Task/FASTA-format/Perl/fasta-format-1.pl
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
my $fasta_example = <<'END_FASTA_EXAMPLE';
|
||||
>Rosetta_Example_1
|
||||
THERECANBENOSPACE
|
||||
>Rosetta_Example_2
|
||||
THERECANBESEVERAL
|
||||
LINESBUTTHEYALLMUST
|
||||
BECONCATENATED
|
||||
END_FASTA_EXAMPLE
|
||||
|
||||
my $num_newlines = 0;
|
||||
while ( < $fasta_example > ) {
|
||||
if (/\A\>(.*)/) {
|
||||
print "\n" x $num_newlines, $1, ': ';
|
||||
}
|
||||
else {
|
||||
$num_newlines = 1;
|
||||
print;
|
||||
}
|
||||
}
|
||||
23
Task/FASTA-format/Perl/fasta-format-2.pl
Normal file
23
Task/FASTA-format/Perl/fasta-format-2.pl
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
use strict; # https://rosettacode.org/wiki/FASTA_format
|
||||
use warnings;
|
||||
|
||||
my $fasta_example = <<''; # end at first empty line
|
||||
>Rosetta_Example_1
|
||||
THERECANBENOSPACE
|
||||
>Rosetta_Example_2
|
||||
THERECANBESEVERAL
|
||||
LINESBUTTHEYALLMUST
|
||||
BECONCATENATED
|
||||
|
||||
open my $fh, '<', \$fasta_example or die "$! on open";
|
||||
local $/ = "\n>"; # to read one sequence at a time
|
||||
while( <$fh> )
|
||||
{
|
||||
chomp;
|
||||
print s/^>//r # remove a leading '>' if present
|
||||
=~ s/\n/: /r # change the first newline to ': '
|
||||
=~ tr/\n//dr, # remove the rest of the newlines
|
||||
"\n"; # and put one newline at the end
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue