-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenerate_dummy_aln.R
39 lines (33 loc) · 1.19 KB
/
Generate_dummy_aln.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#-------------------#
# CLEAN ENVIRONMENT #
#-------------------#
rm( list = ls( ) )
#-----------------------#
# SET WORKING DIRECTORY #
#-----------------------#
library( rstudioapi )
# Get the path to current open R script and find main dir "00_Gene_filtering"
path_to_file <- getActiveDocumentContext()$path
script_wd <- paste( dirname( path_to_file ), "/", sep = "" )
wd <- gsub( pattern = "/scripts", replacement = "", x = script_wd )
setwd( wd )
#--------------#
# LOAD OBJECTS #
#--------------#
tt <- ape::read.tree( file = "../../00_data_formatting/01_inp_data/LUCAdup_246sp_uncalib.tree" )
#-------#
# TASKS #
#-------#
# 1. Find number of taxa
num_sp <- length( tt$tip.label )
spnames <- tt$tip.label
phylip_header <- paste( num_sp, " 1", sep = "" )
phylip_header_aln <- paste( num_sp, " 2\n", sep = "" )
spnames_2chars <- paste( spnames, " PR", sep = "" )
# 2. Generate dummy aln
if( ! dir.exists( "dummy_aln/" ) ){
dir.create( "dummy_aln/" )
}
write( x = phylip_header_aln, file = paste( "dummy_aln/dummy_aln.aln", sep = "" ) )
write( x = spnames_2chars, file = paste( "dummy_aln/dummy_aln.aln", sep = "" ),
append = TRUE )