Thanks for linking that Mensur.
@OP, the script linked above will do what you are looking for I think, but just a few words of warning:
- There actually isn't a 100% reliable way to do this to the best of my knowledge (and I was never able to find any existing tools or built in functions either, but maybe there are some more recent updates have changed this - it was a long time ago).
- My script will work, but you must make absolutely sure that the headers of your sequences are all unique, and differentiate between the sequences adequately ideally within the first 10-20 characters. Even with the
-d 0flag that the script instructions mention, CD-HIT will still truncate the Seq IDs in the.clstrfile if memory serves. - It's highly likely the script can be improved upon, as I wrote it a way back. It will work assuming nothing has changed in the output format.
Does not appear that there is a single tool to do this. You are on the right track. GPT was able to generate a code recommendation that was 3 steps. Ask "how to extract fasta consensus from cd-hit clusters".
I have tried that a few times, and even with shiny new GPT 5 it was not able to make something that actually worked. Maybe I am not giving it enough context but it hasn't been able to properly extract multiple transcript sequences from the fasta.clstr file, pull them the .fasta file, and put them into a new file.
As in different splice variants?
We have a rna-seq transcriptome that we ran CD-HIT-EST on, so it should contain different splice variants but also just different genes. I may be misunderstanding your question though.
The .clstr file looks like this:
There was a frameshift mutation in some transcripts during sequencing, and we are trying to identify when/where the mutation occurred. We want to use this data to manually verify sequence similarity (For example, the first 50% of our sequence is identical and the last 50% is totally new. If we add this a/t/c/g into our transcript, it is now highly similar/identical to our sequence of interest).
I was looking for a script that takes
IsoSeq_HQ_transcript/0out of the.fasta.clstrfile and put them into a.fastafile with the nameCluster_#.fasta, even if there is one sequence per cluster.Looking at the name of the sequences, it looks like this is a PacBio IsoSeq dataset. Is CD-HIT the only analysis you have tried so far? Perhaps the cluster you are looking at above is not full length sequences. Did you consider that possibility?
In case you have not tried it already, you may want to use a tool that is provided by PacBio for this specific analysis. https://isoseq.how/
The python script I suggested below does just that. The only thing you must do during the clustering step is set
-dto a large number (like 200-300) so that the whole sequence name is preserved in cluster file.