|
Parallel Visions: City of Angels City of Demons ebook and trade paperback available on Amazon (or here). |
![]() |
|||
Sandbox ruby
From FritzWiki
wget -O target.zip from_link file_name = gzip -list target.zip gzip -d target.zip mv file_name new_file_name
@error_links = []
@errors = []
def get_and_rename_file( link:, new_file_name: )
`wget -O target.zip #{link}`
file_name = `gzip -list target.zip`
file_name.chomp!
`gzip -d target.zip`
`mv #{file_name} #{new_file_name}`
rescue Exception => e
@error_links << link
# @errors << "#{e.class} #{e.message} at #{e.backtrace[0..5].join("\n")}"
@errors << "#{e.class} #{e.message} at #{e.backtrace[0]}"
end
def report_errors
puts
puts "Errors"
@errors.each_with_index |error,index|
puts "==================================="
puts "Error link: #{@error_links[index]}"
puts error
puts
end
end
# format for input file:
#sample_file_name<tab>link
def load_link_file
list_of_arrs = []
# loop over lines of file
# open file
# loop over lines
if line =~ /^(.+)\t(.+)$/
new_file_name = Regexp.last_match( 1 ).strip
link = Regexp.last_match( 2 ).strip
arr = [ link, "#{new_file_name}.fastq" ]
list_of_arrs << arr
end
end
list_of_arrs
end
@list_of_links = load_link_file # format [ [ "link1", "sample1" ], [ "link2", "sample2" ] ]
@list_of_links.each do |arr|
get_and_rename_file( link: arr[0], sample_number: arr[1] )
end
report_errors
