Anonymous user
FASTA format: Difference between revisions
→Tcl: Added implementation
m (tidier, some notes on what makes for a good implementation) |
(→Tcl: Added implementation) |
||
Line 28:
LINESBUTTHEYALLMUST
BECONCATENATED".comb: / '>' (\N+)\n (<!before '>'>\N+\n?)+ /, :match</lang>
=={{header|Tcl}}==
<lang tcl>proc fastaReader {filename} {
set f [open $filename]
set sep ""
while {[gets $f line] >= 0} {
if {[string match >* $line]} {
puts -nonewline "$sep[string range $line 1 end]: "
set sep "\n"
} else {
puts -nonewline $line
}
}
puts ""
close $f
}
fastaReader ./rosettacode.fasta</lang>
{{out}}
<pre>
Rosetta_Example_1: THERECANBENOSPACE
Rosetta_Example_2: THERECANBESEVERALLINESBUTTHEYALLMUSTBECONCATENATED
</pre>
|