# Which command can subsample fasta file

**URL:** <https://forum.mothur.org/t/which-command-can-subsample-fasta-file/1688>\
**Category:** Commands in mothur\
**Created:** [February 14, 2014, 12:47am UTC](https://forum.mothur.org/t/which-command-can-subsample-fasta-file/1688 "2014-02-14T00:47:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sdpapet](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@sdpapet](https://forum.mothur.org/u/sdpapet)\
**Post date:** [February 14, 2014, 12:47am UTC](https://forum.mothur.org/t/which-command-can-subsample-fasta-file/1688/1 "2014-02-14T00:47:37Z")

</div>

Hi, I have 20 samples in 20 individual fasta files. I combine them together in one fasta file. I want to random sub-sample 1000 seqs from each fasta file (not subsample from OTU table, I want to do it before build otu table). I was wondering which command can let me do this. Can I use the combined large fasta file? Or, I have do it 20 times with the 20 individual files.

Thanks,

---

<div class="post-metadata">

**Author:** ![sdpapet](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@sdpapet](https://forum.mothur.org/u/sdpapet)\
**Post date:** [February 14, 2014, 4:07pm UTC](https://forum.mothur.org/t/which-command-can-subsample-fasta-file/1688/2 "2014-02-14T16:07:35Z")

</div>

Is it possible to do it? Thanks.

---

<div class="post-metadata">

**Author:** ![sdpapet](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@sdpapet](https://forum.mothur.org/u/sdpapet)\
**Post date:** [February 16, 2014, 5:34pm UTC](https://forum.mothur.org/t/which-command-can-subsample-fasta-file/1688/3 "2014-02-16T17:34:10Z")

</div>

?

---

<div class="post-metadata">

**Author:** ![dwaite](https://avatars.discourse-cdn.com/v4/letter/d/ecccb3/32.png) [@dwaite](https://forum.mothur.org/u/dwaite)\
**Post date:** [February 16, 2014, 9:15pm UTC](https://forum.mothur.org/t/which-command-can-subsample-fasta-file/1688/4 "2014-02-16T21:15:38Z")

</div>

If you have the fasta files and a corresponding group file is should just be as simple as:

sub.sample(fasta=XXX, group=XXX, size=1000, persample=T)

If you don’t have a group file, you can make one:

make.group(fasta=file1.fasta-file2.fasta-file3.fasta-…-filen.fasta, groups=group1-group2-group3-…-groupn, output=final.groups)
