Even after string formating, i.e f"(-1 {i} -2 {j})" it is showing problem of "bowtie2-align exited with value 2\n')"
Hello, Everytime I run my script it shows "bad file descriptor" in terminal. Following is my script. Please help
import os
import subprocess
import shlex
fastq1 = []
fastq2 = []
path = os.listdir('kud')
for files in path:
if '_1' in files:
fastq1.append(files)
if '_2' in files:
fastq2.append(files)
for i,j in zip(fastq1,fastq2):
command = "bowtie2 -x bt2_base -1 i -2 j -S z.sam"
cmd = shlex.split(command)
subprocess.run(cmd,shell=False,stdout=subprocess.PIPE,stderr=subprocess.PIPE,universal_newlines=True)
2 answers
Just a guess - the file names you are passing don't have the directory name ('kud') but I don't know.
Anyhow, I would highly suggest to avoid running such scripts and using proper workflow managing software such as nextflow, snakemake or other. 99% chance that what you are trying to run was already implemented in nf-core and you just need to run the pipeline.
This is still related to your old thread. bowtie2, and python script. Why start a new one?
You're trying to use variables inside a string.
x = 5
s = "x"
print(s)
This will just print string x and not the int 5. In your example you're setting command string with literal characters i and j and not with their values. Instead, you just do some string formatting.
# here are some examples.
x = 5
y = 6
s = f"x is {x} y is {y}"
You can read more about string formatting in python docs.
Why do you have parenthesis? Shouldn't look like this?
f"-1 {i} -2 {j}"
Log in to answer this question.