Last active
August 22, 2022 20:11
-
-
Save tomkinsc/49e8519e0ec13bba6ed48ed9fa53cf61 to your computer and use it in GitHub Desktop.
This replaces basecall quality scores with graphical equivalents. Based on pyemojify and fastqe, but self-contained without dependencies external to the standard library.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import re, sys, os | |
from stat import S_ISFIFO | |
import argparse | |
# quick and dirty script to show emoji or bars for samtools mpileup quality scrores | |
# extra verbose so this does not require any external libraries | |
# based on fastqe and emojify: | |
# https://raw.githubusercontent.com/fastqe/fastqe/master/fastqe/fastqe_map.py | |
# https://github.com/lord63/pyemojify | |
seq_emoji_map = { | |
'A': ':apple:', # avocado? differnet colours? | |
'C': ':corn:', | |
'T': ':tomato:', | |
'G': ':grapes:', | |
'N': ':question: ' | |
} | |
all_qualities = r"!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~" | |
#From https://en.wikipedia.org/wiki/FASTQ_format | |
# note order not exact here | |
fastq_emoji_map = { | |
'!': ':no_entry_sign:', | |
'\"': ':x:', | |
'#': ':japanese_goblin:', | |
'$': ':broken_heart:', | |
'%': ':no_good:', | |
'&': ':space_invader:', | |
'\'': ':imp:', | |
'(': ':skull:', | |
')': ':ghost:', | |
#'': ':pouting_cat:', | |
'*': ':see_no_evil:', | |
'+': ':hear_no_evil:', | |
',': ':speak_no_evil:', | |
'/': ':pouting_cat:', | |
'-': ':monkey_face:', | |
'.': ':crying_cat_face:', | |
'0': ':scream_cat:', | |
'1': ':bomb:', | |
'2': ':fire:', | |
'3': ':rage:', | |
'4': ':poop:', | |
'5': ':warning:', | |
'6': ':grinning:', | |
'7': ':sweat_smile:', | |
'8': ':smirk:', | |
'9': ':blush:', | |
':': ':kissing_smiling_eyes:', | |
';': ':kissing:', | |
'<': ':kissing_closed_eyes:', | |
'>': ':kissing_heart:', | |
'@': ':smile:', | |
'=': ':smiley:', | |
'?': ':laughing:', | |
'A': ':yum:', | |
'B': ':relaxed:', | |
'D': ':stuck_out_tongue:', | |
'C': ':stuck_out_tongue_closed_eyes:', | |
'E': ':stuck_out_tongue_winking_eye:', | |
'G': ':grin:', | |
'H': ':smile:', | |
'I': ':sunglasses:', | |
'J': ':heart_eyes:', | |
'F': ':wink:' | |
} | |
# only use 0 to 50 use same emoji | |
# binning - i.e https://www.illumina.com/documents/products/technotes/technote_understanding_quality_scores.pdf | |
fastq_emoji_map_binned= { | |
#N (no call) N (no call) | |
'!': ':no_entry_sign:', | |
'"': ':no_entry_sign:', | |
#2โ9 6 | |
'#': ':skull:', | |
'$': ':skull:', | |
'%': ':skull:', | |
'&': ':skull:', | |
'\'': ':skull:', | |
'(': ':skull:', | |
')': ':skull:', | |
'*': ':skull:', | |
#10โ19 15 | |
'+': ':poop:' , | |
',': ':poop:' , | |
'-': ':poop:' , | |
'.': ':poop:' , | |
'/': ':poop:' , | |
'0': ':poop:' , | |
'1': ':poop:' , | |
'2': ':poop:' , | |
'3': ':poop:' , | |
'4': ':poop:' , | |
#20โ24 22 | |
'5': ':warning:', | |
'6': ':warning:', | |
'7': ':warning:', | |
'8': ':warning:', | |
'9': ':warning:', | |
#25โ29 27 | |
':': ':smile:', | |
';': ':smile:', | |
'<': ':smile:', | |
'=': ':smile:', | |
'>': ':smile:', | |
#30โ34 33 | |
'?': ':laughing:', | |
'@': ':laughing:', | |
'A': ':laughing:', | |
'B': ':laughing:', | |
'C': ':laughing:', | |
#35โ39 37 | |
'D': ':sunglasses:', | |
'E': ':sunglasses:', | |
'F': ':sunglasses:', | |
'G': ':sunglasses:', | |
'H': ':sunglasses:', | |
#โฅ 40 40 | |
'I': ':heart_eyes:', | |
'J': ':heart_eyes:', | |
} | |
# emoji map | |
emoji_table = { | |
':smile:': u'๐', | |
':smiley:': u'๐', | |
':grinning:': u'๐', | |
':blush:': u'๐', | |
':relaxed:': u'โบ๏ธ', | |
':wink:': u'๐', | |
':heart_eyes:': u'๐', | |
':kissing_heart:': u'๐', | |
':kissing_closed_eyes:': u'๐', | |
':kissing:': u'๐', | |
':kissing_smiling_eyes:': u'๐', | |
':stuck_out_tongue_winking_eye:': u'๐', | |
':stuck_out_tongue_closed_eyes:': u'๐', | |
':stuck_out_tongue:': u'๐', | |
':flushed:': u'๐ณ', | |
':grin:': u'๐', | |
':pensive:': u'๐', | |
':relieved:': u'๐', | |
':unamused:': u'๐', | |
':disappointed:': u'๐', | |
':persevere:': u'๐ฃ', | |
':cry:': u'๐ข', | |
':joy:': u'๐', | |
':sob:': u'๐ญ', | |
':sleepy:': u'๐ช', | |
':disappointed_relieved:': u'๐ฅ', | |
':cold_sweat:': u'๐ฐ', | |
':sweat_smile:': u'๐ ', | |
':sweat:': u'๐', | |
':weary:': u'๐ฉ', | |
':tired_face:': u'๐ซ', | |
':fearful:': u'๐จ', | |
':scream:': u'๐ฑ', | |
':angry:': u'๐ ', | |
':rage:': u'๐ก', | |
':triumph:': u'๐ค', | |
':confounded:': u'๐', | |
':laughing:': u'๐', | |
':satisfied:': u'๐', | |
':yum:': u'๐', | |
':mask:': u'๐ท', | |
':sunglasses:': u'๐', | |
':sleeping:': u'๐ด', | |
':dizzy_face:': u'๐ต', | |
':astonished:': u'๐ฒ', | |
':worried:': u'๐', | |
':frowning:': u'๐ฆ', | |
':anguished:': u'๐ง', | |
':smiling_imp:': u'๐', | |
':imp:': u'๐ฟ', | |
':open_mouth:': u'๐ฎ', | |
':grimacing:': u'๐ฌ', | |
':neutral_face:': u'๐', | |
':confused:': u'๐', | |
':hushed:': u'๐ฏ', | |
':no_mouth:': u'๐ถ', | |
':innocent:': u'๐', | |
':smirk:': u'๐', | |
':expressionless:': u'๐', | |
':man_with_gua_pi_mao:': u'๐ฒ', | |
':man_with_turban:': u'๐ณ', | |
':cop:': u'๐ฎ', | |
':construction_worker:': u'๐ท', | |
':guardsman:': u'๐', | |
':baby:': u'๐ถ', | |
':boy:': u'๐ฆ', | |
':girl:': u'๐ง', | |
':man:': u'๐จ', | |
':woman:': u'๐ฉ', | |
':older_man:': u'๐ด', | |
':older_woman:': u'๐ต', | |
':person_with_blond_hair:': u'๐ฑ', | |
':angel:': u'๐ผ', | |
':princess:': u'๐ธ', | |
':smiley_cat:': u'๐บ', | |
':smile_cat:': u'๐ธ', | |
':heart_eyes_cat:': u'๐ป', | |
':kissing_cat:': u'๐ฝ', | |
':smirk_cat:': u'๐ผ', | |
':scream_cat:': u'๐', | |
':crying_cat_face:': u'๐ฟ', | |
':joy_cat:': u'๐น', | |
':pouting_cat:': u'๐พ', | |
':japanese_ogre:': u'๐น', | |
':japanese_goblin:': u'๐บ', | |
':see_no_evil:': u'๐', | |
':hear_no_evil:': u'๐', | |
':speak_no_evil:': u'๐', | |
':skull:': u'๐', | |
':alien:': u'๐ฝ', | |
':hankey:': u'๐ฉ', | |
':poop:': u'๐ฉ', | |
':shit:': u'๐ฉ', | |
':fire:': u'๐ฅ', | |
':sparkles:': u'โจ', | |
':star2:': u'๐', | |
':dizzy:': u'๐ซ', | |
':boom:': u'๐ฅ', | |
':collision:': u'๐ฅ', | |
':anger:': u'๐ข', | |
':sweat_drops:': u'๐ฆ', | |
':droplet:': u'๐ง', | |
':zzz:': u'๐ค', | |
':dash:': u'๐จ', | |
':ear:': u'๐', | |
':eyes:': u'๐', | |
':nose:': u'๐', | |
':tongue:': u'๐ ', | |
':lips:': u'๐', | |
':+1:': u'๐', | |
':thumbsup:': u'๐', | |
':-1:': u'๐', | |
':thumbsdown:': u'๐', | |
':ok_hand:': u'๐', | |
':facepunch:': u'๐', | |
':punch:': u'๐', | |
':fist:': u'โ', | |
':v:': u'โ๏ธ', | |
':wave:': u'๐', | |
':hand:': u'โ', | |
':raised_hand:': u'โ', | |
':open_hands:': u'๐', | |
':point_up_2:': u'๐', | |
':point_down:': u'๐', | |
':point_right:': u'๐', | |
':point_left:': u'๐', | |
':raised_hands:': u'๐', | |
':pray:': u'๐', | |
':point_up:': u'โ๏ธ', | |
':clap:': u'๐', | |
':muscle:': u'๐ช', | |
':walking:': u'๐ถ', | |
':runner:': u'๐', | |
':running:': u'๐', | |
':dancer:': u'๐', | |
':couple:': u'๐ซ', | |
':family:': u'๐ช', | |
':two_men_holding_hands:': u'๐ฌ', | |
':two_women_holding_hands:': u'๐ญ', | |
':couplekiss:': u'๐', | |
':couple_with_heart:': u'๐', | |
':dancers:': u'๐ฏ', | |
':ok_woman:': u'๐', | |
':no_good:': u'๐ ', | |
':information_desk_person:': u'๐', | |
':raising_hand:': u'๐', | |
':massage:': u'๐', | |
':haircut:': u'๐', | |
':nail_care:': u'๐ ', | |
':bride_with_veil:': u'๐ฐ', | |
':person_with_pouting_face:': u'๐', | |
':person_frowning:': u'๐', | |
':bow:': u'๐', | |
':tophat:': u'๐ฉ', | |
':crown:': u'๐', | |
':womans_hat:': u'๐', | |
':athletic_shoe:': u'๐', | |
':mans_shoe:': u'๐', | |
':shoe:': u'๐', | |
':sandal:': u'๐ก', | |
':high_heel:': u'๐ ', | |
':boot:': u'๐ข', | |
':shirt:': u'๐', | |
':tshirt:': u'๐', | |
':necktie:': u'๐', | |
':womans_clothes:': u'๐', | |
':dress:': u'๐', | |
':running_shirt_with_sash:': u'๐ฝ', | |
':jeans:': u'๐', | |
':kimono:': u'๐', | |
':bikini:': u'๐', | |
':briefcase:': u'๐ผ', | |
':handbag:': u'๐', | |
':pouch:': u'๐', | |
':purse:': u'๐', | |
':eyeglasses:': u'๐', | |
':ribbon:': u'๐', | |
':closed_umbrella:': u'๐', | |
':lipstick:': u'๐', | |
':yellow_heart:': u'๐', | |
':blue_heart:': u'๐', | |
':purple_heart:': u'๐', | |
':green_heart:': u'๐', | |
':heart:': u'โค๏ธ', | |
':broken_heart:': u'๐', | |
':heartpulse:': u'๐', | |
':heartbeat:': u'๐', | |
':two_hearts:': u'๐', | |
':sparkling_heart:': u'๐', | |
':revolving_hearts:': u'๐', | |
':cupid:': u'๐', | |
':love_letter:': u'๐', | |
':kiss:': u'๐', | |
':ring:': u'๐', | |
':gem:': u'๐', | |
':bust_in_silhouette:': u'๐ค', | |
':busts_in_silhouette:': u'๐ฅ', | |
':speech_balloon:': u'๐ฌ', | |
':footprints:': u'๐ฃ', | |
':thought_balloon:': u'๐ญ', | |
':dog:': u'๐ถ', | |
':wolf:': u'๐บ', | |
':cat:': u'๐ฑ', | |
':mouse:': u'๐ญ', | |
':hamster:': u'๐น', | |
':rabbit:': u'๐ฐ', | |
':frog:': u'๐ธ', | |
':tiger:': u'๐ฏ', | |
':koala:': u'๐จ', | |
':bear:': u'๐ป', | |
':pig:': u'๐ท', | |
':pig_nose:': u'๐ฝ', | |
':cow:': u'๐ฎ', | |
':boar:': u'๐', | |
':monkey_face:': u'๐ต', | |
':monkey:': u'๐', | |
':horse:': u'๐ด', | |
':sheep:': u'๐', | |
':elephant:': u'๐', | |
':panda_face:': u'๐ผ', | |
':penguin:': u'๐ง', | |
':bird:': u'๐ฆ', | |
':baby_chick:': u'๐ค', | |
':hatched_chick:': u'๐ฅ', | |
':hatching_chick:': u'๐ฃ', | |
':chicken:': u'๐', | |
':snake:': u'๐', | |
':turtle:': u'๐ข', | |
':bug:': u'๐', | |
':bee:': u'๐', | |
':honeybee:': u'๐', | |
':ant:': u'๐', | |
':beetle:': u'๐', | |
':snail:': u'๐', | |
':octopus:': u'๐', | |
':shell:': u'๐', | |
':tropical_fish:': u'๐ ', | |
':fish:': u'๐', | |
':dolphin:': u'๐ฌ', | |
':flipper:': u'๐ฌ', | |
':whale:': u'๐ณ', | |
':whale2:': u'๐', | |
':cow2:': u'๐', | |
':ram:': u'๐', | |
':rat:': u'๐', | |
':water_buffalo:': u'๐', | |
':tiger2:': u'๐ ', | |
':rabbit2:': u'๐', | |
':dragon:': u'๐', | |
':racehorse:': u'๐', | |
':goat:': u'๐', | |
':rooster:': u'๐', | |
':dog2:': u'๐', | |
':pig2:': u'๐', | |
':mouse2:': u'๐', | |
':ox:': u'๐', | |
':dragon_face:': u'๐ฒ', | |
':blowfish:': u'๐ก', | |
':crocodile:': u'๐', | |
':camel:': u'๐ซ', | |
':dromedary_camel:': u'๐ช', | |
':leopard:': u'๐', | |
':cat2:': u'๐', | |
':poodle:': u'๐ฉ', | |
':feet:': u'๐พ', | |
':paw_prints:': u'๐พ', | |
':bouquet:': u'๐', | |
':cherry_blossom:': u'๐ธ', | |
':tulip:': u'๐ท', | |
':four_leaf_clover:': u'๐', | |
':rose:': u'๐น', | |
':sunflower:': u'๐ป', | |
':hibiscus:': u'๐บ', | |
':maple_leaf:': u'๐', | |
':leaves:': u'๐', | |
':fallen_leaf:': u'๐', | |
':herb:': u'๐ฟ', | |
':ear_of_rice:': u'๐พ', | |
':mushroom:': u'๐', | |
':cactus:': u'๐ต', | |
':palm_tree:': u'๐ด', | |
':evergreen_tree:': u'๐ฒ', | |
':deciduous_tree:': u'๐ณ', | |
':chestnut:': u'๐ฐ', | |
':seedling:': u'๐ฑ', | |
':blossom:': u'๐ผ', | |
':globe_with_meridians:': u'๐', | |
':sun_with_face:': u'๐', | |
':full_moon_with_face:': u'๐', | |
':new_moon_with_face:': u'๐', | |
':new_moon:': u'๐', | |
':waxing_crescent_moon:': u'๐', | |
':first_quarter_moon:': u'๐', | |
':moon:': u'๐', | |
':waxing_gibbous_moon:': u'๐', | |
':full_moon:': u'๐', | |
':waning_gibbous_moon:': u'๐', | |
':last_quarter_moon:': u'๐', | |
':waning_crescent_moon:': u'๐', | |
':last_quarter_moon_with_face:': u'๐', | |
':first_quarter_moon_with_face:': u'๐', | |
':crescent_moon:': u'๐', | |
':earth_africa:': u'๐', | |
':earth_americas:': u'๐', | |
':earth_asia:': u'๐', | |
':volcano:': u'๐', | |
':milky_way:': u'๐', | |
':stars:': u'๐ ', | |
':star:': u'โญ', | |
':sunny:': u'โ๏ธ', | |
':partly_sunny:': u'โ ', | |
':cloud:': u'โ๏ธ', | |
':zap:': u'โก', | |
':umbrella:': u'โ', | |
':snowflake:': u'โ๏ธ', | |
':snowman:': u'โ', | |
':cyclone:': u'๐', | |
':foggy:': u'๐', | |
':rainbow:': u'๐', | |
':ocean:': u'๐', | |
':bamboo:': u'๐', | |
':gift_heart:': u'๐', | |
':dolls:': u'๐', | |
':school_satchel:': u'๐', | |
':mortar_board:': u'๐', | |
':flags:': u'๐', | |
':fireworks:': u'๐', | |
':sparkler:': u'๐', | |
':wind_chime:': u'๐', | |
':rice_scene:': u'๐', | |
':jack_o_lantern:': u'๐', | |
':ghost:': u'๐ป', | |
':santa:': u'๐ ', | |
':christmas_tree:': u'๐', | |
':gift:': u'๐', | |
':tanabata_tree:': u'๐', | |
':tada:': u'๐', | |
':confetti_ball:': u'๐', | |
':balloon:': u'๐', | |
':crossed_flags:': u'๐', | |
':crystal_ball:': u'๐ฎ', | |
':movie_camera:': u'๐ฅ', | |
':camera:': u'๐ท', | |
':video_camera:': u'๐น', | |
':vhs:': u'๐ผ', | |
':cd:': u'๐ฟ', | |
':dvd:': u'๐', | |
':minidisc:': u'๐ฝ', | |
':floppy_disk:': u'๐พ', | |
':computer:': u'๐ป', | |
':iphone:': u'๐ฑ', | |
':phone:': u'โ๏ธ', | |
':telephone:': u'โ๏ธ', | |
':telephone_receiver:': u'๐', | |
':pager:': u'๐', | |
':fax:': u'๐ ', | |
':satellite:': u'๐ก', | |
':tv:': u'๐บ', | |
':radio:': u'๐ป', | |
':loud_sound:': u'๐', | |
':sound:': u'๐', | |
':speaker:': u'๐', | |
':mute:': u'๐', | |
':bell:': u'๐', | |
':no_bell:': u'๐', | |
':loudspeaker:': u'๐ข', | |
':mega:': u'๐ฃ', | |
':hourglass_flowing_sand:': u'โณ', | |
':hourglass:': u'โ', | |
':alarm_clock:': u'โฐ', | |
':watch:': u'โ', | |
':unlock:': u'๐', | |
':lock:': u'๐', | |
':lock_with_ink_pen:': u'๐', | |
':closed_lock_with_key:': u'๐', | |
':key:': u'๐', | |
':mag_right:': u'๐', | |
':bulb:': u'๐ก', | |
':flashlight:': u'๐ฆ', | |
':high_brightness:': u'๐', | |
':low_brightness:': u'๐ ', | |
':electric_plug:': u'๐', | |
':battery:': u'๐', | |
':mag:': u'๐', | |
':bathtub:': u'๐', | |
':bath:': u'๐', | |
':shower:': u'๐ฟ', | |
':toilet:': u'๐ฝ', | |
':wrench:': u'๐ง', | |
':nut_and_bolt:': u'๐ฉ', | |
':hammer:': u'๐จ', | |
':door:': u'๐ช', | |
':smoking:': u'๐ฌ', | |
':bomb:': u'๐ฃ', | |
':gun:': u'๐ซ', | |
':hocho:': u'๐ช', | |
':knife:': u'๐ช', | |
':pill:': u'๐', | |
':syringe:': u'๐', | |
':moneybag:': u'๐ฐ', | |
':yen:': u'๐ด', | |
':dollar:': u'๐ต', | |
':pound:': u'๐ท', | |
':euro:': u'๐ถ', | |
':credit_card:': u'๐ณ', | |
':money_with_wings:': u'๐ธ', | |
':calling:': u'๐ฒ', | |
':e-mail:': u'๐ง', | |
':inbox_tray:': u'๐ฅ', | |
':outbox_tray:': u'๐ค', | |
':email:': u'โ๏ธ', | |
':envelope:': u'โ๏ธ', | |
':envelope_with_arrow:': u'๐ฉ', | |
':incoming_envelope:': u'๐จ', | |
':postal_horn:': u'๐ฏ', | |
':mailbox:': u'๐ซ', | |
':mailbox_closed:': u'๐ช', | |
':mailbox_with_mail:': u'๐ฌ', | |
':mailbox_with_no_mail:': u'๐ญ', | |
':postbox:': u'๐ฎ', | |
':package:': u'๐ฆ', | |
':memo:': u'๐', | |
':pencil:': u'๐', | |
':page_facing_up:': u'๐', | |
':page_with_curl:': u'๐', | |
':bookmark_tabs:': u'๐', | |
':bar_chart:': u'๐', | |
':chart_with_upwards_trend:': u'๐', | |
':chart_with_downwards_trend:': u'๐', | |
':scroll:': u'๐', | |
':clipboard:': u'๐', | |
':date:': u'๐ ', | |
':calendar:': u'๐', | |
':card_index:': u'๐', | |
':file_folder:': u'๐', | |
':open_file_folder:': u'๐', | |
':scissors:': u'โ๏ธ', | |
':pushpin:': u'๐', | |
':paperclip:': u'๐', | |
':black_nib:': u'โ๏ธ', | |
':pencil2:': u'โ๏ธ', | |
':straight_ruler:': u'๐', | |
':triangular_ruler:': u'๐', | |
':closed_book:': u'๐', | |
':green_book:': u'๐', | |
':blue_book:': u'๐', | |
':orange_book:': u'๐', | |
':notebook:': u'๐', | |
':notebook_with_decorative_cover:': u'๐', | |
':ledger:': u'๐', | |
':books:': u'๐', | |
':book:': u'๐', | |
':open_book:': u'๐', | |
':bookmark:': u'๐', | |
':name_badge:': u'๐', | |
':microscope:': u'๐ฌ', | |
':telescope:': u'๐ญ', | |
':newspaper:': u'๐ฐ', | |
':art:': u'๐จ', | |
':clapper:': u'๐ฌ', | |
':microphone:': u'๐ค', | |
':headphones:': u'๐ง', | |
':musical_score:': u'๐ผ', | |
':musical_note:': u'๐ต', | |
':notes:': u'๐ถ', | |
':musical_keyboard:': u'๐น', | |
':violin:': u'๐ป', | |
':trumpet:': u'๐บ', | |
':saxophone:': u'๐ท', | |
':guitar:': u'๐ธ', | |
':space_invader:': u'๐พ', | |
':video_game:': u'๐ฎ', | |
':black_joker:': u'๐', | |
':flower_playing_cards:': u'๐ด', | |
':mahjong:': u'๐', | |
':game_die:': u'๐ฒ', | |
':dart:': u'๐ฏ', | |
':football:': u'๐', | |
':basketball:': u'๐', | |
':soccer:': u'โฝ', | |
':baseball:': u'โพ๏ธ', | |
':tennis:': u'๐พ', | |
':8ball:': u'๐ฑ', | |
':rugby_football:': u'๐', | |
':bowling:': u'๐ณ', | |
':golf:': u'โณ', | |
':mountain_bicyclist:': u'๐ต', | |
':bicyclist:': u'๐ด', | |
':checkered_flag:': u'๐', | |
':horse_racing:': u'๐', | |
':trophy:': u'๐', | |
':ski:': u'๐ฟ', | |
':snowboarder:': u'๐', | |
':swimmer:': u'๐', | |
':surfer:': u'๐', | |
':fishing_pole_and_fish:': u'๐ฃ', | |
':coffee:': u'โ', | |
':tea:': u'๐ต', | |
':sake:': u'๐ถ', | |
':baby_bottle:': u'๐ผ', | |
':beer:': u'๐บ', | |
':beers:': u'๐ป', | |
':cocktail:': u'๐ธ', | |
':tropical_drink:': u'๐น', | |
':wine_glass:': u'๐ท', | |
':fork_and_knife:': u'๐ด', | |
':pizza:': u'๐', | |
':hamburger:': u'๐', | |
':fries:': u'๐', | |
':poultry_leg:': u'๐', | |
':meat_on_bone:': u'๐', | |
':spaghetti:': u'๐', | |
':curry:': u'๐', | |
':fried_shrimp:': u'๐ค', | |
':bento:': u'๐ฑ', | |
':sushi:': u'๐ฃ', | |
':fish_cake:': u'๐ฅ', | |
':rice_ball:': u'๐', | |
':rice_cracker:': u'๐', | |
':rice:': u'๐', | |
':ramen:': u'๐', | |
':stew:': u'๐ฒ', | |
':oden:': u'๐ข', | |
':dango:': u'๐ก', | |
':egg:': u'๐ณ', | |
':bread:': u'๐', | |
':doughnut:': u'๐ฉ', | |
':custard:': u'๐ฎ', | |
':icecream:': u'๐ฆ', | |
':ice_cream:': u'๐จ', | |
':shaved_ice:': u'๐ง', | |
':birthday:': u'๐', | |
':cake:': u'๐ฐ', | |
':cookie:': u'๐ช', | |
':chocolate_bar:': u'๐ซ', | |
':candy:': u'๐ฌ', | |
':lollipop:': u'๐ญ', | |
':honey_pot:': u'๐ฏ', | |
':apple:': u'๐', | |
':green_apple:': u'๐', | |
':tangerine:': u'๐', | |
':lemon:': u'๐', | |
':cherries:': u'๐', | |
':grapes:': u'๐', | |
':watermelon:': u'๐', | |
':strawberry:': u'๐', | |
':peach:': u'๐', | |
':melon:': u'๐', | |
':banana:': u'๐', | |
':pear:': u'๐', | |
':pineapple:': u'๐', | |
':sweet_potato:': u'๐ ', | |
':eggplant:': u'๐', | |
':tomato:': u'๐ ', | |
':corn:': u'๐ฝ', | |
':house:': u'๐ ', | |
':house_with_garden:': u'๐ก', | |
':school:': u'๐ซ', | |
':office:': u'๐ข', | |
':post_office:': u'๐ฃ', | |
':hospital:': u'๐ฅ', | |
':bank:': u'๐ฆ', | |
':convenience_store:': u'๐ช', | |
':love_hotel:': u'๐ฉ', | |
':hotel:': u'๐จ', | |
':wedding:': u'๐', | |
':church:': u'โช', | |
':department_store:': u'๐ฌ', | |
':european_post_office:': u'๐ค', | |
':city_sunrise:': u'๐', | |
':city_sunset:': u'๐', | |
':japanese_castle:': u'๐ฏ', | |
':european_castle:': u'๐ฐ', | |
':tent:': u'โบ', | |
':factory:': u'๐ญ', | |
':tokyo_tower:': u'๐ผ', | |
':japan:': u'๐พ', | |
':mount_fuji:': u'๐ป', | |
':sunrise_over_mountains:': u'๐', | |
':sunrise:': u'๐ ', | |
':night_with_stars:': u'๐', | |
':statue_of_liberty:': u'๐ฝ', | |
':bridge_at_night:': u'๐', | |
':carousel_horse:': u'๐ ', | |
':ferris_wheel:': u'๐ก', | |
':fountain:': u'โฒ', | |
':roller_coaster:': u'๐ข', | |
':ship:': u'๐ข', | |
':boat:': u'โต', | |
':sailboat:': u'โต', | |
':speedboat:': u'๐ค', | |
':rowboat:': u'๐ฃ', | |
':anchor:': u'โ', | |
':rocket:': u'๐', | |
':airplane:': u'โ๏ธ', | |
':seat:': u'๐บ', | |
':helicopter:': u'๐', | |
':steam_locomotive:': u'๐', | |
':tram:': u'๐', | |
':station:': u'๐', | |
':mountain_railway:': u'๐', | |
':train2:': u'๐', | |
':bullettrain_side:': u'๐', | |
':bullettrain_front:': u'๐ ', | |
':light_rail:': u'๐', | |
':metro:': u'๐', | |
':monorail:': u'๐', | |
':train:': u'๐', | |
':railway_car:': u'๐', | |
':trolleybus:': u'๐', | |
':bus:': u'๐', | |
':oncoming_bus:': u'๐', | |
':blue_car:': u'๐', | |
':oncoming_automobile:': u'๐', | |
':car:': u'๐', | |
':red_car:': u'๐', | |
':taxi:': u'๐', | |
':oncoming_taxi:': u'๐', | |
':articulated_lorry:': u'๐', | |
':truck:': u'๐', | |
':rotating_light:': u'๐จ', | |
':police_car:': u'๐', | |
':oncoming_police_car:': u'๐', | |
':fire_engine:': u'๐', | |
':ambulance:': u'๐', | |
':minibus:': u'๐', | |
':bike:': u'๐ฒ', | |
':aerial_tramway:': u'๐ก', | |
':suspension_railway:': u'๐', | |
':mountain_cableway:': u'๐ ', | |
':tractor:': u'๐', | |
':barber:': u'๐', | |
':busstop:': u'๐', | |
':ticket:': u'๐ซ', | |
':vertical_traffic_light:': u'๐ฆ', | |
':traffic_light:': u'๐ฅ', | |
':warning:': u'โ ๏ธ', | |
':construction:': u'๐ง', | |
':beginner:': u'๐ฐ', | |
':fuelpump:': u'โฝ', | |
':izakaya_lantern:': u'๐ฎ', | |
':lantern:': u'๐ฎ', | |
':slot_machine:': u'๐ฐ', | |
':hotsprings:': u'โจ๏ธ', | |
':moyai:': u'๐ฟ', | |
':circus_tent:': u'๐ช', | |
':performing_arts:': u'๐ญ', | |
':round_pushpin:': u'๐', | |
':triangular_flag_on_post:': u'๐ฉ', | |
':jp:': u'๐ฏ๐ต', | |
':kr:': u'๐ฐ๐ท', | |
':de:': u'๐ฉ๐ช', | |
':cn:': u'๐จ๐ณ', | |
':us:': u'๐บ๐ธ', | |
':fr:': u'๐ซ๐ท', | |
':es:': u'๐ช๐ธ', | |
':it:': u'๐ฎ๐น', | |
':ru:': u'๐ท๐บ', | |
':gb:': u'๐ฌ๐ง', | |
':uk:': u'๐ฌ๐ง', | |
':one:': u'1๏ธโฃ', | |
':two:': u'2๏ธโฃ', | |
':three:': u'3๏ธโฃ', | |
':four:': u'4๏ธโฃ', | |
':five:': u'5๏ธโฃ', | |
':six:': u'6๏ธโฃ', | |
':seven:': u'7๏ธโฃ', | |
':eight:': u'8๏ธโฃ', | |
':nine:': u'9๏ธโฃ', | |
':zero:': u'0๏ธโฃ', | |
':keycap_ten:': u'๐', | |
':1234:': u'๐ข', | |
':hash:': u'#๏ธโฃ', | |
':symbols:': u'๐ฃ', | |
':arrow_up:': u'โฌ๏ธ', | |
':arrow_down:': u'โฌ๏ธ', | |
':arrow_left:': u'โฌ ๏ธ', | |
':arrow_right:': u'โก๏ธ', | |
':capital_abcd:': u'๐ ', | |
':abcd:': u'๐ก', | |
':abc:': u'๐ค', | |
':arrow_upper_right:': u'โ๏ธ', | |
':arrow_upper_left:': u'โ๏ธ', | |
':arrow_lower_right:': u'โ๏ธ', | |
':arrow_lower_left:': u'โ๏ธ', | |
':left_right_arrow:': u'โ๏ธ', | |
':arrow_up_down:': u'โ๏ธ', | |
':arrows_counterclockwise:': u'๐', | |
':arrow_backward:': u'โ๏ธ', | |
':arrow_forward:': u'โถ๏ธ', | |
':arrow_up_small:': u'๐ผ', | |
':arrow_down_small:': u'๐ฝ', | |
':leftwards_arrow_with_hook:': u'โฉ๏ธ', | |
':arrow_right_hook:': u'โช๏ธ', | |
':information_source:': u'โน๏ธ', | |
':rewind:': u'โช', | |
':fast_forward:': u'โฉ', | |
':arrow_double_up:': u'โซ', | |
':arrow_double_down:': u'โฌ', | |
':arrow_heading_down:': u'โคต๏ธ', | |
':arrow_heading_up:': u'โคด๏ธ', | |
':ok:': u'๐', | |
':twisted_rightwards_arrows:': u'๐', | |
':repeat:': u'๐', | |
':repeat_one:': u'๐', | |
':new:': u'๐', | |
':up:': u'๐', | |
':cool:': u'๐', | |
':free:': u'๐', | |
':ng:': u'๐', | |
':signal_strength:': u'๐ถ', | |
':cinema:': u'๐ฆ', | |
':koko:': u'๐', | |
':u6307:': u'๐ฏ', | |
':u7a7a:': u'๐ณ', | |
':u6e80:': u'๐ต', | |
':u5408:': u'๐ด', | |
':u7981:': u'๐ฒ', | |
':ideograph_advantage:': u'๐', | |
':u5272:': u'๐น', | |
':u55b6:': u'๐บ', | |
':u6709:': u'๐ถ', | |
':u7121:': u'๐', | |
':restroom:': u'๐ป', | |
':mens:': u'๐น', | |
':womens:': u'๐บ', | |
':baby_symbol:': u'๐ผ', | |
':wc:': u'๐พ', | |
':potable_water:': u'๐ฐ', | |
':put_litter_in_its_place:': u'๐ฎ', | |
':parking:': u'๐ ฟ๏ธ', | |
':wheelchair:': u'โฟ', | |
':no_smoking:': u'๐ญ', | |
':u6708:': u'๐ท๏ธ', | |
':u7533:': u'๐ธ', | |
':sa:': u'๐๏ธ', | |
':m:': u'โ๏ธ', | |
':passport_control:': u'๐', | |
':baggage_claim:': u'๐', | |
':left_luggage:': u'๐ ', | |
':customs:': u'๐', | |
':accept:': u'๐', | |
':secret:': u'ใ๏ธ', | |
':congratulations:': u'ใ๏ธ', | |
':cl:': u'๐', | |
':sos:': u'๐', | |
':id:': u'๐', | |
':no_entry_sign:': u'๐ซ', | |
':underage:': u'๐', | |
':no_mobile_phones:': u'๐ต', | |
':do_not_litter:': u'๐ฏ', | |
':non-potable_water:': u'๐ฑ', | |
':no_bicycles:': u'๐ณ', | |
':no_pedestrians:': u'๐ท', | |
':children_crossing:': u'๐ธ', | |
':no_entry:': u'โ', | |
':eight_spoked_asterisk:': u'โณ๏ธ', | |
':sparkle:': u'โ๏ธ', | |
':negative_squared_cross_mark:': u'โ', | |
':white_check_mark:': u'โ ', | |
':eight_pointed_black_star:': u'โด๏ธ', | |
':heart_decoration:': u'๐', | |
':vs:': u'๐', | |
':vibration_mode:': u'๐ณ', | |
':mobile_phone_off:': u'๐ด', | |
':a:': u'๐ ฐ๏ธ', | |
':b:': u'๐ ฑ๏ธ', | |
':ab:': u'๐', | |
':o2:': u'๐ พ๏ธ', | |
':diamond_shape_with_a_dot_inside:': u'๐ ', | |
':loop:': u'โฟ', | |
':recycle:': u'โป๏ธ', | |
':aries:': u'โ', | |
':taurus:': u'โ', | |
':gemini:': u'โ', | |
':cancer:': u'โ', | |
':leo:': u'โ', | |
':virgo:': u'โ', | |
':libra:': u'โ', | |
':scorpius:': u'โ', | |
':sagittarius:': u'โ', | |
':capricorn:': u'โ', | |
':aquarius:': u'โ', | |
':pisces:': u'โ', | |
':ophiuchus:': u'โ', | |
':six_pointed_star:': u'๐ฏ', | |
':atm:': u'๐ง', | |
':chart:': u'๐น', | |
':heavy_dollar_sign:': u'๐ฒ', | |
':currency_exchange:': u'๐ฑ', | |
':copyright:': u'ยฉ๏ธ', | |
':registered:': u'ยฎ๏ธ', | |
':tm:': u'โข๏ธ', | |
':x:': u'โ', | |
':bangbang:': u'โผ๏ธ', | |
':interrobang:': u'โ๏ธ', | |
':exclamation:': u'โ', | |
':heavy_exclamation_mark:': u'โ', | |
':question:': u'โ', | |
':grey_exclamation:': u'โ', | |
':grey_question:': u'โ', | |
':o:': u'โญ', | |
':top:': u'๐', | |
':end:': u'๐', | |
':back:': u'๐', | |
':on:': u'๐', | |
':soon:': u'๐', | |
':arrows_clockwise:': u'๐', | |
':clock12:': u'๐', | |
':clock1230:': u'๐ง', | |
':clock1:': u'๐', | |
':clock130:': u'๐', | |
':clock2:': u'๐', | |
':clock230:': u'๐', | |
':clock3:': u'๐', | |
':clock330:': u'๐', | |
':clock4:': u'๐', | |
':clock430:': u'๐', | |
':clock5:': u'๐', | |
':clock530:': u'๐ ', | |
':clock6:': u'๐', | |
':clock7:': u'๐', | |
':clock8:': u'๐', | |
':clock9:': u'๐', | |
':clock10:': u'๐', | |
':clock11:': u'๐', | |
':clock630:': u'๐ก', | |
':clock730:': u'๐ข', | |
':clock830:': u'๐ฃ', | |
':clock930:': u'๐ค', | |
':clock1030:': u'๐ฅ', | |
':clock1130:': u'๐ฆ', | |
':heavy_multiplication_x:': u'โ๏ธ', | |
':heavy_plus_sign:': u'โ', | |
':heavy_minus_sign:': u'โ', | |
':heavy_division_sign:': u'โ', | |
':spades:': u'โ ๏ธ', | |
':hearts:': u'โฅ๏ธ', | |
':clubs:': u'โฃ๏ธ', | |
':diamonds:': u'โฆ๏ธ', | |
':white_flower:': u'๐ฎ', | |
':100:': u'๐ฏ', | |
':heavy_check_mark:': u'โ๏ธ', | |
':ballot_box_with_check:': u'โ๏ธ', | |
':radio_button:': u'๐', | |
':link:': u'๐', | |
':curly_loop:': u'โฐ', | |
':wavy_dash:': u'ใฐ๏ธ', | |
':part_alternation_mark:': u'ใฝ๏ธ', | |
':trident:': u'๐ฑ', | |
':black_medium_square:': u'โผ๏ธ', | |
':white_medium_square:': u'โป๏ธ', | |
':black_medium_small_square:': u'โพ', | |
':white_medium_small_square:': u'โฝ', | |
':black_small_square:': u'โช๏ธ', | |
':white_small_square:': u'โซ๏ธ', | |
':small_red_triangle:': u'๐บ', | |
':black_square_button:': u'๐ฒ', | |
':white_square_button:': u'๐ณ', | |
':black_circle:': u'โซ', | |
':white_circle:': u'โช', | |
':red_circle:': u'๐ด', | |
':large_blue_circle:': u'๐ต', | |
':small_red_triangle_down:': u'๐ป', | |
':white_large_square:': u'โฌ', | |
':black_large_square:': u'โฌ', | |
':large_orange_diamond:': u'๐ถ', | |
':large_blue_diamond:': u'๐ท', | |
':small_orange_diamond:': u'๐ธ', | |
':small_blue_diamond:': u'๐น', | |
} | |
# binning - i.e https://www.illumina.com/documents/products/technotes/technote_understanding_quality_scores.pdf | |
fastq_noemoji_map = { | |
#N (no call) N (no call) | |
'!': 'โ', | |
'"': 'โ', | |
#2โ9 6 | |
'#': 'โ', | |
'$': 'โ', | |
'%': 'โ', | |
'&': 'โ', | |
'\'': 'โ', | |
'(': 'โ', | |
')': 'โ', | |
'*': 'โ', | |
#10โ19 15 | |
'+': 'โ' , | |
',': 'โ' , | |
'-': 'โ' , | |
'.': 'โ' , | |
'/': 'โ' , | |
'0': 'โ' , | |
'1': 'โ' , | |
'2': 'โ' , | |
'3': 'โ' , | |
'4': 'โ' , | |
#20โ24 22 | |
'5': 'โ', | |
'6': 'โ', | |
'7': 'โ', | |
'8': 'โ', | |
'9': 'โ', | |
#25โ29 27 | |
':': 'โ ', | |
';': 'โ ', | |
'<': 'โ ', | |
'=': 'โ ', | |
'>': 'โ ', | |
#30โ34 33 | |
'?': 'โ', | |
'@': 'โ', | |
'A': 'โ', | |
'B': 'โ', | |
'C': 'โ', | |
#35โ39 37 | |
'D': 'โ', | |
'E': 'โ', | |
'F': 'โ', | |
'G': 'โ', | |
'H': 'โ', | |
#โฅ 40 40 | |
'I': 'โ', | |
'J': 'โ', | |
} | |
def emojify(text): | |
emoji_keys = re.findall(r':\S+:', text) | |
for emoji_key in emoji_keys: | |
raw_emoji = emoji_table.get(emoji_key, emoji_key) | |
text = text.replace(emoji_key, raw_emoji) | |
return text | |
class HelpFormatter(argparse.HelpFormatter): | |
def add_usage(self, usage, actions, groups, prefix=None): | |
if prefix is None: | |
prefix = 'Usage: samtools mpileup ... | ' | |
return super(HelpFormatter, self).add_usage( | |
usage, actions, groups, prefix) | |
parser = argparse.ArgumentParser( | |
description="""This replaces basecall quality scores with graphical equivalents.""", | |
formatter_class=HelpFormatter | |
) | |
parser.add_argument("inputdata", type=argparse.FileType('r'), nargs='?', help="intended to be piped from 'samtools mpileup'", default=sys.stdin) | |
group = parser.add_mutually_exclusive_group() | |
group.add_argument("--bars", action='store_const', dest='output_fmt', help="default", const=fastq_noemoji_map) | |
group.add_argument("--emoji", action='store_const', dest='output_fmt', const=fastq_emoji_map) | |
group.add_argument("--emoji-binned", action='store_const', dest='output_fmt', const=fastq_emoji_map_binned) | |
parser.set_defaults(inputdata="-", output_fmt=fastq_noemoji_map) | |
if __name__ == "__main__": | |
args = parser.parse_args() | |
replacements_dict = args.output_fmt | |
if not S_ISFIFO(os.fstat(0).st_mode) and args.inputdata.name=="<stdin>": # if not piped and no file specified | |
parser.print_help() | |
else: | |
for line in args.inputdata: | |
columns = line.split("\t") | |
columns[5] = "".join([chr(ord(c)) if (ord(c)-33) < 41 else chr(40+33) for c in columns[5]]) | |
strs_to_replace_re = re.compile(r'|'.join(re.escape(key) for key in replacements_dict.keys())) | |
columns[5] = strs_to_replace_re.sub(lambda x: replacements_dict.get(x.group(), "_"), columns[5]).replace("::",": :") | |
columns[5] = emojify(columns[5]).replace(" ","") | |
out_line = '\t'.join(columns) | |
print(f"{out_line}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment