On Tue, Jan 27, 2015 at 2:47 PM, jarod...@libero.it <jarod...@libero.it> wrote:
> I create a  list of local  object: but I can't execute as object only as 
> string:
> ena = Rnaseq(options.configura, options.rst)
>         job_1 = ena.trimmomatic()
>         job_2 = ena.star()
>         job_3 = ena.wiggle()
>         job_4 = ena.rnaseqc()
>         job_5 = ena.picard_sort_sam()
>         job_6 = ena.cufflinks
>         job_7 = ena.merge_trimmomatic_stats()
>         #ena.write_out(job2)
>         cmdset=[]
>         for item in locals().keys():
>             if item.startswith('job_'):
>                 cmdset.append(item)
>         cmdset.sort()
>         for i in range(0,len(cmdset)):
>              ena.prepare_run(cmdset[i])


Technically: the code is collecting a list of strings in cmdset.  I
don't think this is what you want.

Stylistically: this code is trying to be too clever.  You're typing
out the jobs in sequence, so you might as well arrange them as a list.
The use of locals() is dubious, and your use of sort() is trying to
undo the damage that is being introduced by locals().

Why not just do the direct thing?  The pseudocode would be something like:

####################################################
cmdset = [ena.trimmomatic, end.star, ena.wiggle, ena.maseqc, ...]
for cmd in cmdset:
    print cmd.__name__
    cmd()
####################################################

where you keep a list of commands, and you can execute them in turn.
Because the representation of the command set is a list, it's ordered
the way it's typed.
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to