This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"fmt" | |
"os" | |
"strings" | |
) | |
func main() { | |
var gc int = 0 | |
var at int = 0 | |
var line string | |
var err error | |
file, err := os.Open("Homo_sapiens.GRCh37.67.dna_rm.chromosome.Y.fa") | |
var fileReader *bufio.Reader = bufio.NewReader(file) | |
for err == nil { | |
line, err = fileReader.ReadString('\n') | |
if !strings.HasPrefix(line, ">") { | |
var curChar byte | |
for i := 0; i < len(line); i++ { | |
curChar = line[i] | |
if curChar == 'G' || curChar == 'C' { | |
gc++ | |
} else if curChar == 'T' || curChar == 'A' { | |
at++ | |
} | |
} | |
} | |
} | |
var gcFraction float32 = float32(gc) / float32(at+gc) | |
fmt.Println(gcFraction * 100) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment