FASTA format: Difference between revisions

Content added Content deleted
(→‎version 1: rewritten)
(→‎version 2: rewritten)
 
Line 2,011: Line 2,011:
::*   sequences that contain blanks, tabs, and other whitespace
::*   sequences that contain blanks, tabs, and other whitespace
::*   sequence names that are identified with a semicolon   [''';''']
::*   sequence names that are identified with a semicolon   [''';''']
<syntaxhighlight lang="rexx">/*REXX program reads a (bio-informational) FASTA file and displays the contents. */
<syntaxhighlight lang="rexx">/*REXX program reads a (bio-informational) FASTA file and displays the contents. */
parse arg iFID . /*iFID: the input file to be read. */
Parse Arg iFID . /*iFID: the input file to be read. */
if iFID=='' then iFID='FASTA2.IN' /*Not specified? Then use the default.*/
If iFID=='' Then iFID='FASTA2.IN' /*Not specified? Then use the default.*/
name= /*the name of an output file (so far). */
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 FASTA file contents. */
/*the value of the output file's stuff.*/
x=strip( linein(iFID), 'T') /*read a line (a record) from the file,*/
Do While lines(iFID)\==0 /*process the FASTA file contents. */
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
if name=='' then name=substr(x,2)
When x=='' Then /* If the line is all blank, */
say x
Nop /* ignore it. */
When left(x,1)==';' Then Do
iterate
If name=='' Then name=substr(x,2)
end
if left(x, 1)=='>' then do
Say x
End
if $\=='' then say name':' $
When left(x,1)=='>' Then Do
name=substr(x, 2)
If data\=='' Then
$=
end
Say name':' data
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
data=space(data||translate(x, ,'*'),0)
End
End
If data\=='' Then
Say name':' data /* [?] show output of last file used. */
</syntaxhighlight>
<pre>
<pre>
'''input:''' &nbsp; The &nbsp; '''FASTA2.IN''' &nbsp; file is shown below:
'''input:''' &nbsp; The &nbsp; '''FASTA2.IN''' &nbsp; file is shown below: