Skip to content

Instantly share code, notes, and snippets.

View fomightez's full-sized avatar

Wayne's Bioinformatics Code Portal fomightez

View GitHub Profile
@fomightez
fomightez / remove blank lines regex.md
Last active May 26, 2026 04:26
remove all blank lines using regular expressions
@fomightez
fomightez / useful_jupyterlite_that_do_work_without_shell.py
Last active April 30, 2026 16:11
Useful snippets and examples for use of JupyterLite with commands typically related to the shell available in standard Jupyter
#Useful snippets and examples for use of JupyterLite with commands typically related to the shell available in standard Jupyter
# (Also see 'Useful snippets and examples for when converting command line commands from Jupyter/IPython back to Pure Python' at
# https://gist.github.com/fomightez/ed79e33e97601d839dd550fd224d583c because a lot of these overlap, yet JupyterLite has some magics that obviously don't work with Pure Python
# MAGIC COMMANDS THAT SHOULD WORK IN JUPYTERLITE
%pwd
%store s >test_store.txt # if `s` previously defined.
#`%ls` fails at present, but you can do
import os
os.listdir()
@fomightez
fomightez / getting_started_plotlypowerpoint.ipynb
Created April 19, 2026 04:27
Demo basics of plotlyPowerpoint working on MyBinder
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fomightez
fomightez / tqdm_in_jupyterlite_or_MyBinder_Served_Jupyter_April_2026.ipynb
Created April 6, 2026 15:02
tqdm Progress Bars in jupyterlite or MyBinder Served Jupyter (April_2026)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fomightez
fomightez / render_as_cartoon_only_MaxPerformance.ipy
Created March 11, 2026 15:58
Cartoon representation option for the core code sampling various combinations of applying colors from a specific palette to the chains of a large macromolecular complex
# Compromises quality for speed/efficiency
# REPLACE CONTENT OF THE CELL WITH THIS CODE, or use a varation of it if you just prefer cartoon represenation for your use:
text_2_save_templ = '''#!/usr/bin/python
import sys, os
# pymol environment
moddir='/opt/pymol-svn/modules'
sys.path.insert(0, moddir)
os.environ['PYMOL_PATH'] = os.path.join(moddir, 'pymol/pymol_path')
@fomightez
fomightez / streamlined_timestamp_start_end_miner_checker.py
Last active March 2, 2026 17:45
Calculate total time to run based on start and end timestamps from a typical `.out` log
# meant to be run with `uv run https://gist.githubusercontent.com/fomightez/eee9a448be7287a024d260ec80751120/raw/6fcaeed31d62b0f138e265684ceebfcc49c0f6e5/streamlined_timestamp_start_end_miner_checker.py out.txt`, or similar
# This handles evaluating date timestamp info in start and end timestamps of a pipeline.
#####*****------------------------------------------------------------*****#####
# This is meant to use with `uv` to run.
# First install `uv` with `pip install uv` then run `!uv run {script_url} {input_text_filepath}` where defined those variables prior
#-------------------------------------------------------------#
# Times printed for now. (Make a dataframe?)
#-------------------------------------------------------------#
# /// script
# requires-python = ">=3.12"
@fomightez
fomightez / evaluate_date_timestamps_in_pipeline_stdout.py
Last active March 2, 2026 17:31
Evaluating date timestamp info in typical long and short read pipeline.
# meant to be run with `uv run https://gist.githubusercontent.com/fomightez/f036794b91d10761466341644b3c1cac/raw/15da0209f7b09c1ba0130cf66646635c80a58bae/evaluate_date_timestamps_in_pipeline_stdout.py out.txt`, or similar
# This handles evaluating date timestamp info in typical long and short read pipeline.
#####*****------------------------------------------------------------*****#####
# This is meant to use with `uv` to run.
# First install `uv` with `pip install uv` then run `!uv run {script_url} {input_text_filepath}` where defined those variables prior
#-------------------------------------------------------------#
# Times printed for now. (Make a dataframe?)
#-------------------------------------------------------------#
# /// script
# requires-python = ">=3.12"
@fomightez
fomightez / useful_ipython_or_commandline_to_python_snippets.py
Last active January 6, 2026 18:12
Useful snippets and examples for when converting command line commands from Jupyter/IPython back to Pure Python
#Useful examples for when converting command line commands from Jupyter/IPython back to Pure Python
#(Also see 'Useful snippets and examples for use of JupyterLite with commands typically related to the shell available in standard Jupyter' at
# https://gist.github.com/fomightez/53a8e6153095402fe2f168789224099c because it has a few special options that will work in addition to these.)
# This is partly for when need to speed up a `.ipy` script running. It will run much faster as `.py` than as `.ipy` if there
# are a lot of calls to command line / shell commands because saves time by not spawning new shell instance for
# each. (`.ipy` version great for quicker development and proto-typing but `.py` MUCH FASTER for running.)
# The Python versions also have the advantage that you can use them inside functions (I think) because don't have problem like
# with `!cp fn unsanitized_{fn}`or `%store` where actually run in global namespace which cannot see Python variable `fn`
# local to the function.
# RELATED NOTE
@fomightez
fomightez / useful_pandas_snippets.py
Last active December 20, 2025 03:40 — forked from bsweger/useful_pandas_snippets.md
Useful Pandas Snippets
# List unique values in a DataFrame column
df['Column Name'].unique() # Note, `NaN` is included as a unique value. If you just want the number, use `nunique()` which stands
# for 'number of unique values'; By default, it excludes `NaN`. `.nunique(dropna=False)` will include `NaN` in the count of unique values.
# To extract a specific column (subset the dataframe), you can use [ ] (brackets) or attribute notation.
df.height
df['height']
# are same thing!!! (from http://www.stephaniehicks.com/learnPython/pages/pandas.html
# -or-
# http://www.datacarpentry.org/python-ecology-lesson/02-index-slice-subset/)