func BuildDict(filename string) ([]string, map[string]int, error) {
	f, err := os.Open(filename)
	if err != nil {
		return nil, nil, err
	}
	defer f.Close()

	r := bufio.NewReader(f)

	cols := []string{"seqname", "source", "feature", "start", "end", "score", "strand", "frame"}
	colMap := map[string]int{}
	for k, v := range cols {
		colMap[v] = k
	}

	var line string
	for i := 0; ; i++ {
		// row, err := r.Read()
		line, err = r.ReadString('\n')
		if err == io.EOF {
			break
		} else if err != nil {
			return nil, nil, fmt.Errorf("GTF 0-based row %d error %s: %s", i, err, line)
		}

		lineCandidate := strings.TrimSuffix(line, "\n")
		if strings.HasPrefix(lineCandidate, "#") {
			continue
		}

		row := strings.Split(lineCandidate, "\t")

		if x := len(row); x < 9 {
			return nil, nil, fmt.Errorf("GTF 0-based row %d had %d lines, expected 9", i, x)
		}

		attributes, err := ParseAttributes(row[8])
		if err != nil {
			return nil, nil, fmt.Errorf("Line %d: %s (%+v)", i, err, row[8])
		}

		for _, attr := range attributes {
			if _, exists := colMap[attr.Key]; !exists {
				log.Println("Found new column:", attr.Key)
				cols = append(cols, attr.Key)
				colMap[attr.Key] = len(cols) - 1
			}
		}
	}

	return cols, colMap, nil
}
// BuildDict performs the first pass to identify exhaustively all possible
// columns and what order they were seen in
BuildDict performs the first pass to identify exhaustively all possible
columns and what order they were seen in
// BuildDict performs the first pass to identify exhaustively all possible // columns and what order they were seen in
func BuildDict(filename string) ([]string, map[string]int, error) {
	f, err := os.Open(filename)
	if err != nil {
		return nil, nil, err
	}
	defer f.Close()
	r := bufio.NewReader(f)
	cols := []string{"seqname", "source", "feature", "start", "end", "score", "strand", "frame"}
	colMap := map[string]int{}
	for k, v := range cols {
		colMap[v] = k
	}
	var line string
	for i := 0; ; i++ {
		line, err = r.ReadString('\n')
		if err == io.EOF {
			break
		} else if err != nil {
			return nil, nil, fmt.Errorf("GTF 0-based row %d error %s: %s", i, err, line)
		}
		lineCandidate := strings.TrimSuffix(line, "\n")
		if strings.HasPrefix(lineCandidate, "#") {
			continue
		}
		row := strings.Split(lineCandidate, "\t")
		if x := len(row); x < 9 {
			return nil, nil, fmt.Errorf("GTF 0-based row %d had %d lines, expected 9", i, x)
		}
		attributes, err := ParseAttributes(row[8])
		if err != nil {
			return nil, nil, fmt.Errorf("Line %d: %s (%+v)", i, err, row[8])
		}
		for _, attr := range attributes {
			if _, exists := colMap[attr.Key]; !exists {
				log.Println("Found new column:", attr.Key)
				cols = append(cols, attr.Key)
				colMap[attr.Key] = len(cols) - 1
			}
		}
	}
	return cols, colMap, nil
}
func BuildDict ( filename string ) ( [ ] string , map [ string ] int , error ) { f , err := os . Open ( filename ) if err != nil { return nil , nil , err } defer f . Close ( ) r := bufio . NewReader ( f ) cols := [ ] string { " " , " " , " " , " " , " " , " " , " " , " " } colMap := map [ string ] int { } for k , v := range cols { colMap [ v ] = k } var line string for i := 0 ; ; i ++ { line , err = r . ReadString ( '\n' ) if err == io . EOF { break } else if err != nil { return nil , nil , fmt . Errorf ( " " , i , err , line ) } lineCandidate := strings . TrimSuffix ( line , " \n " ) if strings . HasPrefix ( lineCandidate , " " ) { continue } row := strings . Split ( lineCandidate , " \t " ) if x := len ( row ) ; x < 9 { return nil , nil , fmt . Errorf ( " " , i , x ) } attributes , err := ParseAttributes ( row [ 8 ] ) if err != nil { return nil , nil , fmt . Errorf ( " " , i , err , row [ 8 ] ) } for _ , attr := range attributes { if _ , exists := colMap [ attr . Key ] ; ! exists { log . Println ( " " , attr . Key ) cols = append ( cols , attr . Key ) colMap [ attr . Key ] = len ( cols ) - 1 } } } return cols , colMap , nil }
BuildDict performs the first pass to identify exhaustively all possible
columns and what order they were seen in
BuildDict performs the first pass to identify exhaustively all possible columns and what order they were seen in
// row, err := r.Read()