Skip to content

Commit

Permalink
sqlite FTP import success
Browse files Browse the repository at this point in the history
  • Loading branch information
ktmeaton committed Feb 7, 2020
1 parent 911c585 commit 38f2a0c
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions pipeline.nf
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
*/

def helpMessage() {
log.info pipelineHeader()
log.info"""
=========================================
${workflow.manifest.name} v${workflow.manifest.version}
=========================================
Usage:
The typical command for executing the pipeline is:
Expand All @@ -36,6 +34,8 @@ def helpMessage() {
// Extra configuration variables
// SQLite commands script
params.sqlite_commands = "$baseDir/sqlite_import.sh"
params.genbank_asm_suffix = "_genomic.fna.gz"
params.assembly_for_download_file = "assembly_for_download.txt"

// Show help message
params.help = false
Expand All @@ -61,18 +61,37 @@ if (params.sqlite){
.ifEmpty { exit 1, "SQLite commands script not found: ${params.sqlite_commands}" }

process sqlite_import{
// Import assembly ftp url from database, retrieve file names and URL for web get
echo true
log.info pipelineHeader()
log.info"""SQLite database selected: ${params.sqlite}"""

input:
file sqlite from sqlite_ch
file sqlitecmd from sqlite_cmd_ch

output:
file params.assembly_for_download_file into assembly_for_download

script:
"""
echo ${sqlite};
echo ${sqlitecmd};
#sqlite3 ${sqlite} ".read ${baseDir}/sqlite_import.sh";
sqlite3 ${sqlite} 'select AssemblyFTPGenbank from Assembly' | sed 's/ /\\n/g' | while read line;
do
if [[ ! -z \$line ]]; then
asm_url=\$line;
asm_fasta=`echo \$line | cut -d "/" -f 10 | awk -v suffix=${params.genbank_asm_suffix} '{print \$0 suffix}'`;
asm_ftp=\${asm_url}/\${asm_fasta};
echo \$asm_ftp >> ${params.assembly_for_download_file}
fi;
done;
"""
}
}

def pipelineHeader() {
return"""
=========================================
${workflow.manifest.name} v${workflow.manifest.version}
=========================================
""".stripIndent()

}

0 comments on commit 38f2a0c

Please sign in to comment.