func ParseGbk(file []byte) Sequence {

	gbk := string(file)
	lines := strings.Split(gbk, "\n")

	// Create meta struct
	meta := Meta{}
	meta.Other = make(map[string]string)

	// Create features struct
	features := []Feature{}

	// Create sequence struct
	sequence := Sequence{}

	for numLine := 0; numLine < len(lines); numLine++ {
		line := lines[numLine]
		splitLine := strings.Split(line, " ")
		subLines := lines[numLine+1:]

		// This is to keep the cursor from scrolling to the bottom another time after GetSequence() is called.
		// Break has to be in scope and can't be called within switch statement.
		// Otherwise it will just break the switch which is redundant.
		sequenceBreakFlag := false
		if sequenceBreakFlag {
			break
		}

		switch strings.TrimSpace(splitLine[0]) {

		case "":
			continue
		case "LOCUS":
			meta.Locus = parseLocus(line)
		case "DEFINITION":
			meta.Definition = joinSubLines(splitLine, subLines)
		case "ACCESSION":
			meta.Accession = joinSubLines(splitLine, subLines)
		case "VERSION":
			meta.Version = joinSubLines(splitLine, subLines)
		case "KEYWORDS":
			meta.Keywords = joinSubLines(splitLine, subLines)
		case "SOURCE":
			meta.Source, meta.Organism = getSourceOrganism(splitLine, subLines)
		case "REFERENCE":
			meta.References = append(meta.References, getReference(splitLine, subLines))
			continue
		case "FEATURES":
			features = getFeatures(subLines)
		case "ORIGIN":
			sequence.Sequence = getSequence(subLines)
			sequenceBreakFlag = true
		default:
			if quickMetaCheck(line) {
				key := strings.TrimSpace(splitLine[0])
				meta.Other[key] = joinSubLines(splitLine, subLines)
			}
		}

	}

	// add meta to annotated sequence
	sequence.Meta = meta

	// add features to annotated sequence with pointer to annotated sequence in each feature
	for _, feature := range features {
		sequence.AddFeature(feature)
	}

	return sequence
}
// ParseGbk takes in a string representing a gbk/gb/genbank file and parses it into an Sequence object.
ParseGbk takes in a string representing a gbk/gb/genbank file and parses it into an Sequence object.
// ParseGbk takes in a string representing a gbk / gb / genbank file and parses it into an Sequence object .
func ParseGbk(file []byte) Sequence {
	gbk := string(file)
	lines := strings.Split(gbk, "\n")
	meta := Meta{}
	meta.Other = make(map[string]string)
	features := []Feature{}
	sequence := Sequence{}
	for numLine := 0; numLine < len(lines); numLine++ {
		line := lines[numLine]
		splitLine := strings.Split(line, " ")
		subLines := lines[numLine+1:]
		sequenceBreakFlag := false
		if sequenceBreakFlag {
			break
		}
		switch strings.TrimSpace(splitLine[0]) {
		case "":
			continue
		case "LOCUS":
			meta.Locus = parseLocus(line)
		case "DEFINITION":
			meta.Definition = joinSubLines(splitLine, subLines)
		case "ACCESSION":
			meta.Accession = joinSubLines(splitLine, subLines)
		case "VERSION":
			meta.Version = joinSubLines(splitLine, subLines)
		case "KEYWORDS":
			meta.Keywords = joinSubLines(splitLine, subLines)
		case "SOURCE":
			meta.Source, meta.Organism = getSourceOrganism(splitLine, subLines)
		case "REFERENCE":
			meta.References = append(meta.References, getReference(splitLine, subLines))
			continue
		case "FEATURES":
			features = getFeatures(subLines)
		case "ORIGIN":
			sequence.Sequence = getSequence(subLines)
			sequenceBreakFlag = true
		default:
			if quickMetaCheck(line) {
				key := strings.TrimSpace(splitLine[0])
				meta.Other[key] = joinSubLines(splitLine, subLines)
			}
		}
	}
	sequence.Meta = meta
	for _, feature := range features {
		sequence.AddFeature(feature)
	}
	return sequence
}
func ParseGbk ( file [ ] byte ) Sequence { gbk := string ( file ) lines := strings . Split ( gbk , " \n " ) meta := Meta { } meta . Other = make ( map [ string ] string ) features := [ ] Feature { } sequence := Sequence { } for numLine := 0 ; numLine < len ( lines ) ; numLine ++ { line := lines [ numLine ] splitLine := strings . Split ( line , " " ) subLines := lines [ numLine + 1 : ] sequenceBreakFlag := false if sequenceBreakFlag { break } switch strings . TrimSpace ( splitLine [ 0 ] ) { case " " : continue case " " : meta . Locus = parseLocus ( line ) case " " : meta . Definition = joinSubLines ( splitLine , subLines ) case " " : meta . Accession = joinSubLines ( splitLine , subLines ) case " " : meta . Version = joinSubLines ( splitLine , subLines ) case " " : meta . Keywords = joinSubLines ( splitLine , subLines ) case " " : meta . Source , meta . Organism = getSourceOrganism ( splitLine , subLines ) case " " : meta . References = append ( meta . References , getReference ( splitLine , subLines ) ) continue case " " : features = getFeatures ( subLines ) case " " : sequence . Sequence = getSequence ( subLines ) sequenceBreakFlag = true default : if quickMetaCheck ( line ) { key := strings . TrimSpace ( splitLine [ 0 ] ) meta . Other [ key ] = joinSubLines ( splitLine , subLines ) } } } sequence . Meta = meta for _ , feature := range features { sequence . AddFeature ( feature ) } return sequence }
ParseGbk takes in a string representing a gbk/gb/genbank file and parses it into an Sequence object.
ParseGbk takes in a string representing a gbk / gb / genbank file and parses it into an Sequence object .
// Create meta struct // Create features struct // Create sequence struct // This is to keep the cursor from scrolling to the bottom another time after GetSequence() is called. // Break has to be in scope and can't be called within switch statement. // Otherwise it will just break the switch which is redundant. // add meta to annotated sequence // add features to annotated sequence with pointer to annotated sequence in each feature