RosettaCodeData/Task/FASTA-format/FreeBASIC/fasta-format.basic

39 lines
776 B
Plaintext

' FB 1.05.0 Win64
Function checkNoSpaces(s As String) As Boolean
For i As UInteger = 0 To Len(s) - 1
If s[i] = 32 OrElse s[i] = 9 Then Return False '' check for spaces or tabs
Next
Return True
End Function
Open "input.fasta" For Input As # 1
Dim As String ln, seq
Dim first As Boolean = True
While Not Eof(1)
Line Input #1, ln
If Left(ln, 1) = ">" Then
If Not first Then Print
Print Mid(ln, 2); ": ";
If first Then first = False
ElseIf first Then
Print: Print "Error : File does not begin with '>'";
Exit While
Else
If checkNoSpaces(ln) Then
Print ln;
Else
Print : Print "Error : Sequence contains space(s)";
Exit While
End If
End If
Wend
Close #1
Print : Print
Print "Press any key to quit"
Sleep