# Indexing a fasta file with FASTX.jl

**URL:** <https://discourse.julialang.org/t/indexing-a-fasta-file-with-fastx-jl/72457>\
**Category:** Biology, Health, and Medicine\
**Tags:** question, package\
**Created:** [December 2, 2021, 3:04pm UTC](https://discourse.julialang.org/t/indexing-a-fasta-file-with-fastx-jl/72457 "2021-12-02T15:04:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lamma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lamma/32/31006_2.png) [@Lamma](https://discourse.julialang.org/u/Lamma)\
**Post date:** [December 2, 2021, 3:04pm UTC](https://discourse.julialang.org/t/indexing-a-fasta-file-with-fastx-jl/72457/1 "2021-12-02T15:04:54Z")

</div>

I have been informed it is possible to use `FASTX.jl` to index a file. However I am struggling to do this. I think I am meant to use `FASTA:Record()` but am unsure how to pass the data to the function.

```julia
reader = FASTA.Reader(GzipDecompressorStream(open("D:/OneDrive - University of Copenhagen/PhD/Projects/Termite_metagenomes/assembly/small_megahit_final_assembly.fa.gz")))
indexed = FASTA.Record(reader)

ERROR: MethodError: no method matching FASTX.FASTA.Record(::FASTX.FASTA.Reader{TranscodingStreams.TranscodingStream{GzipDecompressor, IOStream}})

```

---

<div class="post-metadata">

**Author:** ![jonathanBieler](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jonathanBieler](https://discourse.julialang.org/u/jonathanBieler)\
**Post date:** [December 2, 2021, 4:18pm UTC](https://discourse.julialang.org/t/indexing-a-fasta-file-with-fastx-jl/72457/2 "2021-12-02T16:18:02Z")

</div>

By index you mean creating a .fai file ? I don’t think that’s possible with FASTX (see [https://github.com/BioJulia/FASTX.jl/blob/be4082269bff2a797afe54dd3cd94051ca6affce/src/fasta/index.jl](https://github.com/BioJulia/FASTX.jl/blob/be4082269bff2a797afe54dd3cd94051ca6affce/src/fasta/index.jl)).

If you already have an index however you can pass it to `Reader` :

> FASTA.Reader(input::IO; index = nothing)

Not sure how you use it though, or if it works with fastqs.

If you just want to read a Record you can just do :

```julia
 record = FASTA.Record()
 read!(reader, record)

```

See the docs: [biojulia.net](https://biojulia.net/FASTX.jl/stable/manual/fastq/)
