Skip to content

Instantly share code, notes, and snippets.

@mauricio
Created December 3, 2013 00:23
Show Gist options
  • Select an option

  • Save mauricio/7761736 to your computer and use it in GitHub Desktop.

Select an option

Save mauricio/7761736 to your computer and use it in GitHub Desktop.
segment = ARGV[0]
taxa = "reference_HAs.fasta"
fasta = "2009pdm_extracts.fasta"
search = IO.read( taxa ).split('>').inject({}) do |accumulator,line|
sorting = line.strip.split("\n")
name = sorting.shift
accumulator[name.split("|")[1]] = 0
accumulator
end
result = IO.read(fasta).split('>').inject([]) do |accumulator,line|
sorting = line.strip.split("\n")
name = sorting.shift
headers = name.split('|')
dna = sorting.join('')
if headers[2] =~ /Segment:#{segment}/ && search[headers[1]]
accumulator << headers[1]
end
accumulator
end
not_found = (search.keys - result)
puts "not found are #{not_found.inspect}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment