- Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathalignVariation
More file actions
Latest commit
executable file
·33 lines (29 loc) · 772 Bytes
/
Copy pathalignVariation
File metadata and controls
executable file
·33 lines (29 loc) · 772 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env ruby
require'optimist'
require'bio'
ARGV.push("--help")ifARGV.empty?
opts=Optimist::optionsdo
bannerFile.basename($0)
opt:input,"input file",:required=>true,:type=>:string
opt:threshold,"variation fraction threshold",:default=>0.2
end
seqs=[]
Bio::FlatFile.new(Bio::FastaFormat,File.new(opts.input)).eachdo |seq|
seqs.push(seq.seq)
end
printf("Position\tVariation\n")
diffs=[0]*seqs.first.length
0.upto(diffs.length - 1)do |i|
bases=[]
seqs.eachdo |seq|
bases.push(seq[i])
end
counts={}
bases.uniq.eachdo |b|
counts[b]=bases.count(b)
end
variation=(1000*(seqs.length-counts.values.max)/seqs.length)/1000.0
ifvariation > opts.threshold
printf("%3d\t%0.3f\n",i+1,variation)
end
end