Sha256: c9701691aabcf569189ddbaebab4f4c213102cb593851be7c6262def34aee887

Contents?: true

Size: 1.07 KB

Versions: 5

Compression:

Stored size: 1.07 KB

Contents

require 'scbi_zcat'

def load_isoform_hash(file)
	isoform_hash = {}
	if File.exists?(file)
		fasta = ScbiZcatFile.new(file)
	    filtered_fasta = ''
		seq_name = nil
		seq = ''
		while !fasta.eof
		        line = fasta.readline.chomp
		        if line[0] == '>'		                
						load_seq_in_hash(seq_name, seq, isoform_hash) if !seq_name.nil?
		                seq_name = line
		                seq = ''
		        else
		                seq << line
		        end
		end
		load_seq_in_hash(seq_name, seq, isoform_hash)
	end
	return isoform_hash
end

def load_seq_in_hash(seq_name, seq, isoform_hash)
	name, desc = seq_name.split(' ', 2) 
	name =~ /(\w+\|(\w+)\-\d+\|)/
	if isoform_hash[$2].nil?
		isoform_hash[$2] = ">#{$1}#{desc}\n#{seq}"
	else
		isoform_hash[$2] += "\n>#{$1}#{desc}\n#{seq}"
	end
end

def do_makeblastdb(seqs, output, dbtype)
	cmd="makeblastdb -in - -out #{output} -title #{File.basename(output)} -dbtype #{dbtype} -parse_seqids"
	IO.popen(cmd,'w+') {|makedb|
		makedb.sync = true
		makedb.write(seqs)
		makedb.close_write
		puts makedb.readlines
		makedb.close_read
	}
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
full_lengther_next-1.0.6 lib/full_lengther_next/handle_db.rb
full_lengther_next-1.0.5 lib/full_lengther_next/handle_db.rb
full_lengther_next-1.0.4 lib/full_lengther_next/handle_db.rb
full_lengther_next-1.0.3 lib/full_lengther_next/handle_db.rb
full_lengther_next-1.0.2 lib/full_lengther_next/handle_db.rb