RosettaCodeData/Task/FASTA-format/ALGOL-68/fasta-format.alg

24 lines
816 B
Text
Raw Permalink Normal View History

2023-07-18 13:51:12 -07:00
BEGIN # read FASTA format data from standard input and write the results to #
# standard output - only the ">" line start is handled #
BOOL at eof := FALSE;
on logical file end( stand in, ( REF FILE f )BOOL: at eof := TRUE );
WHILE STRING line;
read( ( line, newline ) );
NOT at eof
DO
2024-11-04 20:28:54 -08:00
IF line /= "" THEN # non-empty line #
INT start pos := LWB line;
BOOL is heading = line[ start pos ] = ">"; # check for heading line #
2023-07-18 13:51:12 -07:00
IF is heading THEN
print( ( newline ) );
2024-11-04 20:28:54 -08:00
start pos +:= 1
2023-07-18 13:51:12 -07:00
FI;
2024-11-04 20:28:54 -08:00
print( ( line[ start pos : ] ) );
2023-07-18 13:51:12 -07:00
IF is heading THEN print( ( ": " ) ) FI
FI
2024-11-04 20:28:54 -08:00
OD;
print( ( newline ) )
2023-07-18 13:51:12 -07:00
END