Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sort extreme large pairs files #176

Open
andyyhchen opened this issue Aug 3, 2023 · 0 comments
Open

sort extreme large pairs files #176

andyyhchen opened this issue Aug 3, 2023 · 0 comments

Comments

@andyyhchen
Copy link

##sort -k2,2 -k4,4 -k3,3n -k5,5n ${prefix}_contacts.pairs | bgzip -c > ${prefix}_contacts.pairs.gz

Not sure if a sorted pair file is still required by pairix but I suggest to change the original sort -k2,2 -k4,4 -k3,3n -k5,5n ${prefix}_contacts.pairs | bgzip -c > ${prefix}_contacts.pairs.gz to the following to avoid segmentation fault when dealing with extremely large pair files (>50G).

    ##columns: readID chr1 pos1 chr2 pos2 strand1 strand2
    awk '{OFS="\t";print \$1,\$2,\$3,\$5,\$6,\$4,\$7}' $vpairs > ${prefix}_contacts.pairs
    awk '{file=\$2 ".chunk"}{print > file}' ${prefix}_contacts.pairs
    for X in *.chunk; do sort -k2,2 -k4,4 -k3,3n -k5,5n < \$X > sorted-\$X; done
    ls sorted-*.chunk | sort  -V | xargs cat > ${prefix}_contacts.pairs.tmp
    bgzip -c -@ 4  ${prefix}_contacts.pairs.tmp > ${prefix}_contacts.pairs.gz
    pairix -f ${prefix}_contacts.pairs.gz
    rm *chunk
    rm ${prefix}_contacts.pairs.tmp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant