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 junction_type2(row): | |
| """Junction type classification""" | |
| # if there is no exons supported by realible junctions | |
| # return a interable with empty strings | |
| if row['exons_w_junct_sup'] is None: | |
| return ['', ''] | |
| type_ = [] | |
| # each row is a junction | |
| j_start, j_end, exons, strand = row.loc[[ |
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 reverse_complement(sequence): | |
| tab = str.maketrans("ACGT", "TGCA") | |
| return sequence.translate(tab)[::-1] | |
| def apply_rc(row): | |
| if row['strand'] == '-': | |
| row['seq'] = reverse_complement(row['seq']) | |
| return row | |
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
| # run this in you bash command line | |
| # list all r3 packages installed with conda: | |
| conda list | grep r3 | awk '{print $1}') | |
| # remove all pakages r3 | |
| for i in $(conda list | grep r3 | awk '{print $1}'); do conda remove -y $i; done | |
| # finally, remove R | |
| conda remove r-essentials |
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
| \documentclass{article} | |
| \usepackage{tikz} | |
| \usepackage{array} | |
| \usepackage{siunitx} | |
| \usetikzlibrary{shapes.geometric, shapes.misc, arrows, fit, calc} | |
| \newcommand\addvmargin[1]{ | |
| \node[fit=(current bounding box),inner ysep=#1,inner xsep=0]{}; | |
| } |
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
| df['new'] = df['new'].str.split('/') # example how to listfy a column of strings | |
| temp = pd.DataFrame(df['new'].dropna().tolist()) | |
| temp = temp.stack() | |
| temp.index = temp.index.droplevel(1) # index need to be coherent with the original dataframe | |
| temp.name = 'new_colum' # name of the new column in the original dataframe | |
| df = df.join(temp) |
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 better_table(table, caption, name): | |
| start = r""" | |
| \begin{{table}}[!htb] | |
| \sisetup{{round-mode=places, round-precision=2}} | |
| \caption{{{}}}\label{{table:{}}} | |
| \centering | |
| """.format(caption, name) | |
| end = r"\end{table}" |
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 operator | |
| sequence = "ACGACTGATCGATCGATCGATGCATCGATCGACGAT" | |
| random_positions = random.sample(xrange(len(sequence)), 30) | |
| get_positions = operator.itemgetter(*random_positions) | |
| get_positions(sequence) | |
| ('T', 'C', 'G', 'C', 'A', 'C', 'C', 'T', 'A', 'T', 'G', 'T', 'A', 'T', 'C', 'C', 'T', 'T', 'A', 'G', 'T', 'A', 'A', 'A', 'C', 'G', 'G', 'C', 'G', 'A') | |
| from itertools import groupby |
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 urlparse import parse_qs | |
| import pandas as pd | |
| def _fetch_uniprot_gff(identifier): | |
| """ | |
| Retrieve UniProt data from the GFF file | |
| :param identifier: UniProt accession identifier | |
| :type identifier: 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
| print '>\n' + '\n> \n'.join(list(df.query(...).sequence_column)) |
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 requests | |
| data = {"title": "Found a bug", # str | |
| "body": "I'm having a problem with this.", # str | |
| "assignee": None, # username str or None | |
| "milestone": 1, # int | |
| "labels": ['label1']} # list of str | |
| def submit_github_issue(data, token, username, repo): | |
| headers = {'Content-Type':'application/json', |