Created
October 21, 2017 19:26
-
-
Save bsipos/96ce781912039b6bedaaa55f171490c0 to your computer and use it in GitHub Desktop.
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 the necessary libraries: | |
import ( | |
"fmt" | |
"github.com/biogo/biogo/io/featio/bed" | |
"io" | |
"os" | |
) | |
func main() { | |
//Open BED file for reading: | |
inBed, err := os.Open(os.Args[1]) | |
//Panic if something goes wrong: | |
if err != nil { | |
panic(err) | |
} | |
//Create a new reader for 3-column BED format: | |
bedReader, err := bed.NewReader(inBed, 3) | |
if err != nil { | |
panic(err) | |
} | |
for { | |
//Read next BED record: | |
bedRec, err := bedReader.Read() | |
//Break out at EOF: | |
if err == io.EOF { | |
break | |
} | |
//Print out Location, Start and End: | |
fmt.Printf("Chrom: %s Start: %d End: %d\n", bedRec.Location(), bedRec.Start(), bedRec.End()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment