ms-core 0.0.13 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.13
1
+ 0.0.14
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 13
9
- version: 0.0.13
8
+ - 14
9
+ version: 0.0.14
10
10
  platform: ruby
11
11
  authors:
12
12
  - John T. Prince
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-28 00:00:00 -07:00
18
+ date: 2011-03-09 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -118,9 +118,6 @@ files:
118
118
  - lib/ms/data/transposed.rb
119
119
  - lib/ms/fasta.rb
120
120
  - lib/ms/format/format_error.rb
121
- - lib/ms/id/peptide.rb
122
- - lib/ms/id/protein.rb
123
- - lib/ms/id/search.rb
124
121
  - lib/ms/mass.rb
125
122
  - lib/ms/mass/aa.rb
126
123
  - lib/ms/spectrum.rb
@@ -146,7 +143,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
146
143
  requirements:
147
144
  - - ">="
148
145
  - !ruby/object:Gem::Version
149
- hash: -1109965199117656197
146
+ hash: 1895205922860773162
150
147
  segments:
151
148
  - 0
152
149
  version: "0"
data/lib/ms/id/peptide.rb DELETED
@@ -1,76 +0,0 @@
1
-
2
- module Ms ; end
3
- module Ms::Id ; end
4
-
5
- # A 'sequence' is a notation of a peptide that includes the leading and
6
- # trailing amino acid after cleavage (e.g., K.PEPTIDER.E or -.STARTK.L )
7
- # and may contain post-translational modification information.
8
- #
9
- # 'aaseq' is the amino acid sequence of just the peptide with no leading or
10
- # trailing notation (e.g., PEPTIDER or LAKKLY)
11
- module Ms::Id::Peptide
12
- Nonstandard_AA_re = /[^A-Z\.\-]/
13
-
14
- class << self
15
-
16
- def sequence_to_aaseq(sequence)
17
- after_removed = remove_non_amino_acids(sequence)
18
- pieces = after_removed.split('.')
19
- case pieces.size
20
- when 3
21
- pieces[1]
22
- when 2
23
- if pieces[0].size > 1 ## N termini
24
- pieces[0]
25
- else ## C termini
26
- pieces[1]
27
- end
28
- when 1 ## this must be a parse error!
29
- pieces[0] ## which is the peptide itself
30
- else
31
- abort "bad peptide sequence: #{sequence.inspect}"
32
- end
33
- end
34
-
35
- # removes non standard amino acids specified by Nonstandard_AA_re
36
- def remove_non_amino_acids(sequence)
37
- sequence.gsub(Nonstandard_AA_re, '')
38
- end
39
-
40
- # remove non amino acids and split the sequence
41
- def prepare_sequence(sequence)
42
- nv = remove_non_amino_acids(sequence)
43
- split_sequence(nv)
44
- end
45
-
46
- # Returns prev, peptide, next from sequence. Parse errors return
47
- # nil,nil,nil
48
- # R.PEPTIDE.A # -> R, PEPTIDE, A
49
- # R.PEPTIDE.- # -> R, PEPTIDE, -
50
- # PEPTIDE.A # -> -, PEPTIDE, A
51
- # A.PEPTIDE # -> A, PEPTIDE, -
52
- # PEPTIDE # -> nil,nil,nil
53
- def split_sequence(sequence)
54
- peptide_prev_aa = ""; peptide = ""; peptide_next_aa = ""
55
- pieces = sequence.split('.')
56
- case pieces.size
57
- when 3
58
- peptide_prev_aa, peptide, peptide_next_aa = *pieces
59
- when 2
60
- if pieces[0].size > 1 ## N termini
61
- peptide_prev_aa, peptide, peptide_next_aa = '-', pieces[0], pieces[1]
62
- else ## C termini
63
- peptide_prev_aa, peptide, peptide_next_aa = pieces[0], pieces[1], '-'
64
- end
65
- when 1 ## this must be a parse error!
66
- peptide_prev_aa, peptide, peptide_next_aa = nil,nil,nil
67
- when 0
68
- peptide_prev_aa, peptide, peptide_next_aa = nil,nil,nil
69
- end
70
- return peptide_prev_aa, peptide, peptide_next_aa
71
- end
72
-
73
- end
74
-
75
-
76
- end
data/lib/ms/id/protein.rb DELETED
@@ -1,17 +0,0 @@
1
-
2
- module Ms ; end
3
- module Ms::Id ; end
4
-
5
- module Ms::Id::Protein
6
-
7
- class << self
8
- end
9
-
10
- # gives the information up until the first space or carriage return.
11
- # Assumes the protein can respond_to? :reference
12
- def first_entry
13
- reference.split(/[\s\r]/)[0]
14
- end
15
-
16
- end
17
-
data/lib/ms/id/search.rb DELETED
@@ -1,110 +0,0 @@
1
-
2
- module Ms
3
- module Id
4
-
5
- module Search
6
- attr_accessor :prots
7
- attr_accessor :peps
8
-
9
- def protein_class
10
- self.const_get("Prot")
11
- end
12
-
13
-
14
- # returns an array of peptide_hits and protein_hits that are linked to
15
- # one another. NOTE: this will update peptide and protein
16
- # hits :prots and :peps attributes respectively). Assumes that each search
17
- # responds to :peps, each peptide responds to :prots and each protein to
18
- # :peps. Can be done on a single file to restore protein/peptide
19
- # linkages to their original single-file state.
20
- # Assumes the protein is initialized with (reference, peptide_ar)
21
- #
22
- # yields the protein that will become the template for a new protein
23
- # and expects a new protein hit
24
- def merge!(ar_of_peptide_hit_arrays)
25
- all_peptide_hits = []
26
- reference_hash = {}
27
- ar_of_peptide_hit_arrays.each do |peptide_hits|
28
- all_peptide_hits.push(*peptide_hits)
29
- peptide_hits.each do |pep|
30
- pep.prots.each do |prot|
31
- ref = prot.reference
32
- if reference_hash.key? ref
33
- reference_hash[ref].peps << pep
34
- reference_hash[ref]
35
- else
36
- reference_hash[ref] = yield(prot, [pep])
37
- end
38
- end
39
- end
40
- end
41
- [all_peptide_hits, reference_hash.values]
42
- end
43
-
44
- end
45
-
46
-
47
- module SearchGroup
48
- include Search
49
-
50
- # an array of search objects
51
- attr_accessor :searches
52
-
53
- # the group's file extension (with no leading period)
54
- def extension
55
- 'grp'
56
- end
57
-
58
- def search_class
59
- Search
60
- end
61
-
62
- # a simple formatted file with paths to the search files
63
- def to_paths(file)
64
- IO.readlines(file).grep(/\w/).reject {|v| v =~ /^#/}.map {|v| v.chomp }
65
- end
66
-
67
- def from_file(file)
68
- from_filenames(to_paths(file))
69
- end
70
-
71
-
72
- def from_filenames(filenames)
73
- filenames.each do |file|
74
- if !File.exist? file
75
- message = "File: #{file} does not exist!\n"
76
- message << "perhaps you need to modify the file with file paths"
77
- abort message
78
- end
79
- @searches << search_class.new(file)
80
- end
81
- end
82
-
83
-
84
- # takes an array of filenames or a single search filename (with
85
- # extension defined by 'extendsion') or an array of objects passes any
86
- # arguments to the initializer for each search
87
- # the optional block yields the object for further processing
88
- def initialize(arg=nil, opts={})
89
- @peps = []
90
- @reference_hash = {}
91
- @searches = []
92
-
93
- if arg
94
- if arg.is_a?(String) && arg =~ /\.#{Regexp.escap(extension)}$/
95
- from_file(arg)
96
- elsif arg.is_a?(Array) && arg.first.is_a?(String)
97
- from_filenames(arg)
98
- elsif arg.is_a?(Array)
99
- @searches = array
100
- else
101
- raise ArgumentError, "must be file, array of filenames, or array of objs"
102
- end
103
- @searches << search_class.new(file, opts)
104
- end
105
- yield(self) if block_given?
106
- end
107
-
108
- end
109
- end
110
- end