[R] Convert CSV file to FASTA

Mike Marchywka marchywka at hotmail.com
Wed Aug 31 13:34:48 CEST 2011


















----------------------------------------
> Date: Wed, 31 Aug 2011 01:36:51 -0700
> From: oliviacreemer at gmail.com
> To: r-help at r-project.org
> Subject: [R] Convert CSV file to FASTA
>
> Hi there,
>
> I have large excel files which I can save as CSV files.
>
> Each excel file contains two columns. One contains the chromosome number and
> the second contains a DNA sequence.
>
> I need to convert this into a fasta file that looks like this
> >chromosomenumber
> CGTCGAGCGTCGAGCGGAGCG....
>
> Can anyone show me an R script to do this?
>

If you can post a few lines of your "csv" someone can probably give you a bach
script to do it. It may be possible in R but sed/awk probbly work better. IIRC, fasta
is just a name line followed by sequence. If your csv looks like "name, XXXXXXXXXX"
it may be possible to change comma to space and use awk with something like print ">"$1"\n"$2 
etc.



> Many thanks
>
> x
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Convert-CSV-file-to-FASTA-tp3780498p3780498.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
 		 	   		  


More information about the R-help mailing list