Skip to content

Instantly share code, notes, and snippets.

@bluegenes
bluegenes / get-contigs-trinDE-dammitAnnot.py
Last active July 24, 2018 00:03
Take in a list of trinity gene names (e.g. from gene-level DE using salmon), a dammit namemap, and a dammit fasta file. Output fasta of matching dammit contigs.
###################################################################
"""Function: Take in a list of trinity gene names, a dammit namemap,
and a dammit fasta file. Output fasta of matching dammit contigs.
"""
###################################################################
import sys
import os
import argparse
import screed
@bluegenes
bluegenes / generate_trinity_geneTransMap.py
Last active July 19, 2018 17:47
Generates a gene: trans or trans: gene map from a Trinity fasta file
import os
import argparse
import screed
def generate_geneTransMap(fasta, geneTransMap, transGeneMap):
if transGeneMap:
outT = open(transGeneMap, "w")
with open(geneTransMap, "w") as outG:
with screed.open(fasta) as seqs:
for read in seqs:
###################################################################
"""Function: Take in a dammit gff3, dammit fasta, dammit namemap.
Output gff3 and fasta with trinity names.
by Dr. Tessa Pierce
"""
###################################################################
import sys
import os
import argparse
@bluegenes
bluegenes / fix_fq_headers.sh
Created October 30, 2018 21:07
fix ENA fastq headers for trinity
for f in *fq.gz; do
echo 'starting on file' $f
cp "$f" "$f~" &&
gzip -cd "$f~" | sed 's/^@ERR\S*\s/@/' | gzip > "$f"
rm "$f~"
done
import os
from snakemake.remote import FTP
FTP = FTP.RemoteProvider()
data_dir='data_subset'
targets = []
with open('SRA_accessions.txt', 'r') as f:
for line in f:
#Author: Tessa Pierce
import argparse
import screed
import re
def extract_contigs(in_fasta, pattern, outF):
if not outF:
outF = in_fasta.split('.fa')[0] + '_' + pattern + '.fa'
with screed.open(in_fasta) as seqF:
@bluegenes
bluegenes / copy_samplefiles.py
Last active July 1, 2019 02:47
given a list of sample names and a source location, copy relevant files somewhere else
import os
import sys
import argparse
import glob
from shutil import copyfile
# requires python >= 3.6
# run: python copy_samplefiles.py haptophyta.txt --source ../../pep/ --destination ../../haptophyta_pep
@bluegenes
bluegenes / split-fastq.py
Created September 30, 2021 21:37
split a fastq file into one entry per file
#! /usr/bin/env python
import os
import sys
import argparse
import screed
def make_outdir(output_dirname):
if not os.path.exists(output_dirname):
try:
os.makedirs(output_dirname)