Thanks Erik. I have got something but I can not get the sequence along the row with the isogroup, contig information. Sorry I can't get the sequences beside the Contig information
read FASTA file in R, including description information
Hello everybody
I'm trying to import a: *.fna file, in R, and I have no idea how to deal with it. I would need to have columns like these: Isogroup, Contigs, Length, Sequence. As one Isogroup contain more that one Contig they will be repeated; but that is exactly what I want. I will appreciate your help. An example file is included. They have paragraph tab after each line.
Regards
Roberto
>contig00002 gene=isogroup00001 length=656
CTAATCCTCAAACCCGAACTCATCTCAGGCCTCCCTATATGCAAGTATAGTTTCAACCCA
CTCCCCACACCATCAAACATCTCAGCTTGATGAAATTTCGGGTCATTACTGGGCATTTGC
>contig00004 gene=isogroup00001 length=566
CACAGATACAGATGGTTGGGGATGCAACAGTCCTCATCCTACTTCGTAATCGCGGCATTC
>contig00005 gene=isogroup00001 length=1152
CTCCCCACACCATCAAACATCTCAGCTTGATGAAATTTCGGGTCATTACTGGGCATTTGC
>contig00007 gene=isogroup00001 length=547
AACCCAACCAAAGCATTTGCCAGTCCCAGTATAGGCGATAGAAAAGACACCATTGGAGCG
>contig00008 gene=isogroup00001 length=698
AaGGgGGGGGggTGGTTCTCGTAGTTAAATGCTTATAACAGtGGCTTTTCAGGCCGTTGA
>contig00024 gene=isogroup00001 length=2170
CTTGGACGCTCTATTATCCCGTGTGAATCATCCCGTCGTCATTTGTCGGGGCTGGGAGAG
• 22,302 views
•
link
2 answers
You could use the readDNAStringSet function in the Biostrings package:
library(Biostrings)
dna <- readDNAStringSet("<<PATH TO FASTA FILE>>")
s <- strsplit(names(dna), "[ \t]+") # split names by tab/space
info <- matrix(unlist(s), ncol=3, byrow=T)
More text parsing may be added as desired. Hope that helps!
• 0 views
•
link
• 0 views
•
link
Check out the readFASTA() method in the Biostrings Bioconductor package. Some postprocessing will be needed to get a data.frame with the columns as you describe.
• 0 views
•
link
Log in to answer this question.