<jupyter_start><jupyter_text>Table of Contents1&nbsp;&nbsp;Goal2&nbsp;&nbsp;Var3&nbsp;&nbsp;Init4&nbsp;&nbsp;Test samples4.1&nbsp;&nbsp;n50_Pseudomonas4.2&nbsp;&nbsp;n104.3&nbsp;&nbsp;n55&nbsp;&nbsp;Gene list  Goal* test dataset construction & evaluation for Struo2  Var<jupyter_code>samps_dir = '/ebio/abt3_projects/software/dev/struo2/tests/samples/'
work_dir = '/ebio/abt3_projects/software/dev/struo2/tests/data/'

meta_file = '/ebio/abt3_projects/databases_no-backup/GTDB/release95/Struo/'
meta_file = file.path(meta_file, 'metadata_1per-GTDB-Spec_gte50comp-lt5cont_wtaxID_wPath.tsv')<jupyter_output><empty_output><jupyter_text>Init<jupyter_code>library(dplyr)
library(tidyr)
library(ggplot2)
library(LeyLabRMisc)
library(uuid)
df.dims()<jupyter_output><empty_output><jupyter_text>Test samples<jupyter_code># reading in GTDB metadata file used for Struo
meta = read.delim(meta_file, sep='\t')
meta<jupyter_output><empty_output><jupyter_text>n50_Pseudomonas<jupyter_code># selecting subset
meta_n50 = meta %>%
    filter(grepl('Pseudomonas', gtdb_taxonomy)) %>%
    sample_n(50) 
meta_n50
outF = file.path(samps_dir, 'GTDBr95_n50_Pseudomonas.tsv')
write_table(meta_n50, outF)<jupyter_output>File written: /ebio/abt3_projects/software/dev/struo2/tests/samples//GTDBr95_n50_Pseudomonas.tsv<jupyter_text>n10<jupyter_code># selecting subset
meta_n10 = meta %>%
    sample_n(10) 
meta_n10
outF = file.path(samps_dir, 'GTDBr95_n10.tsv')
write_table(meta_n10, outF)<jupyter_output>File written: /ebio/abt3_projects/software/dev/struo2/tests/samples//GTDBr95_n10.tsv<jupyter_text>n5<jupyter_code># selecting subset
meta_n5 = meta %>%
    anti_join(meta_n10, c('accession')) %>%
    sample_n(5) 
meta_n5
outF = file.path(samps_dir, 'GTDBr95_n5.tsv')
write_table(meta_n5, outF)<jupyter_output>File written: /ebio/abt3_projects/software/dev/struo2/tests/samples//GTDBr95_n5.tsv<jupyter_text>Gene list* A list of genes to add to an existing gene database* Columns required in gene metadata table:```'seq_uuid','seq_orig_name','domain','phylum','class','order','family','genus','species','taxid','genome_name','genome_length_bp'```<jupyter_code>F = file.path(work_dir, 'clusters_rep-seqs_tmp.txt')
meta = read.delim(F, sep='\t', header=FALSE) 
meta
meta_f = meta %>%
    rename('seq_orig_name' = V1) %>%
    mutate(seq_uuid = gsub('-', '', UUIDgenerate())) %>%
    mutate(domain = '',
           phylum = '',
           class = '',
           order = '',
           family = '',
           genus = gsub('(.+)\\.s__.+', '\\1', V3),
           species = gsub('.+\\.(s__.+)', '\\1', V3),
           taxid = gsub('.+__taxID(.+)', '\\1', V3),
           genome_name = '',
           genome_length_bp = '') %>%
    mutate(species = gsub('__taxID.+', '', species),
           taxid = ifelse(grepl('^[0-9]+$', taxid), taxid, '')) %>%
    dplyr::select(seq_uuid, seq_orig_name, domain, phylum, class, 
                  order, family, genus, species, taxid, genome_name, 
                  genome_length_bp)
meta_f                      
# writing
outF = file.path(work_dir, 'clusters_rep-seqs.txt')
write_table(meta_f, outF)<jupyter_output>File written: /ebio/abt3_projects/software/dev/struo2/tests/data//clusters_rep-seqs.txt
StarcoderdataJupyterStructuredCleanDedup