This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to create multidimensional dictionary in python?

Hi All,

The input data is as below:

chr1    a   3   6
chr1    b   4   5
chr1    a   2   5
chr1    c   4   5
chr2    d   5   6
chr2    d   2   3
chr2    c   4   7
chr3    e   6   7

How can I get dicts like the following?

dict1:

 {'chr1': {'a': '3-6,2-5', 'b': '4-5', 'c': '4-5'}, 'chr2': {'d': '5-6,2-3', 'c': '4-7'}, 'chr3': {'e': '6-7'}}

dict2:

{'chr1': {'a': ['3-6','2-5'], 'b': ['4-5'], 'c': ['4-5']}, 'chr2': {'d': ['5-6','2-3'], 'c': ['4-7']}, 'chr3': {'e': ['6-7']}}

Thanks

python dataframe gtf

Not a bioinformatics question. This is about python programming, have you looked on StackOverflow, like for example this post ?

Can you explain the rationale of your data structure and how such can help your downstream analyses? Else, I'm interpreting this as a homework question.

Hello Santiansiye!

We believe that this post does not fit the main topic of this site.

Not a bioinformatics question!

For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.

If you disagree please tell us why in a reply below, we'll be happy to talk about it.

Cheers!

0 answers

No answers yet.

Log in to answer this question.