Class: Unipept::Commands::Peptfilter

Inherits:
Object
  • Object
show all
Defined in:
lib/commands/peptfilter.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#root_commandObject (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

Parameters:

  • peptide (String)

    The peptide to check

  • min (Integer)

    The minimal length requirement

  • max (Integer)

    The maximal length requirement

  • lacks (Array<String>)

    The forbidden amino acids

  • contains (Array<String>)

    The required amino acids

Returns:

  • (Boolean)

    true if the peptide satisfies all requirements



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

Parameters:

  • peptide (String)

    The peptide to check

  • contains (Array<String>)

    The required amino acids

Returns:

  • (Boolean)

    true if the peptide satisfies all requirements



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

Parameters:

  • peptide (String)

    The peptide to check

  • lacks (Array<String>)

    The forbidden amino acids

Returns:

  • (Boolean)

    true if the peptide satisfies all requirements



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

Parameters:

  • peptide (String)

    The peptide to check

  • min (Integer)

    The minimal length requirement

  • max (Integer)

    The maximal length requirement

Returns:

  • (Boolean)

    true if the peptide satisfies all requirements



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.

Parameters:

  • args (Array<String>)

    An array of command-line arguments



47
48
49
# File 'lib/commands/peptfilter.rb', line 47

def self.run(args)
  @root_command.run(args)
end