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


Messages In This Thread
Python Code Generator - by KatherineHov - Jul-24-2017, 05:58 PM
RE: Python Code Generator - by MTVDNA - Jul-24-2017, 10:00 PM
RE: Python Code Generator - by KatherineHov - Jul-25-2017, 04:13 PM
RE: Python Code Generator - by MTVDNA - Jul-25-2017, 04:52 PM
RE: Python Code Generator - by KatherineHov - Jul-25-2017, 05:40 PM
RE: Python Code Generator - by MTVDNA - Jul-25-2017, 06:03 PM
RE: Python Code Generator - by KatherineHov - Jul-25-2017, 09:16 PM
RE: Python Code Generator - by MTVDNA - Jul-25-2017, 09:54 PM
RE: Python Code Generator - by KatherineHov - Jul-26-2017, 05:15 PM
RE: Python Code Generator - by MTVDNA - Jul-26-2017, 09:56 PM
RE: Python Code Generator - by KatherineHov - Jul-27-2017, 01:22 AM
RE: Python Code Generator - by MTVDNA - Jul-27-2017, 10:04 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Is the following code returning a generator expression? quazirfan 8 1,900 Apr-11-2023, 11:44 PM
Last Post: quazirfan
  Python returns generator instead of None Tawnwen 4 4,934 Mar-09-2018, 07:06 AM
Last Post: DeaD_EyE
  receive from a generator, send to a generator Skaperen 9 5,793 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