forgi.utilities.stuff module¶
-
forgi.utilities.stuff.
bpseq_to_tuples_and_seq
(bpseq_str)[source]¶ Convert a bpseq string to a list of pair tuples and a sequence dictionary. The return value is a tuple of the list of pair tuples and a sequence string.
Parameters: bpseq_str – The bpseq string Returns: ([(1,5),(2,4),(3,0),(4,2),(5,1)], ‘ACCAA’)
-
forgi.utilities.stuff.
dotbracket_to_pairtable
(struct)[source]¶ Converts arbitrary structure in dot bracket format to pair table (ViennaRNA format).
-
forgi.utilities.stuff.
get_version_string
()[source]¶ If installed from github, print the version obtained by
git describe
On my local machine, when run within a git directory, get the commit hash directly usinggit describe
-
forgi.utilities.stuff.
grouped
(iterable, n)[source]¶ Return a list of every n elements in iterable.
http://stackoverflow.com/questions/5389507/iterating-over-every-two-elements-in-a-list
s -> (s0,s1,s2,…sn-1), (sn,sn+1,sn+2,…s2n-1), (s2n,s2n+1,s2n+2,…s3n-1), …
-
forgi.utilities.stuff.
make_temp_directory
(*args, **kwds)[source]¶ Yanked from:
http://stackoverflow.com/questions/13379742/right-way-to-clean-up-a-temporary-folder-in-python-class
-
forgi.utilities.stuff.
merge_intervals
(intervals, diff=0)[source]¶ Take a set of intervals, and combine them whenever the endpoints match.
I.e. [(42,47), (55,60), (60,63), (1,9), (63,71)]
Should yield
[(1,9),(42,47), (55,71)]
There should be no overlapping intervals.
@param intervals: A set of tuples indicating intervals @return: A list of merged intervals
-
forgi.utilities.stuff.
pairtable_to_dotbracket
(pt)[source]¶ Converts arbitrary pair table array (ViennaRNA format) to structure in dot bracket format.
-
forgi.utilities.stuff.
pairtable_to_elements
(pt, level, i, j)[source]¶ Convert a pair table to a list of secondary structure elements:
[[‘s’,1,[2,3]]
The ‘s’ indicates that an element can be a stem. It can also be an interior loop (‘i’), a hairpin loop (‘h’) or a multiloop (‘m’)
The second number (1 in this case) indicates the depth or how many base pairs have to be broken to get to this element.
Finally, there is the list of nucleotides which are part of of this element.
-
forgi.utilities.stuff.
pairtable_to_tuples
(pt)[source]¶ Convert a pairtable to a list of base pair tuples.
i.e. [4,3,4,1,2] -> [(1,3),(2,4),(3,1),(4,2)]
Parameters: pt – A pairtable Returns: A list paired tuples
-
forgi.utilities.stuff.
renumber_bpseq
(bpseq_triples)[source]¶ Parameters: bpseq_triples – A list of triples (from, res, to)
-
forgi.utilities.stuff.
tuples_to_pairtable
(pair_tuples, seq_length=None)[source]¶ Convert a representation of an RNA consisting of a list of tuples to a pair table:
i.e. [(1,3),(2,4),(3,1),(4,2)] -> [4,3,4,1,2]
Parameters: - tuples – A list of pair tuples
- seq_length – How long is the sequence? Only needs to be passed in when the unpaired nucleotides aren’t passed in as (x,0) tuples.
Returns: A pair table