Class: Unipept::Commands::Peptfilter
- Defined in:
- lib/commands/peptfilter.rb
Instance Attribute Summary collapse
-
#root_command ⇒ Object
readonly
Returns the value of attribute root_command.
Class Method Summary collapse
-
.filter(peptide, min, max, lacks, contains) ⇒ Boolean
Checks if a peptide satisfies the min length, max length, lacks and contains requirements.
-
.filter_contains(peptide, contains) ⇒ Boolean
Checks if a peptide satisfies the contains requirement.
-
.filter_lacks(peptide, lacks) ⇒ Boolean
Checks if a peptide satisfies lacks requirement.
-
.filter_length(peptide, min, max) ⇒ Boolean
Checks if a peptide satisfies the min length and max length requirements.
-
.run(args) ⇒ void
Invokes the peptfilter command-line tool with the given arguments.
Instance Attribute Details
#root_command ⇒ Object (readonly)
Returns the value of attribute root_command.
3 4 5 |
# File 'lib/commands/peptfilter.rb', line 3 def root_command @root_command end |
Class Method Details
.filter(peptide, min, max, lacks, contains) ⇒ Boolean
Checks if a peptide satisfies the min length, max length, lacks and contains requirements. Returns true if
-
the peptide length is equal or higher than min
-
the peptide length is equal or lower than max
-
the peptide doesn’t contain any of the amino acids in lacks
-
the peptide contains all of the amino acids in contains
69 70 71 72 73 |
# File 'lib/commands/peptfilter.rb', line 69 def self.filter(peptide, min, max, lacks, contains) filter_length(peptide, min, max) && filter_lacks(peptide, lacks) && filter_contains(peptide, contains) end |
.filter_contains(peptide, contains) ⇒ Boolean
Checks if a peptide satisfies the contains requirement. Returns true if
-
the peptide contains all of the amino acids in contains
113 114 115 |
# File 'lib/commands/peptfilter.rb', line 113 def self.filter_contains(peptide, contains) (peptide.chars.to_a & contains).size == contains.size end |
.filter_lacks(peptide, lacks) ⇒ Boolean
Checks if a peptide satisfies lacks requirement. Returns true if
-
the peptide doesn’t contain any of the amino acids in lacks
100 101 102 |
# File 'lib/commands/peptfilter.rb', line 100 def self.filter_lacks(peptide, lacks) (peptide.chars.to_a & lacks).empty? end |
.filter_length(peptide, min, max) ⇒ Boolean
Checks if a peptide satisfies the min length and max length requirements. Returns true if
-
the peptide length is equal or higher than min
-
the peptide length is equal or lower than max
87 88 89 |
# File 'lib/commands/peptfilter.rb', line 87 def self.filter_length(peptide, min, max) peptide.length >= min && peptide.length <= max end |
.run(args) ⇒ void
This method returns an undefined value.
Invokes the peptfilter command-line tool with the given arguments.
47 48 49 |
# File 'lib/commands/peptfilter.rb', line 47 def self.run(args) @root_command.run(args) end |