Skip to content

Instantly share code, notes, and snippets.

@holgerbrandl
Last active December 1, 2016 16:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save holgerbrandl/521a5e9b1eb0d5b443b82cf13f66074f to your computer and use it in GitHub Desktop.
Save holgerbrandl/521a5e9b1eb0d5b443b82cf13f66074f to your computer and use it in GitHub Desktop.
A kscript/kotlin tool to filter fasta files by length
//DEPS de.mpicbg.scicomp:kutils:0.4
//KOTLIN_OPTS -J-Xmx5g
import de.mpicbg.scicomp.bioinfo.openFasta
import java.io.File
import kotlin.system.exitProcess
if (args.size != 2) {
System.err.println("Usage: fasta_filter <fasta> <length_cutoff>")
exitProcess(-1)
}
val fastaFile = File(args[0])
val lengthCutoff = args[1].toInt()
openFasta(fastaFile).
filter { it.sequence.length >= lengthCutoff }.
forEach { print(it.toEntryString()) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment