#!/usr/bin/env cwl-runner
# Generated from: makeblastdb -in ./data/uniprotkb_rice_all_240820.fasta -out ./data/index_uniprot_rice/uniprotkb_rice_all_240820 -dbtype prot -hash_index -parse_seqids
class: CommandLineTool
cwlVersion: v1.2
label: "blastn command for rRNA database creation"
doc: |
  "This tool is used to execute blastn process.
  original script: scripts/07_annotation_modified.sh
  original command: blastn -num_threads ${threads} -db ${db}/${rrna} -query ${f}.fna -out ${f}_${rrna}.txt -outfmt "6 qseqid sseqid stitle evalue" -max_target_seqs 1 -evalue 0.1"

requirements:
  WorkReuse:
    enableReuse: true

baseCommand: [blastn]

arguments:
  - -num_threads
  - $(inputs.threads)
  - -db
  - $(inputs.index_dir.path)
  - -query
  - $(inputs.input_fasta_file.path)
  - -out
  - $(inputs.output_file_name)
  # You may not edit "outfmt" following terms, or 12_faablast2gtf4tpm.cwl do not work correctly.
  - -outfmt
  - "6 qseqid sseqid stitle evalue"
  - -max_target_seqs
  - $(inputs.max_target_seqs)
  - -evalue
  - $(inputs.evalue)

inputs:
  - id: threads
    type: int
    label: "threads"
    doc: "Number of threads to use"
    default: 16

  - id: index_dir
    type: File
    label: "index directory name"
    doc: "directory containing index files for BLASTN"
    default:
      class: File
      location: ../out/SILVA_138.1_LSUParc_tax_silva/SILVA_138.1_LSUParc_tax_silva.fasta.gz
    secondaryFiles:
      - .ndb
      - .nhr
      - .nin
      - .njs
      - .nog
      - .nos
      - .not
      - .nsq
      - .ntf
      - .nto

  - id: input_fasta_file
    type: File
    label: "input fasta file (nucleotide sequence generated by prodigal process)"
    doc: "predicted protein coding sequences produced by Prodigal process"
    default:
      class: File
      location: ../out/all_contigs_SRR27548858_dna.fasta

  - id: output_file_name
    type: string
    label: "output file name"
    doc: "text file of annotaion information of contaminating rRNA"
    default: "blastn_rRNA_alignment.txt"

  - id: max_target_seqs
    type: int
    label: "max target seqs"
    doc: "number of annotaion output for each DNA sequences, sometimes annotaiton output will be more than 1 even though the setting is 1"
    default: 1
  
  - id: evalue
    type: float
    label: "evalue"
    doc: "E-value threshod of BLASTN search"
    default: 0.1

outputs:
  # - id: all-for-debugging
  #   type:
  #     type: array
  #     items: [File, Directory]
  #   outputBinding:
  #     glob: "*"

  - id: output_file
    type: File
    label: "output file"
    doc: "text file of annotaion information of contaminating rRNA"
    outputBinding:
      glob: "$(inputs.output_file_name)"


hints:
  - class: DockerRequirement
    dockerPull: quay.io/biocontainers/blast:2.17.0--h66d330f_0

$namespaces:
  s: https://schema.org/
  edam: http://edamontology.org/
