This file contains hidden or 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
| def mutate_amino(protein_str, mutations, offset=1): | |
| ''' mutations: {int>mutation_idx:str>AminoID}''' | |
| mut_protein_str = list(protein_str) | |
| for mut_idx in mutations.keys(): | |
| mut_protein_str[mut_idx-offset] = mutations[mut_idx] # Arg 71 His | R > H | |
| mut_protein_str = ''.join(mut_protein_str) | |
| return mut_protein_str |
This file contains hidden or 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
| import cv2 | |
| class PointGrabber: | |
| def __init__(self, imgPath, printCords=True): | |
| self.points = [] | |
| self.img = cv2.imread(imgPath, 1) | |
| self.printCords = printCords | |
| def select_point(self, event, x, y, flags, param): |
This file contains hidden or 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
| # Computes an ICS file of birthdays from a spreadsheet | |
| # spreadsheet in the format of | |
| # Name - persons name | |
| # Date - Birthdate in %m/%d/%Y format | |
| # Description - some links or other info you want to add | |
| # this is built ontop of ICSps | |
| # https://icspy.readthedocs.io/en/stable/ | |
| # install with pip install ics |
This file contains hidden or 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
| import re | |
| import pandas as pd | |
| # kwc 210310 | |
| data_fName = 'linkGrabberData.txt' | |
| saveName = 'linkedinLinks.csv' | |
| re_exp = '(((//)|(\\\\))+([\w\d:#@%/;$()~_?\+-=\\\.&](#!)?)*)' | |
This file contains hidden or 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
| import matplotlib.pyplot as plt | |
| # kwc 201208 | |
| # Create synthetic data for each plot | |
| np.random.seed(10) | |
| synData_1 = np.random.normal(100, 10, 200) | |
| synData_2 = np.random.normal(80, 30, 200) | |
| synData_3 = np.random.normal(90, 20, 200) | |
| synData_4 = np.random.normal(70, 25, 200) |
This file contains hidden or 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
| from itertools import groupby | |
| l1 = [1,1,1,2,2,2,2,2,1,1,1,0,0,0] | |
| l2 = range(len(l1)) | |
| [(k, list(group)) for k, group in groupby(l2, key=lambda _, ig=iter(l1): next(ig))] | |
| # Returns [(1, [0, 1, 2]), (2, [3, 4, 5, 6, 7]), (1, [8, 9, 10]), (0, [11, 12, 13])] |
This file contains hidden or 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
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| plt.style.use('seaborn-white') | |
| # Create test data | |
| a, b = np.random.randint(10, 25, 30), np.random.randint(0, 8, 30) | |
| a_mu, b_mu = np.mean(a), np.mean(b) | |
| a_std, b_std = np.std(a), np.std(b) | |
This file contains hidden or 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
| def scaleInRange(lon, a, b): | |
| r_max, r_min = max(lon), min(lon) | |
| slon = [] | |
| for i in lon: | |
| slon.append(((i - r_min) / (r_max - r_min)) * (b - a) + a) | |
| return slon | |
| # Example | |
| lon = range(1,100) | |
| a, b, = 4, 8 |
This file contains hidden or 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
| import pandas as pd | |
| import matplotlib.pyplot as plt | |
| import matplotlib.dates as mdates | |
| import datetime | |
| import random | |
| import matplotlib.ticker as mticker | |
| from pandas.plotting import register_matplotlib_converters | |
| register_matplotlib_converters() |
This file contains hidden or 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
| def strpMailTime(timestamp): | |
| if len(timestamp) < 27: | |
| # Ex. '5 Nov 2018 12:05:07 -0500' len 25 | |
| # '28 Oct 2019 03:33:57 -0400' len 26 | |
| dt = datetime.datetime.strptime(timestamp, "%d %b %Y %H:%M:%S %z") | |
| elif len(timestamp) > 29 and len(timestamp) < 32: | |
| # 'Fri, 6 Dec 2019 15:22:49 +0000' len 30 | |
| # 'Mon, 09 Dec 2019 14:19:26 +0000' len 31 | |
| dt = datetime.datetime.strptime(timestamp, "%a, %d %b %Y %H:%M:%S %z") | |
| elif len(timestamp) > 35 and len(timestamp) < 39: |
NewerOlder