Class: Bio::Spoctopus::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/bio/appl/octopus.rb

Class Method Summary collapse

Class Method Details

.create_from_output(spoctopus_output) ⇒ Object

Given the fasta-ish file output from spoctopus, parse it into a SignalPeptideTransmembraneDomainProtein.

Example without TMD: >wrapperSeq gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg ggggggggggggggggggggggggggggggggggggg

Example with 2 TMD >wrapperSeq iiiiiiiiiiMMMMMMMMMMMMMMMMMMMMMooooooooooooooooooooooooooooo ooooMMMMMMMMMMMMMMMMMMMMMiiiiiMMMMMMMMMMMMMMMMMMMMMo

Example with SP and TMD >wrapperSeq nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnSSSSSSSSSSSSSSSooooooooooooooo ooooooooooooooooooooooooooooooooooooo



114
115
116
117
118
119
120
121
122
123
124
125
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
# File 'lib/bio/appl/octopus.rb', line 114

def self.create_from_output(spoctopus_output)
  #        puts spoctopus_output
  # split the fasta into the real parts
  lines = spoctopus_output.split("\n")
  
  # Error checking
  unless lines[0].match(/^\>/) and lines.length > 1
    raise Exception, "Unexpected OCTOPUS output file: #{spoctopus_output.inspect}. STDERR: #{File.open(err.path).read}"
  end

  seq = lines[1..(lines.length-1)].join('')

  # Taken from http://octopus.cbr.su.se/OCTOPUS_DATA/readme
  # and supplemented by experiment, as there doesn't seem to be one available for
  # SPOCTOPUS, only OCTOPUS.
  #
  # Currently dips, hairpins, unannotated and reentrants are ignored.
  unless seq.match(/^[ioMgnSHRrDd\.T]+$/)
    raise Exception, "Unexpected characters in SPOCTOPUS output sequence: #{seq}"
  end

  tmd = Bio::Transmembrane::SignalPeptideTransmembraneDomainProtein.new

  # deal with nothing proteins
  return tmd if seq.match(/^g*$/)

  seq.scan(/S+/) do
    if tmd.signal?
      raise Exception, "Only 1 Signal Peptide is expected!. SPOCTOPUS output was #{seq}"
    end

    s = Bio::Transmembrane::SignalPeptide.new
    s.start = $~.offset(0)[0]+1
    s.stop = $~.offset(0)[1]
    tmd.signal_peptide = s
  end

  seq.scan(/M+/) do # for each transmembrane domain
    t = Bio::Transmembrane::OrientedTransmembraneDomain.new
    t.start = $~.offset(0)[0]+1
    t.stop = $~.offset(0)[1]

    # set orientation
    # if at the start of the protein it is harder
    if t.start == 1
      if t.stop == seq.length #all TMD, so we don't know
        t.orientation = Bio::Transmembrane::OrientedTransmembraneDomain::UNKNOWN
      else
        char = seq[t.stop-2..t.stop-2]
        if char == 'o'
          t.orientation = Bio::Transmembrane::OrientedTransmembraneDomain::INSIDE_OUT
        else
          t.orientation = Bio::Transmembrane::OrientedTransmembraneDomain::OUTSIDE_IN
        end
      end

    else # usual - TMD does not start at exactly the beginning
      char = seq[t.start-2..t.start-2]
      if char == 'i'
        t.orientation = Bio::Transmembrane::OrientedTransmembraneDomain::INSIDE_OUT
      else
        t.orientation = Bio::Transmembrane::OrientedTransmembraneDomain::OUTSIDE_IN
      end
    end

    tmd.transmembrane_domains.push t
  end

  return tmd
end