Skip to content

Instantly share code, notes, and snippets.

View boopsboops's full-sized avatar

Rupert A. Collins boopsboops

View GitHub Profile
@boopsboops
boopsboops / feature_table.R
Created April 24, 2015 02:56
Feature table
feature_tab <- paste0(paste0(">Feature", " ", reduced_table$otherCatalogNumbers, "_", gene_name),"\n", #
"1", "\t", ">", nchar(reduced_table$nucleotides_CYTB), "\t", "gene", "\n", #
"\t", "\t", "\t", "gene", "\t", gene_name, "\n", #
"1", "\t", ">", nchar(reduced_table$nucleotides_CYTB), "\t", "CDS", "\t", "\t", "\n", #
"\t", "\t", "\t", "product", "\t", prod_name, "\n", #
"\t", "\t", "\t", "codon_start", "\t", "1")
write(feature_tab, file="features.tbl", append=FALSE)# write out
@boopsboops
boopsboops / prod_name.R
Created April 24, 2015 02:21
Product and gene names
gene_name <- "CYTB"
prod_name <- "cytochrome b"
@boopsboops
boopsboops / write_fasta.R
Last active August 29, 2015 14:19
Write fasta
fasta_description <- paste0(">", paste0(reduced_table$otherCatalogNumbers, "_", gene_name), " ", #
"[organism=", reduced_table$genus, " ", reduced_table$specificEpithet, "]", " ", #
"[Bio_material=", reduced_table$otherCatalogNumbers, "]", " ", "[Specimen-voucher=", #
reduced_table$institutionCode, ":", reduced_table$catalogNumber, "]", " ", "[location=mitochondrion] [mgcode=2]")
fasta_complete <- paste(fasta_description, reduced_table$nucleotides_CYTB, sep="\n")# add data to fasta
write(fasta_complete, file="sequences.fsa", append=FALSE)# write out the fasta file
@boopsboops
boopsboops / read_reduce.R
Created April 24, 2015 02:12
Read and reduce
tab <- read.table("master.tsv", header=TRUE, sep="\t", stringsAsFactors=FALSE)
reduced_table <- tab[-which(is.na(tab$nucleotides_CYTB)), ]
@boopsboops
boopsboops / master_fake.tsv
Last active August 29, 2015 14:19
Example of master TSV, but with added tabs (for vis)
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 8 columns, instead of 14. in line 1.
otherCatalogNumbers genus specificEpithet institutionCode catalogNumber country nucleotides_CYTB nucleotides_16S
BB-001 Boops boops MNHN 1978-0632 Spain NA TATGGAGCTTAA
BB-002 Boops boops MNHN 1978-0632 Spain ATGGCTAGCCT NA
BB-003 Boops boops MNHN 1978-0632 Spain ATGGCTAGCCT TATGGAGCTTAA