Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Code Generator
#4
Next time please post your code between [ python ] tags (but without the spaces), that makes it a lot easier to read ;)

In python indentation matters. Try this:
for i in range(3):
  # do some stuff
  a = i + 10
  
  print("I'm in the loop!", i)

for j in range(3):
  # do some stuff
  a = i + 10
  
print("I'm not in the loop!", j)
See the difference? Now if there's nothing in your loop, python will give an error. Also if you use indentation where you shouldn't. Try to use 4 spaces for each level of indentation (most editors will do this for you). This will keep your code readable (and it's what everybody else uses).

When you fix the indentation, you'll notice that the transfer function is executed 4 times instead of only once.

Now, about getting the right targets. Do you understand how the variable i corresponds to the column and j to the row of the target well? This piece of code does exactly the same as the first example I gave, maybe that will clear it up for you:
for i, mm in enumerate(mastermix_sources):
  #list of targets for mastermix
  targets = []
  for j in range(len(cDNA_sources)):
    column = chr(65+i)
    row = j+1
    target = "{}{}".format(column, row)
    targets.append(target)
  
  transfer(
           6, 
           mm,
           targets
         )
You hardly need to change anything to change this from A1, A2, A3 to A1, B1, C1. Also notice that the transfer function is part of the first loop, but not of the second, because of the indentation used.

If you got this figured out we can look at using multiple wells for 1 sample of cDNA, etc. Let me know if anything is unclear.
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,753 Apr-11-2023, 11:44 PM
Last Post: quazirfan
  Python returns generator instead of None Tawnwen 4 4,817 Mar-09-2018, 07:06 AM
Last Post: DeaD_EyE
  receive from a generator, send to a generator Skaperen 9 5,647 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