Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Code Generator
#11
Thanks! Using that I tried it out for cDNA, and I've gotten really close but I haven't been quite able to hit the desired effect with modifying the line. 

def transfer(p_amount, p_source, p_target):
 print("Transfering {:>5}ul from {} to {}".format(p_amount, p_source, p_target))
 
# number of mastermixes
N_mm = 2

# number of cDNA samples 
N_cDNA = 2
# number of tests to run on each sample
replicates = 2
 
mastermix_sources = list("A{}".format(j+1) for j in range(N_mm))
cDNA_sources = list("B{}".format(j+1) for j in range(N_cDNA))
 
for i, mm in enumerate(mastermix_sources):
  #list of targets for mastermix
  targets =
  for j in range(N_cDNA * replicates):
    wells = j + 1 + i * replicates * N_cDNA
    target = "{}".format(wells)
    targets.append(target)
   
  transfer(
           6, 
           mm,
           targets
         )
 
 
for i, cd in enumerate(cDNA_sources):
  #list of targets for cDNA
  targets =
   
  # loop over the number of mastermixes then loop over the number of tests
  for j in range(N_mm):
    for k in range(replicates):
      wells = i + 1 + j * replicates + k
      target = "{}".format(wells)
      targets.append(target)
   
  transfer(
             4, 
             cd,
             targets
           )
For the output I get close - but not quite

Transfering     6ul from A1 to ['1', '2', '3', '4']
Transfering     6ul from A2 to ['5', '6', '7', '8']
Transfering     4ul from B1 to ['1', '2', '3', '4']
Transfering     4ul from B2 to ['2', '3', '4', '5']
The numbers repeat except for one. I don't think the equation needs to be shifted (adding numbers) but I was wondering what I should consider multiplying if that makes sense?

Do you know where I went wrong?
Reply
#12
Off the top of my head I think it should be: wells = i*replicates + j*replicates*N_cDNA + k + 1.

I can't really test it right now though. I'll have some more time later, so I'll post an explanation then.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Is the following code returning a generator expression? quazirfan 8 1,533 Apr-11-2023, 11:44 PM
Last Post: quazirfan
  Python returns generator instead of None Tawnwen 4 4,639 Mar-09-2018, 07:06 AM
Last Post: DeaD_EyE
  receive from a generator, send to a generator Skaperen 9 5,423 Feb-05-2018, 06:26 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020