[Tutor] R: Tutor Digest, Vol 131, Issue 60 order loop from methos on class

Danny Yoo dyoo at hashcollision.org
Mon Jan 26 21:56:26 CET 2015


> The order of the self.step are the order I wan to to execute my analisys.
> So this is the order:
> In [160]: ena.show()
> 1- trimmomatic
> 2- merge_trimmomatic_stats
> 3- star
> 4- picard_sort_sam
> 5- rnaseqc
> 6- wiggle
> 7- cufflinks
> 8- cuffquant
> 9- gq_seq_utils_exploratory_analysis_rnaseq
> First aim is to write a code to write all the pipeline .
> up to now I use this:
> job1 = ena.trimming()
> ena.prepare_run(job1)
> ena.prepare_run(job2)
> ..
> the other aim is to selcet a range number to execute i.e. 2-9 or 1-4...

In this case, yes, you probably want to explicitly represent the
sequence of steps as an explicit list of operators.

I think you may have wanted somehow to get this ordered sequence "for
free" by iterating over the class's methods, perhaps through a dir().
However, trying to get this ordering from the class via method
iteration is unreliable because, underneath the service, the iteration
is walking through a dictionary, and dictionaries do not give us a
deterministic ordering: the ordering is allowed to change on us
between program runs.

And in fact, in certain environments, dictionary iteration is
_guaranteed_ to give us a different ordering on every program run.
See: https://docs.python.org/2/using/cmdline.html#envvar-PYTHONHASHSEED

Ultimately, this means that if we want an ordered sequence, we can't
depend on dictionary iteration.  Lists are what we want.

More information about the Tutor mailing list