get.otulist (or get.seqlist?)

Dear forum members,

I find the command get.otulist very useful, because the list generated can easily be imported into Excel for a good overview. However, what would be equally useful is the reverse of the get.otulist command, instead of a file where the first column is the OTU and the second a list of sequences that belong to that OTU, I would like a file where the first column contains the sequence names and the second the OTU each sequence belongs to. I realize that bin.seqs does something similar, but I am not interested in the fasta file, I want something that can be imported into Excel or R. Any ideas on how to achieve this?

Thanks in advance,

/ Mia Bengtsson

Dear mothur users,

If anyone else needs to convert a mothur .otu file into a list of sequences with the otus they belong to in the next column, I have a script for R that can do this and output the result as a textfile. It is useful if you want to use a spreadsheet to keep track of your sequences for example. Script is below, thanks to Agurtzane Urtizberea for writing it for me.

/ Mia

otu_mothur2<-gsub(pattern= “\t”, otu_mothur, replacement=",")
N = length(otu_mothur2)
seq = NULL
otu = NULL
otu_list = NULL
for (i in 1:N){
seq=c(seq,unlist(strsplit(otu_mothur2_, “,”))[-1])
Notu_seq = length(unlist(strsplit(otu_mothur2_, “,”))[-1])
otu = c(otu,rep(unlist(strsplit(otu_mothur2_, “,”))[1],Notu_seq))
otu_list$seq = seq
write.table((,"/path/otu_list.txt", sep= “\t”, row.names=F)___

Thanks for the suggestion! The get.otulist command will include a sort parameter in version 1.11.0, so you can get the output you are looking for.