bettersam 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/bettersam.rb +22 -8
  3. data/test/test_test.rb +10 -2
  4. metadata +42 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a61794c089e1bbc0b2c7b5aebdf080cb0018a508
4
- data.tar.gz: bf147789ee59d30182c24d6535618b919a8d3938
3
+ metadata.gz: b784a8ef5c7c567134964e9d028157ae3ef14579
4
+ data.tar.gz: 7ac15b849c7402b8dcd3de17ef9a5d2c52cfabda
5
5
  SHA512:
6
- metadata.gz: f6308aefe4a2681466d5fda521eaa167ecb2dea4dcefb9d7bf761f5c80b5ea771f01d0d65cc1a69922c063f01710e85f0c1cf2f9d7e2ed099b3367147f12f044
7
- data.tar.gz: 9938db788b714bea439ef342695676fcf90c2febcae8284e8dc3a4adf04979179d1904e331ce481aa428ba54cca083d8024535e8de07c6bf8cb57c40a7baa87d
6
+ metadata.gz: 8d492bc114f9a8a195eb47a34302539e26494d809bd4a01e2710358bd75e53ed8688dd58b7514cfb4f4c77835c213534bebf7a125a2084be2db5cd097f12a5c2
7
+ data.tar.gz: 66eed73b517ad1b0710e7f81664136476801753c1fda5e0e50f123f80ced5a35f6805a5998d0291c53ced983dd610c9b00881ef4261da55a32fc69cebb9b993b
data/lib/bettersam.rb CHANGED
@@ -18,8 +18,9 @@ class BetterSam
18
18
  0x400] # 11. read is PCR or optical duplicate
19
19
 
20
20
  public
21
- attr_accessor :name, :flag, :chrom, :pos, :mapq, :cigar, :mchrom, :mpos, :insert, :seq, :qual, :tags
22
- attr_accessor :snp
21
+ attr_accessor :name, :flag, :chrom, :pos, :mapq, :cigar, :mchrom, :mpos
22
+ attr_accessor :insert, :seq, :qual, :tags
23
+ attr_accessor :snp, :length
23
24
  attr_reader :cigar_list
24
25
 
25
26
  def initialize(line=nil)
@@ -52,11 +53,15 @@ public
52
53
  while i < f.size
53
54
  tag = f[i]
54
55
  i += 1
55
- colon_index = tag.rindex(':')
56
- raise line if f.rindex == nil
57
- key = tag[0, colon_index]
58
- value = int_or_raw(tag[colon_index + 1, tag.size - colon_index] || "")
59
- @tags[key] = value
56
+ a = tag.split(":")
57
+ raise line if a.length != 3
58
+ if a[1]=="i"
59
+ @tags[a[0].to_sym] = a[2].to_i
60
+ elsif a[1]=="Z"
61
+ @tags[a[0].to_sym] = a[2]
62
+ else
63
+ @tags[a[0].to_sym] = a[2]
64
+ end
60
65
  end
61
66
 
62
67
  return true;
@@ -123,10 +128,19 @@ public
123
128
  !self.pair_opposite_strands?
124
129
  end
125
130
 
131
+ def edit_distance
132
+ @tags[:NM]
133
+ end
134
+
135
+ def length
136
+ @length = @seq.length if !@length
137
+ return @length
138
+ end
139
+
126
140
  # cigar parsing methods
127
141
 
128
142
  def exact_match?
129
- @cigar=="100M"
143
+ @tags[:NM]==0
130
144
  end
131
145
 
132
146
  def endpos
data/test/test_test.rb CHANGED
@@ -8,12 +8,12 @@ class TestBetterSam < Test::Unit::TestCase
8
8
 
9
9
  setup do
10
10
  # this is run before each test
11
- @l1 = BetterSam.new("FCC00CKABXX:2:1101:10117:6470#CAGATCAT 81 nivara_3s 1572276 40 100M = 1571527 -849 AGGATCGGGCCTCGTGAGCCGACGGTGAGCGAGTTGTTGTTGTTCCATACGGGGGCGCCGGAGTTGGTGCTCCACAGCGGGCCGTTGAACGAGCTCGACG ZbaX^_baX\_S]_ZdYccYebeffddZdbebdadc[bdVeeeceeeddggggggggggggggggegeggdffbfefegggggggggggggggggggggg AS:i:-24 XN:i:0 XM:i:4 XO:i:0 XG:i:0 NM:i:4 MD:Z:1T1G3T0A91 YS:i:-5 YT:Z:DP")
11
+ @l1 = BetterSam.new("FCC00CKABXX:2:1101:10117:6470#CAGATCAT 81 nivara_3s 1572276 40 100M = 1571527 -849 AGGATCGGGCCTCGTGAGCCGACGGTGAGCGAGTTGTTGTTGTTCCATACGGGGGCGCCGGAGTTGGTGCTCCACAGCGGGCCGTTGAACGAGCTCGACG ZbaX^_baX\_S]_ZdYccYebeffddZdbebdadc[bdVeeeceeeddggggggggggggggggegeggdffbfefegggggggggggggggggggggg AS:i:-24 XN:i:0 XM:i:4 XO:i:0 XG:i:0 NM:i:0 MD:Z:1T1G3T0A91 YS:i:-5 YT:Z:DP")
12
12
  @l2 = BetterSam.new("FCC00CKABXX:2:1101:10117:6470#CAGATCAT 81 chromosome03 1789384 24 4M5I91M = 1788782 -697 AGGATCGGGCCTCGTGAGCCGACGGTGAGCGAGTTGTTGTTGTTCCATACGGGGGCGCCGGAGTTGGTGCTCCACAGCGGGCCGTTGAACGAGCTCGACG ZbaX^_baX\_S]_ZdYccYebeffddZdbebdadc[bdVeeeceeeddggggggggggggggggegeggdffbfefegggggggggggggggggggggg AS:i:-38 XN:i:0 XM:i:3 XO:i:1 XG:i:5 NM:i:8 MD:Z:0C1T6G85 YS:i:-5 YT:Z:DP")
13
13
  @l3 = BetterSam.new("FCC00CKABXX:2:1101:19524:66398#CAGATCAT 145 chromosome03 1789377 23 4M1I2M1D93M = 1788766 -711 GGAGGATCGGGCCTCGTGGGCCGACGGTGAGCGAGTTGTTGTTGTTCCATACGGGGGCGCCGGAGTTGGTGCTCCACAGCGGGCCGTTGAACGAGCTCGA Bc`aaT\Y_]RLMKKMHEMV_T[Y[deaeeeaadbaaa\_feecedddddadfcegdcXdggcggggggggg`gfbecbcggggggggeggggggggggg AS:i:-51 XN:i:0 XM:i:6 XO:i:2 XG:i:2 NM:i:8 MD:Z:2T0C2^A2T0A5G1A81 YS:i:0 YT:Z:DP")
14
14
  @l4l = BetterSam.new("FCC00CKABXX:2:1101:16909:83925#CAGATCAT 145 nivara_3s 1572267 23 5M2D3M2I3M1I86M = 1571498 -868 GTCCTCCAGGAGGATCGGGCCTCGTGAGCCGACGGTGAGCGAGTTGTTGTTGTTCCATACGGGGGCGCCGGAGTTGGTGCTCCACAGCGGGCCGTTGAAC BBBBBB_Z`cU]^SZS][]USKV[L`ac`dedeageeefagegagffdd`egedgggedgggggggdggggggggefeeeQgeagggggggggggggggg AS:i:-53 XN:i:0 XM:i:4 XO:i:3 XG:i:5 NM:i:9 MD:Z:2G2^TG3T5T0A81 YS:i:0 YT:Z:DP")
15
15
  @l4r = BetterSam.new("FCC00CKABXX:2:1101:16909:83925#CAGATCAT 145 chromosome03 1789378 23 7M4I3M5I81M = 1788753 -716 GTCCTCCAGGAGGATCGGGCCTCGTGAGCCGACGGTGAGCGAGTTGTTGTTGTTCCATACGGGGGCGCCGGAGTTGGTGCTCCACAGCGGGCCGTTGAAC BBBBBB_Z`cU]^SZS][]USKV[L`ac`dedeageeefagegagffdd`egedgggedgggggggdggggggggefeeeQgeagggggggggggggggg AS:i:-59 XN:i:0 XM:i:4 XO:i:2 XG:i:9 NM:i:13 MD:Z:3A1A2T6G75 YS:i:0 YT:Z:DP")
16
- @l5l = BetterSam.new("FCC2HFRACXX:7:2314:9299:67450#TGACCAAT 355 Sb02g000720.1 1186 18 71M = 1238 -150 CGTCATCTTCTCTCATATATTTGTATCACCCATCCATCCATCTGCCTTCGATATGCATCTCCACTCCGCCG __^cc]^\`eegea`ffdfghhfd]eghhfffef``degfhf_^gdfhfg_fghhhfdhffdfhffbeWcW AS:i:142 XN:i:0 XM:i:0 XO:i:0 XG:i:0 NM:i:0 MD:Z:71 YS:i:44 YT:Z:CP")
16
+ @l5l = BetterSam.new("FCC2HFRACXX:7:2314:9299:67450#TGACCAAT 355 Sb02g000720.1 1186 18 71M = 1238 -150 CGTCATCTTCTCTCATATATTTGTATCACCCATCCATCCATCTGCCTTCGATATGCATCTCCACTCCGCCG __^cc]^\`eegea`ffdfghhfd]eghhfffef``degfhf_^gdfhfg_fghhhfdhffdfhffbeWcW AS:i:142 XN:i:0 XM:i:0 XO:i:0 XG:i:0 MD:Z:71 YS:i:44 YT:Z:CP") # NM:i:0
17
17
  end
18
18
 
19
19
  should "be a paired read" do
@@ -94,5 +94,13 @@ class TestBetterSam < Test::Unit::TestCase
94
94
  assert !@l5l.primary_aln?
95
95
  end
96
96
 
97
+ should "get the edit distance" do
98
+ assert_equal 8, @l2.tags[:NM]
99
+ end
100
+
101
+ should "fail to get the edit distance" do
102
+ assert_equal nil, @l5l.tags[:NM]
103
+ end
104
+
97
105
  end
98
106
  end
metadata CHANGED
@@ -1,86 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bettersam
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
- - Richard Smith
7
+ - Richard Smith-Unna
8
8
  - Chris Boursnell
9
+ - Jesse Rodriguez
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2014-06-30 00:00:00.000000000 Z
13
+ date: 2014-08-05 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: simplecov
16
17
  requirement: !ruby/object:Gem::Requirement
17
18
  requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '0.8'
18
22
  - - '>='
19
23
  - !ruby/object:Gem::Version
20
- version: '0'
24
+ version: 0.8.2
21
25
  type: :development
22
26
  prerelease: false
23
27
  version_requirements: !ruby/object:Gem::Requirement
24
28
  requirements:
29
+ - - ~>
30
+ - !ruby/object:Gem::Version
31
+ version: '0.8'
25
32
  - - '>='
26
33
  - !ruby/object:Gem::Version
27
- version: '0'
34
+ version: 0.8.2
28
35
  - !ruby/object:Gem::Dependency
29
36
  name: rake
30
37
  requirement: !ruby/object:Gem::Requirement
31
38
  requirements:
39
+ - - ~>
40
+ - !ruby/object:Gem::Version
41
+ version: '10.3'
32
42
  - - '>='
33
43
  - !ruby/object:Gem::Version
34
- version: '0'
44
+ version: 10.3.2
35
45
  type: :development
36
46
  prerelease: false
37
47
  version_requirements: !ruby/object:Gem::Requirement
38
48
  requirements:
49
+ - - ~>
50
+ - !ruby/object:Gem::Version
51
+ version: '10.3'
39
52
  - - '>='
40
53
  - !ruby/object:Gem::Version
41
- version: '0'
54
+ version: 10.3.2
42
55
  - !ruby/object:Gem::Dependency
43
56
  name: turn
44
57
  requirement: !ruby/object:Gem::Requirement
45
58
  requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '0.9'
46
62
  - - '>='
47
63
  - !ruby/object:Gem::Version
48
- version: '0'
64
+ version: 0.9.7
49
65
  type: :development
50
66
  prerelease: false
51
67
  version_requirements: !ruby/object:Gem::Requirement
52
68
  requirements:
69
+ - - ~>
70
+ - !ruby/object:Gem::Version
71
+ version: '0.9'
53
72
  - - '>='
54
73
  - !ruby/object:Gem::Version
55
- version: '0'
74
+ version: 0.9.7
56
75
  - !ruby/object:Gem::Dependency
57
76
  name: shoulda-context
58
77
  requirement: !ruby/object:Gem::Requirement
59
78
  requirements:
79
+ - - ~>
80
+ - !ruby/object:Gem::Version
81
+ version: '1.2'
60
82
  - - '>='
61
83
  - !ruby/object:Gem::Version
62
- version: '0'
84
+ version: 1.2.1
63
85
  type: :development
64
86
  prerelease: false
65
87
  version_requirements: !ruby/object:Gem::Requirement
66
88
  requirements:
89
+ - - ~>
90
+ - !ruby/object:Gem::Version
91
+ version: '1.2'
67
92
  - - '>='
68
93
  - !ruby/object:Gem::Version
69
- version: '0'
94
+ version: 1.2.1
70
95
  - !ruby/object:Gem::Dependency
71
96
  name: coveralls
72
97
  requirement: !ruby/object:Gem::Requirement
73
98
  requirements:
74
- - - '>='
99
+ - - ~>
75
100
  - !ruby/object:Gem::Version
76
- version: '0'
101
+ version: '0.7'
77
102
  type: :development
78
103
  prerelease: false
79
104
  version_requirements: !ruby/object:Gem::Requirement
80
105
  requirements:
81
- - - '>='
106
+ - - ~>
82
107
  - !ruby/object:Gem::Version
83
- version: '0'
108
+ version: '0.7'
84
109
  description: Extended SAM (Sequence Alignment/Map) file parsing
85
110
  email: rds45@cam.ac.uk
86
111
  executables: []
@@ -89,8 +114,8 @@ extra_rdoc_files: []
89
114
  files:
90
115
  - Rakefile
91
116
  - lib/bettersam.rb
92
- - test/helper.rb
93
117
  - test/test_test.rb
118
+ - test/helper.rb
94
119
  - README.md
95
120
  - LICENSE
96
121
  homepage: https://github.com/blahah/bettersam
@@ -113,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
138
  version: '0'
114
139
  requirements: []
115
140
  rubyforge_project:
116
- rubygems_version: 2.0.6
141
+ rubygems_version: 2.1.4
117
142
  signing_key:
118
143
  specification_version: 4
119
144
  summary: Extended SAM file parsing