Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
43
Task/FASTA-format/Go/fasta-format.go
Normal file
43
Task/FASTA-format/Go/fasta-format.go
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
f, err := os.Open("rc.fasta")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
defer f.Close()
|
||||
s := bufio.NewScanner(f)
|
||||
headerFound := false
|
||||
for s.Scan() {
|
||||
line := s.Text()
|
||||
switch {
|
||||
case line == "":
|
||||
continue
|
||||
case line[0] != '>':
|
||||
if !headerFound {
|
||||
fmt.Println("missing header")
|
||||
return
|
||||
}
|
||||
fmt.Print(line)
|
||||
case headerFound:
|
||||
fmt.Println()
|
||||
fallthrough
|
||||
default:
|
||||
fmt.Printf("%s: ", line[1:])
|
||||
headerFound = true
|
||||
}
|
||||
}
|
||||
if headerFound {
|
||||
fmt.Println()
|
||||
}
|
||||
if err := s.Err(); err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue