Class: BioToolsExcelConverter
- Inherits:
-
Object
- Object
- BioToolsExcelConverter
- Defined in:
- lib/protk/biotools_excel_converter.rb
Class Method Summary collapse
Instance Method Summary collapse
- #get_rows ⇒ Object
-
#initialize(filename) ⇒ BioToolsExcelConverter
constructor
A new instance of BioToolsExcelConverter.
Constructor Details
#initialize(filename) ⇒ BioToolsExcelConverter
Returns a new instance of BioToolsExcelConverter.
7 8 9 |
# File 'lib/protk/biotools_excel_converter.rb', line 7 def initialize(filename) @inputBook = Spreadsheet.open File.new("#{filename}") end |
Class Method Details
.isBiotools(filename) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/protk/biotools_excel_converter.rb', line 11 def self.isBiotools(filename) testBook = Spreadsheet.open File.new("#{filename}") testSheet = testBook.worksheet 0 isbiotools=FALSE testSheet.each do |row| if (row[0].class==String) && row[0].match(/Digest Matches.*?Score:\s(.*)\)/) isbiotools=TRUE end end isbiotools end |
Instance Method Details
#get_rows ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/protk/biotools_excel_converter.rb', line 26 def get_rows sheet=@inputBook.worksheet 0 protein_rows=[] n_rows=sheet.dimensions[1] protein_rows=(0...n_rows).collect do |row_i| new_row=nil row=sheet.row row_i if ( row[0]!=nil) digmatch=row[0].match(/Digest Matches.*?Score:\s(.*)\)/) if ( digmatch!=nil ) new_row=[] text= sheet.row(row_i-1)[0] m=text.match(/\s(\S*)\s*$/) throw "Badly formed protein line in biotools file ... could not parse protein name from #{text}" unless m!=nil new_row[0]=m[1] new_row[1]=digmatch[1] end end new_row end protein_rows.compact! protein_rows.insert(0,["Accession","Ion Scores"]) protein_rows end |