From 11:00 PM CST Friday, Feb 14th - 6:30 PM CST Saturday, Feb 15th, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From 11:00 PM CST Friday, Feb 14th - 6:30 PM CST Saturday, Feb 15th, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
04-24-2021 12:15 PM
Hey guys,
I'm working on a project and I need to replace elements of an array based on the elements around it.
I was given a subVI that outputs a random gene sequence as a 2D array of strings. Each string is comprised of one letter, representing half of a base pair in an RNA strand. (For example, A is next to U and C is next to G, or vice versa) The subVI randomly adds the letter M to simulate a mutation taking place. So, I need a code that would locate this mutation and replace it with the proper other half of the base pair. (So if the sequence was M-U, I would need to replace the M with an A).
I know how to locate the M and replace it, but I'm not sure how to replace it with the corresponding letter. I'm not sure how to make the program differentiate what the correct letter is to insert. Can anyone point me in the right direction? I've attached the subVI.
Thank you!
Solved! Go to Solution.
04-25-2021 04:37 AM - edited 04-25-2021 04:39 AM
Given the indices of the "M" element as (x,y), you can state that the indices of the element to use to determine the new value are (x, 1-y) for a 2D array (y=0 or y=1).
Once you have this, use Index Array to find the current value, and then you can use e.g. a Map to find the paired value.
As an aside, password protecting VIs that you upload to the forum is a bit annoying (although not critical in this case) and easily circumvented - passwords on VIs set in this manner basically are completely insecure - you shouldn't use this for "security" if that's something you're considering. Instead you need to entirely remove the block diagram as a compilation step if you're producing outputs. Password protection is only a deterrent.
Edit: I saw that I wired the search location in twice, once via the "?" and once as a normal tunnel. In case you didn't know, you don't need to do this - you can just wire the ? from the right side. I didn't notice before I uploaded 😕
04-25-2021 10:38 AM - edited 04-25-2021 11:33 AM
This almost looks like homework. What should happen if both elements of a row are M? Can there be more than one M? Can we assume that all other pairs are correctly matched, e.g. a U-G cannot occur?
04-25-2021 11:39 AM - edited 04-25-2021 01:09 PM
Here's how I would do all repairs except M-M (repaired A).
Once you have the result of all valid inputs, you can create a new map for even simpler code. (Repaired B). This version even replaces all invalid pairs with X-X.
04-25-2021 01:01 PM
Wow thank you so much - the only reason there is a password on that VI is because this is a small part of a homework assignment, and the professor didn't want us to be able to edit that VI. Nothing that really needs to be secure there! And no worries on the little extra wiring this is so helpful.
04-25-2021 01:02 PM
I guess I should've been a little more specific - sorry this is my first time posting anything on this kind of forum. I don't think both elements of a row can be M. There can be multiple M's, and we can assume all other pairs are correctly matched.
04-25-2021 01:03 PM
This is awesome! Thank you so much!