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
Visual Studio Code (1.76.1, undefined, desktop) | |
Jupyter Extension Version: 2023.2.1200692131. | |
Python Extension Version: 2023.4.1. | |
Workspace folder /Users/zak/repos/test | |
warn 13:48:48.940: Exception while attempting zmq : No native build was found for platform=darwin arch=arm64 runtime=electron abi=106 uv=1 armv=8 libc=glibc node=16.14.2 electron=19.1.11 | |
loaded from: /Users/zak/.vscode/extensions/ms-toolsai.jupyter-2023.2.1200692131/out/node_modules/zeromq | |
User belongs to experiment group 'jupyterEnhancedDataViewer' | |
User belongs to experiment group 'jupyterTest' | |
debug 13:48:49.017: Updating cache with Python kernels |
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
import contextlib | |
import os | |
import sys | |
# Suppress stdout http://stackoverflow.com/a/17753573 | |
class DummyFile(object): | |
def write(self, x): pass | |
@contextlib.contextmanager | |
def no_stdout(std_channel, dest_filename): | |
old_std_channel = os.dup(std_channel.fileno()) |
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
import requests | |
import re | |
response = requests.post( | |
'http://bigg.ucsd.edu/advanced_search_external_id_results', | |
data={'database_source': 'kegg.compound', 'query': 'C00234'} | |
) | |
try: | |
print re.search(r'/models/universal/metabolites/([^"]+)', response.text).group(1) |
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
# inputs | |
# model, old_gene, new_gene | |
for reaction in model.genes.get_by_id(old_gene).reactions: | |
reaction.gene_reaction_rule = re.sub(r'\b' + old_gene + r'\b', new_gene, | |
reaction.gene_reaction_rule) | |
remove_genes(model, [g for g in model.genes if len(g.reactions) == 0]) |
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
# http://stackoverflow.com/questions/15288891/how-can-i-serve-files-with-utf-8-encoding-using-python-simplehttpserver | |
python -c "import SimpleHTTPServer; m = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map; m[''] = 'text/plain'; m.update(dict([(k, v + ';charset=UTF-8') for k, v in m.items()])); SimpleHTTPServer.test();" |
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
diff <(jq -S '.' s_cerevisiae.iMM904.all_reactions.json) <(jq '.' 2007179_map.json -S) | less |
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
#!/bin/bash | |
# Put this in .git/hooks/post-checkout, and chmod +x | |
/Users/zaking/.emacs.d/etags.sh -js -py -!/bin/ -!/lib/ -!escher.* |
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
tax_id Org_name GeneID CurrentID Status Symbol Aliases description other_designations map_location chromosome genomic_nucleotide_accession.version start_position_on_the_genomic_accession end_position_on_the_genomic_accession orientation exon_count OMIM | |
511145 Escherichia coli str. K-12 substr. MG1655 5625560 0 live aaaD b4634ECK4439, ylcF pseudo NC_000913.3 581354 581662 plus 0 | |
511145 Escherichia coli str. K-12 substr. MG1655 7751645 0 live aaaE b4693ECK1135, JW1135, ymfN pseudo NC_000913.3 1204404 1205537 plus 0 | |
511145 Escherichia coli str. K-12 substr. MG1655 947748 0 live aaeA b3241ECK3230, JW3210, yhcQ p-hydroxybenzoic acid efflux system component NC_000913.3 3388194 3389126 minus 0 | |
511145 Escherichia coli str. K-12 substr. MG1655 947747 0 live aaeB b3240ECK3229, JW3209, yhcP p-hydroxybenzoic acid efflux system component NC_000913.3 3386221 3388188 minus 0 | |
511145 Escherichia coli str. K-12 substr. MG1655 947760 0 live aaeR b3243ECK3232, JW3212, qseA, yhcS transcriptional regulator for |
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
import json | |
# save a single flux vector as JSON | |
flux_dictionary = {'asdf': 2} | |
with open('out.json', 'w') as f: | |
json.dump(flux_dictionary, f) | |
flux_dictionary = {'asdf': 2} | |
# save a flux comparison as JSON | |
flux_comp = [{'GAPD': 3}, {'GAPD': 4}] |
NewerOlder