Skip to content

Instantly share code, notes, and snippets.

View altanner's full-sized avatar
🦉

Alastair Tanner altanner

🦉
View GitHub Profile
@altanner
altanner / glen221202.py
Created December 2, 2022 14:16
Some dictionary / DF wrangling with BioPython
#fasta file to dictionary
import pandas as pd
import argparse
from Bio import SeqIO
# make a parser so we can pass things in from command line
parser = argparse.ArgumentParser(
prog = "Name of the program",
description = "What the program does",
epilog = "Text at the bottom of help")
@altanner
altanner / abimbola.py
Created November 23, 2022 10:21
How to search through a fasta file and print out the sequence associated with a record name.
from Bio import SeqIO
def fasta_search(fastas, target):
"""
Search for a sequence motif in multiple FASTA records.
Args: fastas - SeqIO iterable
target - the sequence name to find (string)
Returns: Nothing.
@altanner
altanner / gist:a0397fb4dd1a0615dc0d0035fb36515a
Last active January 19, 2023 12:28
Reminder of how to make a new Hugo themed github pages site
#latest first
create REPONAME on github
mkdir REPONAME
cd REPONAME
git init
hugo new site site-build
cp -r ../data-vis-with-streamlit/site-build/content site-build
cp -r ../data-vis-with-streamlit/site-build/themes/LoveIt_local site-build/themes
spec_dict = {
"A": "dog",
"B": "parrot",
"C": "algae",
"D": "trilobite",
"E": "apple",
"F": "dugong",
"G": "placozoa"}
((B:0.2,(C:0.3,D:0.4)E:0.5)F:0.1)A;
#~ standard library imports
import sys
import re
#~ local file import (the dict of codes:species)
try:
import species_dict
except Exception as e:
print(f"You'll need your codes:species dict here, named \"species_dict.py\"\n"
f"or there is an issue: {e}")
CRIM ZN INDUS CHAS NOX RM AGE DIS RAD TAX PTRATIO BK LSTAT MEDV
0.00632 18.00 2.310 0 0.5380 6.5750 65.20 4.0900 1 296.0 15.30 396.90 4.98 24.00
0.02731 0.00 7.070 0 0.4690 6.4210 78.90 4.9671 2 242.0 17.80 396.90 9.14 21.60
0.02729 0.00 7.070 0 0.4690 7.1850 61.10 4.9671 2 242.0 17.80 392.83 4.03 34.70
0.03237 0.00 2.180 0 0.4580 6.9980 45.80 6.0622 3 222.0 18.70 394.63 2.94 33.40
0.06905 0.00 2.180 0 0.4580 7.1470 54.20 6.0622 3 222.0 18.70 396.90 5.33 36.20
0.02985 0.00 2.180 0 0.4580 6.4300 58.70 6.0622 3 222.0 18.70 394.12 5.21 28.70
0.08829 12.50 7.870 0 0.5240 6.0120 66.60 5.5605 5 311.0 15.20 395.60 12.43 22.90
0.14455 12.50 7.870 0 0.5240 6.1720 96.10 5.9505 5 311.0 15.20 396.90 19.15 27.10
0.21124 12.50 7.870 0 0.5240 5.6310 100.00 6.0821 5 311.0 15.20 386.63 29.93 16.50
import something
def bobble();
print("ah")
@altanner
altanner / gist.py
Last active August 1, 2020 11:23
DaSciResCom_example
# hello, this is gist, where snippets of code can be shared
# without needing a full repository.
# here is an example of a gist :)
# chunks splits the screen_name list into manageable blocks:
def chunks(a_list, length_of_chunk):
# For item i in a range that is a length of a_list,
for i in range(0, len(a_list), length_of_chunk):