# HG changeset patch # User ecology # Date 1682417129 0 # Node ID 0ccbe1c20fc31804a679bcca149b2f3f9049991a planemo upload for repository https://github.com/ColineRoyaux/Galaxy_tool_projects/tree/main/consensus_from_alignments commit ecc21de8f368c6a95c57d4e6511ed42af9e72a66 diff -r 000000000000 -r 0ccbe1c20fc3 consalign.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/consalign.xml Tue Apr 25 10:05:29 2023 +0000 @@ -0,0 +1,67 @@ + + + + consalign_macros.xml + + + r-bioseq + r-ptxqc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 10.1111/2041-210X.13490 + + diff -r 000000000000 -r 0ccbe1c20fc3 consalign_macros.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/consalign_macros.xml Tue Apr 25 10:05:29 2023 +0000 @@ -0,0 +1,3 @@ + + 1.0.0 + diff -r 000000000000 -r 0ccbe1c20fc3 consensus_from_alignments.R --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/consensus_from_alignments.R Tue Apr 25 10:05:29 2023 +0000 @@ -0,0 +1,43 @@ +#Rscript + +################################################################################ +## Extract consensus sequence from aligned forward and reverse fasta ## +################################################################################ + +#####Packages +library(bioseq, quietly = TRUE) + +##Load arguments +args <- commandArgs(trailingOnly = TRUE) + +if (length(args) == 0) { + stop("This tool needs at least one argument") +} else { + fasta_f <- args[1] + seq_type <- args[2] + meth_choice <- args[3] + gaps_tf <- as.logical(args[4]) + out_og <- as.logical(args[5]) +} + +## Read input file +seq_l <- bioseq::read_fasta(fasta_f, type = seq_type) + +if(bioseq::seq_nseq(seq_l) < 2){ + stop("Only one sequence in the file, at least two aligned sequences are needed to compute a consensus") +}else{ + if(length(unique(bioseq::seq_nchar(seq_l))) > 1) {stop("Sequences have different lengths, please provide aligned sequences")} +} + +##Consensus sequence +seq_con <- bioseq::seq_consensus(seq_l, method = meth_choice, gaps = gaps_tf) + +if(bioseq::seq_nseq(seq_con) > 1){stop("Consensus hasn't worked for an unknown reason, double-check your input file and the parameters you chose")} + +names(seq_con) <- paste0("consensus_", Reduce(PTXQC::LCS, names(seq_l))) +##Create output +if(out_og){ + bioseq::write_fasta(c(seq_con, seq_l), file = "output.fasta", line_length = Inf, block_length = Inf) +}else{ + bioseq::write_fasta(seq_con, file = "output.fasta", line_length = Inf, block_length = Inf) +} diff -r 000000000000 -r 0ccbe1c20fc3 test-data/out_file.fasta --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/out_file.fasta Tue Apr 25 10:05:29 2023 +0000 @@ -0,0 +1,2 @@ +>consensus_L +TTTGTGTACCCCCASDGGAT diff -r 000000000000 -r 0ccbe1c20fc3 test-data/test_file.fasta --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/test_file.fasta Tue Apr 25 10:05:29 2023 +0000 @@ -0,0 +1,6 @@ +>LAL +TTTGTGTACC-CCACAGG-- +>L0L +--TGTGT-CCCCCAGTGGAT +>LEL +-TTGTGT-CCCCCAGGGGA-