FASTA format: Difference between revisions

→‎version 2: rewritten
(Added Easylang)
(→‎version 2: rewritten)
 
(One intermediate revision by the same user not shown)
Line 1,975:
===version 1===
This REXX version correctly processes the examples shown.
<syntaxhighlight lang="rexx">/*REXX program reads a (bio-informational) FASTA file and displays the contents. */
parseParse argArg iFIDifid . /* iFID: the input file to be read. */
If ifid=='' Then
if iFID=='' then iFID='FASTA.IN' /*Not specified? Then use the default.*/
name= ifid='FASTA.IN' /* Not specified? Then use /*the namedefault of an output file (so far). */
$name='' /* the name of an output file (so far) /*the value of the output file's stuff.*/
d='' do while lines(iFID)\==0 /*process the value FASTAof the output file's contents. */
Do While lines(ifid)\==0 x=strip( linein(iFID), 'T') /* process the FASTA file /*readcontents a line (a record) from the file,*/
x=strip(linein(ifid),'T') /* read a line (a record) from the input */
/* and strip trailing blanks /*───────── and strip trailing blanks. */
if left(x, 1)=='>' then do
If left(x,1)=='>' Then Do /* a new file id if $\=='' then say name':' $*/
Call out /* show output name=substr(x, and data 2)*/
name=substr(x,2) /* and get the new (or first) $=output name */
d='' end /* start with empty contents */
End
else $=$ || x
Else end /*j*/ /* a line with data /* [↓] show output of last file used. */
if $\= d=''d||x then say name':' $ /*stick aappend it to output fork in it, we're all done. */</syntaxhighlight>
End
Call end /*j*/ out /* [↓] show output of last file used. */
Exit
 
out:
$If d\=='' Then /* if there ara data /*the value of the output file's stuff.*/
Say name':' d /* show output name and data */
Return</syntaxhighlight>
{{out|output|text=&nbsp; when using the default input filename:}}
<pre>
Line 2,003 ⟶ 2,011:
::* &nbsp; sequences that contain blanks, tabs, and other whitespace
::* &nbsp; sequence names that are identified with a semicolon &nbsp; [''';''']
<syntaxhighlight lang="rexx">/*REXX program reads a (bio-informational) FASTA file and displays the contents. */
parseParse argArg iFID . /*iFID: the input file to be read. */
ifIf iFID=='' thenThen iFID='FASTA2.IN' /*Not specified? Then use the default.*/
name= '' /*the name of an output file (so far). */
data=''
$= /*the value of the output file's stuff.*/
do while lines(iFID)\==0 /*process the value FASTAof the output file's contentsstuff. */
Do While x=strip( lineinlines(iFID),\==0 'T') /*readprocess athe line (aFASTA record) fromfile contents. the file,*/
x=strip(linein(iFID),'T') /*read a line (a record) from the file,*/
/*───────── and strip trailing blanks. */
if x=='' then iterate /*If the line is all blank, ignore it /*--------- and strip trailing blanks. */
Select
if left(x, 1)==';' then do
When x=='' Then /* ifIf name==''the thenline name=substr(xis all blank,2) */
Nop say x /* ignore it. */
ifWhen left(x, 1)==';' Then then doDo
iterate
If name=='' Then name=substr(x, 2)
end
if left(Say x, 1)=='>' then do
End
if $\=='' then say name':' $
ifWhen left(x, 1)=='>' thenThen doDo
name=substr(x, 2)
If data\=='' Then
$=
Say name':' enddata
name=substr(x,2)
else $=space($ || translate(x, , '*'), 0)
data=''
end /*j*/ /* [↓] show output of last file used. */
End
if $\=='' then say name':' $ /*stick a fork in it, we're all done. */</syntaxhighlight>
Otherwise
else $data=space($ data|| translate(x, , '*'), 0)
End
End
If data\=='' Then
Say name':' data /* [?] if $\==''show output thenof saylast name':'file used. $*/
</syntaxhighlight>
<pre>
'''input:''' &nbsp; The &nbsp; '''FASTA2.IN''' &nbsp; file is shown below:
2,295

edits