Created
October 21, 2017 19:02
-
-
Save bsipos/622ed9bbb3f9bf676b0b803c54f04b32 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 required libraries: | |
import ( | |
"fmt" | |
"github.com/biogo/hts/bam" | |
"github.com/biogo/hts/sam" | |
"io" | |
"os" | |
) | |
func main() { | |
//Open the input file for reading: | |
ifh, err := os.Open(os.Args[1]) | |
//Panic if something went wrong: | |
if err != nil { | |
panic(err) | |
} | |
//Create a new BAM reader with maximum | |
//concurrency: | |
bamReader, err := bam.NewReader(ifh, 0) | |
if err != nil { | |
panic(err) | |
} | |
for { | |
//Read next record: | |
record, err := bamReader.Read() | |
//Break out of loop if we reached the end | |
//of the file: | |
if err == io.EOF { | |
break | |
} | |
// Print out record name if read is mapped: | |
if record.Flags&sam.Unmapped == 0 { | |
fmt.Println(record.Name) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment