Created
May 29, 2012 08:23
-
-
Save yagays/2823292 to your computer and use it in GitHub Desktop.
NGSのサンプルデータっぽい感じで,fastaから適当に短い配列取ってきてfastqにするスクリプト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #/usr/bin/env ruby | |
| # usage: | |
| # ruby rand_fastq.rb hoge.fasta > random.fastq | |
| require 'bio' | |
| genome = "" | |
| read_length = 100 | |
| read_count = 10000000 | |
| Bio::FlatFile.open(Bio::FastaFormat,ARGV[0]).each do |e| | |
| genome << e.naseq.gsub(/n/,"") | |
| end | |
| random_start = Array.new( read_count ){ rand genome.length - read_length} | |
| random_start.each_with_index do |r,i| | |
| seq = Bio::Sequence.new(genome[r, read_length].upcase) | |
| puts seq.output(:fastq, :title=> "random_"+i.to_s, :width => read_length) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment