func ParseConcurrent(r io.Reader, sequences chan<- Fasta) {
	// Initialize necessary variables
	var sequenceLines []string
	var name string
	start := true

	// Start the scanner
	scanner := bufio.NewScanner(r)
	for scanner.Scan() {
		line := scanner.Text()
		switch {
		// if there's nothing on this line skip this iteration of the loop
		case len(line) == 0:
			continue
		// if it's a comment skip this line
		case line[0:1] == ";":
			continue
		// start of a fasta line
		case line[0:1] != ">":
			sequenceLines = append(sequenceLines, line)
		// Process normal new lines
		case line[0:1] == ">" && !start:
			sequence := strings.Join(sequenceLines, "")
			newFasta := Fasta{
				Name:     name,
				Sequence: sequence}
			// Reset sequence lines
			sequenceLines = []string{}
			// New name
			name = line[1:]
			sequences <- newFasta
		// Process first line of file
		case line[0:1] == ">" && start:
			name = line[1:]
			start = false
		}
	}
	// Add final sequence in file to channel
	sequence := strings.Join(sequenceLines, "")
	newFasta := Fasta{
		Name:     name,
		Sequence: sequence}
	sequences <- newFasta
	close(sequences)
}
// ParseConcurrent concurrently parses a given Fasta file in an io.Reader into a channel of Fasta structs.
ParseConcurrent concurrently parses a given Fasta file in an io.Reader into a channel of Fasta structs.
// ParseConcurrent concurrently parses a given Fasta file in an io . Reader into a channel of Fasta structs .
func ParseConcurrent(r io.Reader, sequences chan<- Fasta) {
	var sequenceLines []string
	var name string
	start := true
	scanner := bufio.NewScanner(r)
	for scanner.Scan() {
		line := scanner.Text()
		switch {
		case len(line) == 0:
			continue
		case line[0:1] == ";":
			continue
		case line[0:1] != ">":
			sequenceLines = append(sequenceLines, line)
		case line[0:1] == ">" && !start:
			sequence := strings.Join(sequenceLines, "")
			newFasta := Fasta{
				Name:     name,
				Sequence: sequence}
			sequenceLines = []string{}
			name = line[1:]
			sequences <- newFasta
		case line[0:1] == ">" && start:
			name = line[1:]
			start = false
		}
	}
	sequence := strings.Join(sequenceLines, "")
	newFasta := Fasta{
		Name:     name,
		Sequence: sequence}
	sequences <- newFasta
	close(sequences)
}
func ParseConcurrent ( r io . Reader , sequences chan <- Fasta ) { var sequenceLines [ ] string var name string start := true scanner := bufio . NewScanner ( r ) for scanner . Scan ( ) { line := scanner . Text ( ) switch { case len ( line ) == 0 : continue case line [ 0 : 1 ] == " " : continue case line [ 0 : 1 ] != " " : sequenceLines = append ( sequenceLines , line ) case line [ 0 : 1 ] == " " && ! start : sequence := strings . Join ( sequenceLines , " " ) newFasta := Fasta { Name : name , Sequence : sequence } sequenceLines = [ ] string { } name = line [ 1 : ] sequences <- newFasta case line [ 0 : 1 ] == " " && start : name = line [ 1 : ] start = false } } sequence := strings . Join ( sequenceLines , " " ) newFasta := Fasta { Name : name , Sequence : sequence } sequences <- newFasta close ( sequences ) }
ParseConcurrent concurrently parses a given Fasta file in an io.Reader into a channel of Fasta structs.
ParseConcurrent concurrently parses a given Fasta file in an io . Reader into a channel of Fasta structs .
// Initialize necessary variables // Start the scanner // if there's nothing on this line skip this iteration of the loop // if it's a comment skip this line // start of a fasta line // Process normal new lines // Reset sequence lines // New name // Process first line of file // Add final sequence in file to channel