Skip to content

Instantly share code, notes, and snippets.

View bsipos's full-sized avatar

Botond Sipos bsipos

View GitHub Profile
@bsipos
bsipos / fq_count_grep.sh
Last active May 1, 2020 11:34
fq_count_grep.sh
#!/bin/bash -
set -o nounset
for i in `seq 1 100`;
do
start=`date +%N`;
grep -c "^+$" test.fq >/dev/null;
end=`date +%N`;
TS=`expr $end - $start`;
TM=`echo $TS/1000.0 | bc -l`
echo -e "grep\t1\t$TM" >> count_timing.tsv;
#!/bin/bash -
set -o nounset # Treat unset variables as an error
TSV="count_timing.tsv"
CORES=2
TAGS=$1
echo -n "" > test.fq
for c in `seq 1 32`; do cat ../tests/pcs109_5k.fq >> test.fq; done
echo -e "Group\tBuffSize\tTime" > $TSV
#!/bin/bash -
set -o nounset # Treat unset variables as an error
TSV="big_count_timing.tsv"
CORES=2
TAGS="lines exact-buff buff-readahead"
echo -n "" > test.fq
for c in `seq 1 128`; do cat ../tests/pcs109_5k.fq >> test.fq; done
echo -e "Group\tBuffSize\tTime" > $TSV
// bufio
import "github.com/klauspost/readahead"
// ...
// Create new readahead buffered reader:
reader, err := readahead.NewReaderSize(fh, 100, buffSize)
checkError(err)
// ...
// CountFastxRecords counts the number of records in a fastx file.
func CountFastxRecords(fh *os.File, buffSize int, format string) int {
// Start the timer:
start := time.Now()
pattern := []byte{'\n', '+', '\n'} // Pattern to look for.
// Create new buffered reader:
reader := bufio.NewReaderSize(fh, buffSize)
// Byte buffer:
buffer := make([]byte, buffSize)
// Auxiliary buffer:
// CountFastxRecords counts the number of records in a fastx file.
func CountFastxRecords(fh *os.File, buffSize int, format string) int {
// Start the timer:
start := time.Now()
pattern := []byte("\n+\n") // Pattern to look for.
// Create new buffered reader:
reader := bufio.NewReaderSize(fh, buffSize)
// Byte buffer:
buffer := make([]byte, buffSize)
// Variable for counting records:
#!/bin/bash -
set -o nounset # Treat unset variables as an error
TSV="count_timing.tsv"
CORES=4
echo "Time" > $TSV
for i in `seq 1 10000`
do
seqkit -j $CORES count pcs109_5k.fq 1>/dev/null 2>> $TSV
done
// CountFastxRecords counts the number of records in a fastx file.
func CountFastxRecords(fh *os.File, buffSize int, format string) int {
// Start the timer:
start := time.Now()
pattern := "+\n" // Pattern to look for.
// Create new buffered reader:
reader := bufio.NewReaderSize(fh, buffSize)
// Variable for counting records:
var records int
func CountFastxRecords(fh *os.File, buffSize int, format string) int {
// Do the counting here.
return 0
}
#!/bin/bash
INPUT_FQ=demo_reads.fq
TRANSCRIPTOME="transcriptome.fas"
COUNT_TSV="online_counts.tsv"
COUNT_MONITOR="[ -f $COUNT_TSV ] && ( csvtk -t watch -O sec_dist.pdf -B 100 -f SecCount $COUNT_TSV ; sleep 2)" # script to monitor secondary read count distribution
csvtk cat $INPUT_FQ \
| seqkit seq -Q 3 \
| seqkit watch -x -f MeanQual -p 20000 \