[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Tough problem in Python3

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 8
Thread images: 2

File: 70s_etrna_nolabels.jpg (504KB, 1366x1123px) Image search: [Google]
70s_etrna_nolabels.jpg
504KB, 1366x1123px
I posted here last night but no one responded. I've since made some progress. Here's the code:

        for rows in range(len(kmerl)):
for cols in range(len(kmerl[rows])):
mdarray = {(i,j):0 for j in range(cols+1) for i in range(rows+1)}
nucs = {'A':mdarray, 'G':mdarray, 'T':mdarray, 'C':mdarray}

'''
for i in range(len(kmerl)):
for j in range(len(kmerl[i])):
if kmerl[i][j] == 'A':
try:
print(kmerl)
nucs['A'][i][j] = 1
print(nucs['A'][i][j])
print('test')
except KeyError:
pass

elif kmerl[i][j] == 'C':
try:
nucs['C'][i][j] = 1
except KeyError:
pass

elif kmerl[i][j] == 'G':
try:
nucs['G'][i][j] = 1
except KeyError:
pass

elif kmerl[i][j] == 'T':
try:
nucs['T'][i][j] = 1
except KeyError:
pass'''

>>
>>57047968
Basically, I have a set of tuples (i,j) for rows and columns, with each row column pair being set = 0. This tuple is contained as a value in the dictionary with keys {AGCT]. I have a file that is going to generate most of this information, and I need to get the count of each A, G, C, T at a given row/column position.


If I have a 2 lines of sequence: AGCCCAGACTACT, AGGGCTAGATAA
And I split them into 3 substrings of size k = 1 such as: C, G.

For example. This is the actual output from my terminal when I generate this dictionary using the above parameters dictionary.
{'A': {(1, 0): 0, (0, 0): 0}, 'G': {(1, 0): 0, (0, 0): 0}, 'T': {(1, 0): 0, (0, 0): 0}, 'C': {(1, 0): 0, (0, 0): 0}}

So now I need to get the count of each occurrence of A,C,G,T, and store a count as a subvalue of the tuple value.
So in this example it would be:

{'A': {(1, 0): 0, (0, 0): 0}, 'G': {(1, 0): 1, (0, 0): 0}, 'T': {(1, 0): 0, (0, 0): 0}, 'C': {(1, 0): 0, (0, 0): 1}}

I have added a 1 to G:(1:0): and C:(0:0):. Furthermore, I need to be able to increase this value given a larger col/row size if new occurences of AGCT happen, meaning I could do +=1
>>
>>57047968
anon plz
>>
>>57047968
I'm lazy and in class so could you put your problem into a tl;dr? You'd probably get more responses.
>>
>>57048301
tl;dr how do I change the subvalue (where subvalue is the value of the 'value') of a dictionary without changing its key or value

dictionaryd = {keys:value:subvalue}
>>
>>57048445
I should note:

in dictionary d value = tuple(i,j)

so dictionaryd = {keys:(i,j):value}

how do I do something like this:

dictionaryd[keys][i][j] = 1
>>
File: double_helix.jpg (128KB, 1279x713px) Image search: [Google]
double_helix.jpg
128KB, 1279x713px
>>57047968
I don't have a clue about your problem, but I think you should revise your data model, it's a mess and make your problem impenetrable.

For example, why don't you value and subvalue a pair?

Pic totally related. Beware of the unforseen consequences of the double helix.
>>
>>57048573
>For example, why don't you value and subvalue a pair?

What do you mean? Like
dictd {keys:[value][pair]:[subvalue][pair]}
?

This would give me too many dimensions to the array. And that's not really the problem, it's being able to modify value of:

dictionaryd = {keys:(i,j):value}


Once the dictionary array is created, keys, and (i,j) will remain constant. They will only be used for indexing
Thread posts: 8
Thread images: 2


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.