Class: Bioroebe::HelixWheel

Inherits:
CommandlineApplication show all
Defined in:
lib/bioroebe/pdb_and_protein_structure/helical_wheel.rb

Overview

Bioroebe::HelixWheel

Constant Summary collapse

GS_HEADER_START =
#

GS_HEADER_START

#
<<EOF;
%!PS-Adobe-
%%BoundingBox: (atend)
%1 0 0 setrgbcolor
%newpath
%37.5 161 moveto 557.5 161 lineto 557.5 681 lineto 37.5 681 lineto
%closepath stroke
297.5 421. translate 2 setlinewidth 1 setlinecap
/Helvetica findfont 20 scalefont setfont 0 0 moveto
EO
HELVETICA_FONT =
'Helvetica'
HELVETICA_FONT_BOLD =
'Helvetica-Bold'
FONT =
#

FONT

Define fonts to associate with each amino acid

#
{}

Constants inherited from CommandlineApplication

CommandlineApplication::OLD_VERBOSE_VALUE

Constants included from ColoursForBase

ColoursForBase::ARRAY_HTML_COLOURS_IN_USE

Constants inherited from Base

Base::NAMESPACE

Instance Method Summary collapse

Methods inherited from CommandlineApplication

#all_aminoacids?, #append_what_into, #at_home?, #be_silent, #be_verbose?, #cat, #ccliner, #change_directory, #cliner, #codon_table_dataset?, #codon_to_aminoacid, #codons_for?, #colourize_this_dna_sequence, #complement, #cp, #disable_warnings, #download_dir?, #editor?, #enable_warnings, #ensure_that_the_base_directories_exist, #esystem, #extract, #is_this_a_start_codon?, #is_this_a_stop_codon?, #leading_five_prime, #load_bioroebe_yaml_file, #log_directory?, #one_letter_to_long_name, #one_to_three, #only_numbers?, #open_in_browser, #opnerev, #opnn, #pad_with_double_quotes, #pad_with_single_quotes, #partner_nucleotide, #remove_numbers, #remove_trailing_ansii_escape_code, #return_all_possible_start_codons, #return_array_of_one_letter_aminoacids, #return_cheerful_person, #return_chunked_display, #return_ubiquitin_sequence, #runmode?, #set_be_verbose, #set_runmode, #start_codon?, #stop_codons?, #strict_filter_away_invalid_aminoacids, #taxonomy_download_directory?, #three_to_one, #to_rna, #trailing_three_prime, #use_opn?, #verbose_truth, #was_or_were, #without_extname, #write_what_into

Methods included from BaseModule

#absolute_path, #default_file_read, #file_readlines

Methods included from CommandlineArguments

#commandline_arguments?, #commandline_arguments_that_are_files?, #e, #first?, #first_non_hyphen_argument?, #remove_hyphens_from_the_commandline_arguments, #return_commandline_arguments_as_string, #return_commandline_arguments_that_are_not_files, #return_entries_without_two_leading_hyphens, #select_commandline_arguments, #select_entries_starting_with_two_hyphens, #set_commandline_arguments

Methods included from ColoursForBase

#colourize_this_aminoacid_sequence_for_the_commandline, #colourize_this_nucleotide_sequence, #disable_colours, #ecomment, #efancy, #egold, #enable_colours, #eorange, #eparse, #erev, #red, #remove_trailing_escape_part, #return_colour_for_nucleotides, #rev, #sdir, #set_will_we_use_colours, #sfancy, #sfile, #simp, #swarn, #use_colours?, #use_colours_within_the_bioroebe_namespace?

Methods inherited from Base

#append_what_into, #can_base_pair?, #convert_global_env, #delete_file, #directory_to_the_codon_tables?, #is_on_roebe?, #is_palindrome?, #main_encoding?, #mkdir, #move_file, #mv, #no_file_exists_at, #no_newlines, #project_yaml_directory?, #rds, #register_sigint, #return_pwd, #return_the_first_line_of_this_file, #word_wrap, #write_what_into

Methods included from InternalHashModule

#internal_hash?, #reset_the_internal_hash

Methods included from InferTheNamespaceModule

#infer_the_namespace, #namespace?

Constructor Details

#initialize(run_already = true) ⇒ HelixWheel

#

initialize

#


76
77
78
79
80
81
# File 'lib/bioroebe/pdb_and_protein_structure/helical_wheel.rb', line 76

def initialize(
    run_already = true
  )
  reset
  run if run_already
end

Instance Method Details

#_(i) ⇒ Object

#

_

#


97
98
99
# File 'lib/bioroebe/pdb_and_protein_structure/helical_wheel.rb', line 97

def _(i)
  @_ << i
end

#build_stringObject

#

build_string

#


104
105
106
107
# File 'lib/bioroebe/pdb_and_protein_structure/helical_wheel.rb', line 104

def build_string
  _ GS_HEADER_START
  fetch_input
end

#cos(i) ⇒ Object

#

cos

#


112
113
114
# File 'lib/bioroebe/pdb_and_protein_structure/helical_wheel.rb', line 112

def cos(i)
  Math.cos(i)
end

#fetch_inputObject

#

fetch_input

#


126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/bioroebe/pdb_and_protein_structure/helical_wheel.rb', line 126

def fetch_input
  @input = $stdin.gets.chomp.strip # Read line of input
  # @input =~ s/\s//g # remove terminal carriage return and blanks
  use_this_regex = /^(\d+)/
  if ( @input =~ use_this_regex ) # if input begins with integer
    resno = $1 # extract it as initial residue number
  else
    resno = 1  # if not, set initial residue number = 1
  end
  radius =  50 # initialize values for radius,
  x      =   0
  y      = -50
  theta  = -90 # x, y and angle theta
  # print light gray spiral arc as succession of
  # line segments, 10 per residue
  npoints = 10 * (@input.size - 1)
  _ '0.8 0.8 0.8 setrgbcolor'+N # set colour to light gray
  _ 'newpath'+N                 # draw spiral arc
  _ sprintf('%8.3f %8.3f moveto'+N,x,y)
  (1 .. npoints).each {|d|             # 10 points per residue
    theta  += 10
    radius += 0.6          # increase radius and theta
    x = radius * cos(theta * 0.01747737)   # calculate new value of x
    y = radius * sin(theta * 0.01747737)   # and y
    printf("%8.3f %8.3f lineto"+N,x,y)
  }
  _ 'stroke'+N
  # ======================================================================= #
  # print residues and residue numbers
  # ======================================================================= #
  radius =  50 # reinitialize values for radius,
  x      =   0
  y      = -50
  theta  = -90 # x, y and angle theta
  _ '0 setgray'+N  # set colour to black
  @input.split('').each {|line|       # loop over characters from input line
    _ "/FONT{@input} findfont"        # set font appropriate
    _ ' 20 scalefont setfont'+N       # for this amino acid
    _ sprintf('%8.3f %8.3f moveto'+N,x,y)  # move to current point
    _ " (resno@input) stringwidth"    # adjust position to center residue
    _ ' pop -0.5 mul -7 rmoveto'+N    #    identification on point on spiral
    _ " (resno@input) show"+N         # print residue number and id
    _ "% theta resno@input"+N
    theta += 100
    radius += 6           #  set new values of angle, radius
    x = radius * cos(theta * 0.01747737) #  compute new values of x
    y = radius * sin(theta * 0.01747737) #     and y
    resno += 1                           #  increase residue number
  }
  _ 'showpage'+N             # postscript signals to
  _ "%%BoundingBox:"         # print
  xl = 297.5 - 1.05 * radius #   x
  xr = 297.5 + 1.05 * radius # and
  yb = 421.  - 1.05 * radius #   y
  yt = 421.  + 1.05 * radius # limits
  _ sprintf('%8.3f %8.3f %8.3f %8.3f'+N,xl,xr,yb,yt)
  _ 'showpage'+N
  _ '%%EOF'+N              #  and wind up
end

#resetObject

#

reset (reset tag)

#


86
87
88
89
90
91
92
# File 'lib/bioroebe/pdb_and_protein_structure/helical_wheel.rb', line 86

def reset
  super()
  # ======================================================================= #
  # === @_
  # ======================================================================= #
  @_ = ''.dup
end

#runObject

#

run

#


196
197
198
199
# File 'lib/bioroebe/pdb_and_protein_structure/helical_wheel.rb', line 196

def run
  build_string
  show_result
end

#show_resultObject

#

show_result

#


189
190
191
# File 'lib/bioroebe/pdb_and_protein_structure/helical_wheel.rb', line 189

def show_result
  e @_
end

#sin(i) ⇒ Object

#

sin

#


119
120
121
# File 'lib/bioroebe/pdb_and_protein_structure/helical_wheel.rb', line 119

def sin(i)
  Math.sin(i)
end