-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
79 lines (64 loc) · 1.4 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package main
import (
"bufio"
"flag"
"fmt"
"log"
"os"
"strings"
)
/*
Author Gaurav Sablok
Universitat Potsdam
Date 2024-9-17
Check out the complete alignmentGo package for dealing with all alignment functions.
*/
func main() {
alignment := flag.String("alignmentfile", "path to the alignment file", "file")
title := flag.String("title", "name of the header of the gene", "gene name")
flag.Parse()
type alignmentID struct {
id string
}
type alignmentSeq struct {
seq string
}
type alignmentFilterID struct {
id string
}
type alignmentFilterSeq struct {
seq string
}
fOpen, err := os.Open(*alignment)
if err != nil {
log.Fatal(err)
}
// file opening and storing into structs
fRead := bufio.NewScanner(fOpen)
alignmentReadID := []alignmentID{}
alignmentReadSeq := []alignmentSeq{}
for fRead.Scan() {
line := fRead.Text()
if strings.HasPrefix(string(line), ">") {
alignmentReadID = append(alignmentReadID, alignmentID{
id: string(line),
})
}
if !strings.HasPrefix(string(line), ">") {
alignmentReadSeq = append(alignmentReadSeq, alignmentSeq{
seq: string(line),
})
}
}
var seqFilter string
for i := range alignmentReadSeq {
for j := range alignmentReadSeq[i].seq {
if string(alignmentReadSeq[i].seq[j]) == "-" {
continue
} else {
seqFilter += string(alignmentReadSeq[i].seq[j])
}
}
}
fmt.Println(">", *title, "\n", seqFilter)
}