REGEX remove blank lines:
FROM: http://www.ultraedit.com/support/tutorials_power_tips/ultraedit/remove_blank_lines.html
FIND:
^(?:[\t ]*(?:\r?\n|\r))+
REGEX remove blank lines:
FROM: http://www.ultraedit.com/support/tutorials_power_tips/ultraedit/remove_blank_lines.html
FIND:
^(?:[\t ]*(?:\r?\n|\r))+
| #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() |
| # 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') |
| # 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" |
| # 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" |
| #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 |
| # 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/) |