Sha256: bb8299b2a43c3ee38660e517b553fea6c757a6f47f9c571bfb2c9e85a86df0e1
Contents?: true
Size: 1.46 KB
Versions: 1
Compression:
Stored size: 1.46 KB
Contents
#!/usr/bin/env ruby require "bio" require "thor" class AcnfpTransCounter < Thor desc "analyse FILENAME", "Run acnfp-trans-counter on a given alignment" def analyse(filename) alignments = Bio::FlatFile.open(filename) alignments.to_a.combination(2) do |a,b| transition_count = 0 transversion_count = 0 indel_count = 0 informative_count = 0 alignment = Bio::Alignment::OriginalAlignment.new([a,b]) alignment.each_site do |site| next if site.has_gap? if site[0] == site[1] or site.include? "N" informative_count += 1 next end case site.sort.map{|char| char.upcase} when %w{C T}, %w{A G} transition_count += 1 when %w{A C}, %w{A T}, %w{C G}, %w{G T} transversion_count += 1 else raise "Unknown pairing: #{site}" end end mutation_count = transversion_count + transition_count.to_f header = "%s vs %s" % [a.definition, b.definition] puts header puts "=" * header.length puts "Transversions: %d (%.2f%%)" % [transversion_count, 100 * transversion_count / mutation_count] puts "Transitions: %d (%.2f%%)" % [transition_count, 100 * transition_count / mutation_count] puts "Transversions / Transitions: %.2f" % [transversion_count.to_f / transition_count] puts "Non-indel sites: %d" % informative_count puts end end end AcnfpTransCounter.start
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
acnfp-trans-counter-0.2.0 | bin/acnfp-trans-counter |