Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Code Generator
#9
Thank you for the dictionary. It was able to translate wells (A1) to their number (1) but I had trouble adding it into my code to convert the A1 coordinates to numbers. So, I tried out another thing. 

I thought that maybe I could combine the rows/columns and create just one 'wells' as the target like this:

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 = 3

# 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 
    target = "{}".format(wells)
    targets.append(target)
   
  transfer(
           6, 
           mm,
           targets
         )
 
I did some fiddling around and it spits out the right numbers in ascending order (for the first half - haven't touched the cDNA portion yet) but it repeats numbers. Is there a way to restrict repeating numbers. I tried some if commands but I kept getting syntax errors. 

Here's the output-

Transfering     6ul from A1 to ['1', '2', '3', '4']
Transfering     6ul from A2 to ['3', '4', '5', '6']
Transfering     6ul from A3 to ['5', '6', '7', '8']
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,867 Apr-11-2023, 11:44 PM
Last Post: quazirfan
  Python returns generator instead of None Tawnwen 4 4,898 Mar-09-2018, 07:06 AM
Last Post: DeaD_EyE
  receive from a generator, send to a generator Skaperen 9 5,722 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