Skip to content

Instantly share code, notes, and snippets.

@buchanae
Created April 18, 2013 00:48
Show Gist options
  • Save buchanae/5408984 to your computer and use it in GitHub Desktop.
Save buchanae/5408984 to your computer and use it in GitHub Desktop.
# maps names to OTU numbers
name_to_OTU = {
'name_1': 23,
'RIO12.3_44008': 93,
}
# contrived data to represent what you emailed
# this represents one sample's counts,
# e.g. the "('MID - OLD12.5',..." line
per_sample_counts = Counter({
'name_1': 1,
'RIO12.3_44008': 3,
})
# Print out the counts with updated names
for name, count in per_sample_counts:
print 'OTU({})'.format(name_to_OTU[name]), count
# Or, update the counts without printing
updated = {}
for name, count in per_sample_counts:
x = 'OTU({})'.format(name_to_OUT[name])
updated[x] = count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment