FASTX
Read and write files in FASTA and FASTQ format, the most common biological sequence file format.
Installation
You can install FASTX from the julia REPL. Press ]
to enter pkg mode again, and enter the following:
(v1.8) pkg> add FASTX
Quickstart
See more documentation in the sections in the sidebar.
Read FASTA or FASTQ files
It is preferred to use the do
syntax to automatically close the file when you're done with it:
julia> FASTAReader(open("../test/data/test.fasta")) do reader
for record in reader
println(identifier(record))
end
end
abc
Alternatively, you can open and close the reader manually:
julia> reader = FASTAReader(open("../test/data/test.fasta"));
julia> for record in reader
println(identifier(record))
end
abc
julia> close(reader)
Write FASTA or FASTQ files
julia> FASTQWriter(open(tempname(), "w")) do writer
write(writer, FASTQRecord("abc", "TAG", "ABC"))
end
15
Read and write Gzip compressed FASTA files
julia> using CodecZlib
julia> FASTAReader(GzipDecompressorStream(open("../test/data/seqs.fna.gz"))) do reader
for record in reader
println(identifier(record))
end
end
seqa
seqb
julia> FASTQWriter(GzipCompressorStream(open(tempname(), "w"))) do writer
write(writer, FASTQRecord("header", "sequence", "quality!"))
end
28
Construct FASTA or FASTQ records from raw parts
julia> fasta_record = FASTARecord("some header", dna"TAGAAGA");
julia> fastq_record = FASTQRecord("read1", "TAGA", "ABCD");
Validate that a file (or an arbitrary IO
) is well-formatted
The validate_fast*
functions return nothing
if the IO is well formatted
julia> validate_fasta(IOBuffer(">ABC\nDEF")) === nothing
true
julia> validate_fastq(IOBuffer("@ABC\nTAG\n+\nDDD")) === nothing
true
To check if files are well-formatted:
julia> open(validate_fasta, "../test/data/test.fasta") === nothing
true
julia> open(validate_fasta, "Project.toml") === nothing
false
Contributing
We appreciate contributions from users including reporting bugs, fixing issues, improving performance and adding new features.
Take a look at the contributing files detailed contributor and maintainer guidelines, and code of conduct.