FASTA format: Difference between revisions
→version 2: rewritten
Walterpachl (talk | contribs) (→version 2: rewritten) |
|||
(3 intermediate revisions by 3 users not shown) | |||
Line 704:
=={{header|Delphi}}==
See [https://rosettacode.org/wiki/FASTA_format#Pascal Pascal].
=={{header|EasyLang}}==
<syntaxhighlight>
repeat
s$ = input
until s$ = ""
if substr s$ 1 1 = ">"
if stat = 1
print ""
.
stat = 1
print s$
else
write s$
.
.
input_data
>Rosetta_Example_1
THERECANBENOSPACE
>Rosetta_Example_2
THERECANBESEVERAL
LINESBUTTHEYALLMUST
BECONCATENATED
</syntaxhighlight>
=={{header|F_Sharp|F#}}==
Line 719 ⟶ 744:
THERECANBESEVERALLINESBUTTHEYALLMUSTBECONCATENATED
</pre>
=={{header|Factor}}==
<syntaxhighlight lang="factor">USING: formatting io kernel sequences ;
Line 1,949 ⟶ 1,975:
===version 1===
This REXX version correctly processes the examples shown.
<syntaxhighlight lang="rexx">/*REXX program reads a (bio-informational)
If ifid=='' Then
d=''
Do While lines(ifid)\==0
x=strip(linein(ifid),'T') /* read a line (a record) from the input */
/* and strip trailing blanks
if left(x, 1)=='>' then do▼
If left(x,1)=='>' Then Do /* a new file id
Call out /* show output name
name=substr(x,2) /* and get the new (or first)
d=''
End
Else
End
Exit
out:
Say name':' d /* show output name and data */
Return</syntaxhighlight>
{{out|output|text= when using the default input filename:}}
<pre>
Line 1,977 ⟶ 2,011:
::* sequences that contain blanks, tabs, and other whitespace
::* sequence names that are identified with a semicolon [''';''']
<syntaxhighlight lang="rexx">/*REXX program reads a
name=
data=''
▲$= /*the value of the output file's stuff.*/
Do While
x=strip(linein(iFID),'T') /*read a line (a record) from the file,*/
Select
if left(x, 1)==';' then do▼
When x=='' Then /*
Nop
End
if $\=='' then say name':' $▼
▲ name=substr(x, 2)
If data\=='' Then
Say name':'
name=substr(x,2)
else $=space($ || translate(x, , '*'), 0)▼
data=''
▲ end /*j*/ /* [↓] show output of last file used. */
End
Otherwise
End
End
If data\=='' Then
</syntaxhighlight>
<pre>
'''input:''' The '''FASTA2.IN''' file is shown below:
Line 2,313 ⟶ 2,354:
</syntaxhighlight>
{{out}}
<pre>
Rosetta_Example_1: THERECANBENOSPACE
Rosetta_Example_2: THERECANBESEVERALLINESBUTTHEYALLMUSTBECONCATENATED
</pre>
=={{header|Tcl}}==
<syntaxhighlight lang="tcl">proc fastaReader {filename} {
|