hi there is an interesting problem , as i have almost 500 file in directory ~/work/whole_proteome/analysis_xenopus_takifugu_tetradon/split_result/filtered_domain/big_cluster_fasta_format/, now i want to run a perl script which is present in  ~/work/whole_proteome/analysis_xenopus_takifugu_tetradon/split_result/filtered_domain/ORTHOMCLV1.4/ the problem is using os.system(command as it does not take the command properly)
from sys import *
import os
import sys
import subprocess
file_list = os.listdir(os.getcwd())
print os.getcwd()
#path = '~/work/whole_proteome/analysis_xenopus_takifugu_tetradon/split_result/filtered_domain/big_cluster_fasta_format'
#file_list = os.listdir(path)
for f in file_list:
        fr = open(f,'r')
        #filenumber += 1
        fr_lines = fr.read().split('>')[1:]
        for item  in fr_lines:
                protein = item.split('\n',1)[0]
                type(protein)
                #print protein
                pro_sequence = item.split('\n',1)[1]
                if protein.startswith('ENSXET'):
                        xenopus_seq = '>'+item + '\n'
                        print xenopus_seq
                        outfile = open("/ddfs/user/data/k/ktrip_01/work/whole_proteome/analysis_xenopus_takifugu_tetradon/split_result/filtered_domain/ORTHOMCLV1.4/sample_data/xenopus.fa", 'a')
                        outfile.write(xenopus_seq)
                elif protein.startswith('ENSTRU'):
                        fugu_seq = '>'+ item +'\n'
                        print fugu_seq
                        outfile = open("/ddfs/user/data/k/ktrip_01/work/whole_proteome/analysis_xenopus_takifugu_tetradon/split_result/filtered_domain/ORTHOMCLV1.4/sample_data/fugu.fa", 'a')
                        outfile.write(fugu_seq)
                elif protein.startswith('ENSTNI'):
                        tetradon_seq = '>'+ item + '\n'
                        print tetradon_seq
                        outfile = open("/ddfs/user/data/k/ktrip_01/work/whole_proteome/analysis_xenopus_takifugu_tetradon/split_result/filtered_domain/ORTHOMCLV1.4/sample_data/tetradon.fa", 'a')
                        outfile.write(tetradon_seq)
        print '********************************************************************************************************'
        # os.system()
        os.system("perl ~/work/whole_proteome/analysis_xenopus_takifugu_tetradon/split_result/filtered_domain/ORTHOMCLV1.4/  orthomcl.pl --mode1 --fa_files ~/work/whole_proteome/analysis_xenopus_takifugu_tetradon/split_result/filtered_domain/ORTHOMCLV1.4/sample_data xenopus.fa,fugu.fa,tetradon.fa "
os.system("cd ~/~/work/whole_proteome/analysis_xenopus_takifugu_tetradon/split_result/filtered_domain/ORTHOMCLV1.4/sample_data")
        os.system(" rm *.fa")

the whole program works fine but the last step of program does not work accordingly

os.system("perl ~/work/whole_proteome/analysis_xenopus_takifugu_tetradon/split_result/filtered_domain/ORTHOMCLV1.4/  orthomcl.pl --mode1 --fa_files ~/work/whole_proteome/analysis_xenopus_takifugu_tetradon/split_result/filtered_domain/ORTHOMCLV1.4/sample_data xenopus.fa,fugu.fa,tetradon.fa "
os.system("cd ~/~/work/whole_proteome/analysis_xenopus_takifugu_tetradon/split_result/filtered_domain/ORTHOMCLV1.4/sample_data")
        os.system(" rm *.fa"

What is this second '~'? "cd ~/~/work/... If that isn't the problem, then perhaps you can tell us how the last step doesn't work.

yea check line 36 of your code. what are trying to achieve?

Btw on *nix platforms cd~ will take you to the user dir. Why do you need double cd~/~????.
try that with only one cd~ ok?
cheers

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.