Skip to content

Instantly share code, notes, and snippets.

View rhine3's full-sized avatar

Tessa Rhinehart rhine3

View GitHub Profile
@rhine3
rhine3 / bridges.md
Last active November 18, 2020 15:38 — forked from sammlapp/bridges.md
Bridges PSC
@rhine3
rhine3 / rename_audiomoth_filenames.R
Last active June 24, 2020 22:28
Convert hex filenames to decimal date/time using R
top_dir <- "/Users/tessa/Desktop/moth-tests/M10_0001_test0"
for (file in list.files(top_dir)){
old_filepath <- paste(top_dir, file, sep="/")
print(paste("Old filepath:", old_filepath))
hex_code <- tools::file_path_sans_ext(basename(old_filepath))
seconds <- strtoi(hex_code, base=16)
true_time <- as.POSIXct(seconds, origin="1970-01-01")
formatted <- strftime(true_time, "%Y%m%d_%H%M%S")
new_filepath <- paste(top_dir, "/", formatted, ".WAV", sep="")
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import pandas as pd
# Function for processing pandas dataframe
def process(df, user_col, date_col, save_to):
'''
Save table of earliest date per user
Save dataframe containing earliest value
in date_col for each value in user_col. Creates dataframe
containing one row per unique value in user_col,
@rhine3
rhine3 / filename-convert.py
Last active June 26, 2019 15:10
Convert AudioMoth hexadecimal filenames
from datetime import datetime, timedelta
filename = '5BAC2C6F'
seconds_after_epoch = int(filename, 16)
utc_datetime = datetime.fromtimestamp(seconds_after_epoch)
dst_date = datetime(2019, 3, 10) # FOR UTC CONVERSION - 2019 ONLY
# UTC TO CST CONVERSION
if utc_datetime < dst_date:
@rhine3
rhine3 / xeno-canto.md
Last active November 5, 2023 11:09
Downloading files from Xeno-Canto

This script is no longer supported.

Over the years since I posted this script, it has become more and more common to scrape audio files off of Xeno-Canto.org. This has resulted in an overwhelming amount of traffic to their servers.

Please do not scrape Xeno-Canto without contacting the organizers first to ask for permission and for more information. They will be able to advise you on the best time of day to download data from their servers, or any alternative download options that are available.

name: opso
channels:
- conda-forge
dependencies:
- python==3.6
- pip==18.0
- pandas==0.23.4
- numpy==1.15.1
- matplotlib==2.1.2
- docopt==0.6.2
@rhine3
rhine3 / steps.md
Last active July 27, 2017 21:58
eco-evo_intro-to-bioinfo

Introduction to Bioinformatics - EcoEvo17

Goal: trim and map paired-end read files.

Trimming

Each sequenced nucleotide has a quality associated in a .fastq file. To be sure that we are working with high-quality data, trim off low-quality reads.

To trim, use a program called trim_galore. This program can take several different parameters, specified as "flags":

  • --paired - indicates that we are trimming paired-end reads
  • length 70 - indicates we want to keep only reads that are longer than 70bp
  • --quality 30 - indicates we want to keep only reads with a quality score greater than (or equal to?) 30