Subprocess Skript
Verfasst: Montag 28. September 2015, 09:22
Hallo Leute,
ich habe folgendes Problem:
Ich möchte erreichen, das Folgendes in der Konsole eingelesen bzw. ausgegeben wird.
./bwa index -a 'is' /path/to/folder/datei.fa
Bisher schaffe ich es noch nicht die Datei direkt an den Pfad zu hängen. Habt ihr eine Idee wie man das mit Python schafft ?
Das hier ist meine Fehlermeldung:
./bwa index -a 'is': /mnt/vault/tmp/until_2016_01_01/florian/OpenSourceTools/BWA/bwa-0.7.12: is a directory
Hier ist mein Code:
ich habe folgendes Problem:
Ich möchte erreichen, das Folgendes in der Konsole eingelesen bzw. ausgegeben wird.
./bwa index -a 'is' /path/to/folder/datei.fa
Bisher schaffe ich es noch nicht die Datei direkt an den Pfad zu hängen. Habt ihr eine Idee wie man das mit Python schafft ?
Das hier ist meine Fehlermeldung:
./bwa index -a 'is': /mnt/vault/tmp/until_2016_01_01/florian/OpenSourceTools/BWA/bwa-0.7.12: is a directory
Hier ist mein Code:
Code: Alles auswählen
#!/usr/bin/python
import os, sys
import subprocess
def open_source_tools():
# copy the trimmed sequences filenames into a list
counter = 0
trim_seq = []
for x in os.listdir("/mnt/vault/tmp/until_2016_01_01/florian/trimmed_seq_salmonella_normal_20percentage"):
trim_seq.append(x)
# paths to the folders
open_bwa_index = "/mnt/vault/tmp/until_2016_01_01/florian/OpenSourceTools/BWA/bwa-0.7.12"
open_bwa_mem = "/mnt/vault/tmp/until_2016_01_01/florian/OpenSourceTools/BWA/bwa-0.7.12"
open_trimmed_reads = "/mnt/vault/tmp/until_2016_01_01/florian/trimmed_seq_salmonella_normal_20percentage"
open_reference_genome = "/mnt/vault/tmp/until_2016_01_01/florian/OpenSourceTools/BWA/bwa-0.7.12/reference_genomes"
best_match_liste = ['NC_016856_genome.fa','NC_022569_genome.fa','NC_022569_genome.fa','NC_016856_genome.fa','NC_022569_genome.fa''NC_016860_genome.fa',
'NC_016860_genome.fa','NC_016860_genome.fa','NC_016860_genome.fa','NC_016856_genome.fa','NC_016860_genome.fa','NC_016860_genome.fa',
'NC_022569_genome.fa','NC_016860_genome.fa','NC_022569_genome.fa','NC_022569_genome.fa','NC_017046_genome.fa','NC_022569_genome.fa',
'NC_016856_genome.fa','NC_016856_genome.fa','NC_016856_genome.fa','NC_016856_genome.fa','NC_022569_genome.fa','NC_017046_genome.fa',
'NC_016856_genome.fa','NC_022569_genome.fa','NC_016856_genome.fa','NC_016856_genome.fa','NC_016856_genome.fa','NC_016856_genome.fa',
'NC_016856_genome.fa','NC_021814_genome.fa','NC_021814_genome.fa','NC_016860_genome.fa','NC_011294_genome.fa','NC_011294_genome.fa',
'NC_011294_genome.fa','NC_011294_genome.fa','NC_011294_genome.fa','NC_011294_genome.fa','NC_011294_genome.fa','NC_011294_genome.fa',
'NC_016856_genome.fa','NC_011294_genome.fa','NC_016856_genome.fa','NC_022991_genome.fa','NC_021814_genome.fa']
# run bwa index to construct FM index
for ref in best_match_liste:
bwa_index_command = subprocess.call([open_bwa_index, "./bwa index -a 'is'",open_reference_genome,ref],shell=True)
# run bwa mem to map the reads to the reference
for trim in open_trimmed_reads:
bwa_mem_command = subprocess.call([open_bwa_index, "./bwa mem -t 1 -P", open_reference_genome,ref, open_trimmed_reads, trim],shell=True)
#open Bacterial Analysis Pipeline
#print(trim_seq)
subprocess.call(["firefox", "-new-tab","https://cge.cbs.dtu.dk/services/CGEpipeline-1.1/"])
open_source_tools()