# CHALLENGE - Compare two lists (subtype: genetic differences)

Question asked by DrewTenenholz on May 4, 2017
Latest reply on May 4, 2017 by siplus

Hi All --

Here's something I've been having trouble getting correct, and would like your help so I stop banging my head against the wall.

Q: How many differences are there between two different individuals at a single genetic locus?

...at least that the question I'd like to answer, but I think this could also be generalized to use methods comparing two lists of values.  In my case, ListA & ListB will only ever have two values each, but I think any successful calculation would be able to compare lists of varying lengths (and even lists with different lengths).

Below is a chart that explains what I'm trying to do.  It shows the alleles (values) at one locus for two individuals and the expected result.  Next to that are columns showing what happens when I use various ValueList comparison functions: FilterValues, and Ray Cologon's excellent XORValues and ZAPValues.  Unfortunately, none of these give the an answer that is always correct.

Below the chart is a long calculation that you can throw into the data viewer which runs the nine separate tests and spits out readable results.  I hope that will help anyone willing to take on the challenge and find a successful result.

Thanks for taking a look at this!

-- Drew

P.S.  In the end, i could work out a more 'manual'/'explicit' way of getting my answer, after all, there are only ever two values to compare to two others.  But, I'm hoping for something more efficient and elegant.

 List A (Individual A) List B (Individual B) Test Homologue1 Homologue2 Homologue1 Homologue2 Expected Differences FilterValues XORValues ZAPValues 1 M1 M1 M1 M1 0 2 ( should be 0 ) success success 2 M1 M1 M1 M2 1 2 ( should be 1 ) success 0 ( should be 1 ) 3 M1 M1 M2 M1 1 2 ( should be 1 ) success 0 ( should be 1 ) 4 M1 M1 M2 M3 2 0 ( should be 2 ) 3 ( should be 2 ) success 5 M1 M2 M1 M1 1 success success success 6 M1 M2 M1 M2 0 2 ( should be 0 ) success success 7 M1 M2 M2 M1 0 2 ( should be 0 ) success success 8 M1 M2 M2 M3 1 success 2 ( should be 1 ) success 9 M1 M2 M2.1bR57 M3 2 0 ( should be 2 ) 4 ( should be 2 ) success

Let ( [

ListA1=List("M1";"M1")

; ListB1=List("M1";"M1")

; ListA2=List("M1";"M1")

; ListB2=List("M1";"M2")

; ListA3=List("M1";"M1")

; ListB3=List("M2";"M1")

; ListA4=List("M1";"M1")

; ListB4=List("M2";"M3")

; ListA5=List("M1";"M2")

; ListB5=List("M1";"M1")

; ListA6=List("M1";"M2")

; ListB6=List("M1";"M2")

; ListA7=List("M1";"M2")

; ListB7=List("M2";"M1")

; ListA8=List("M1";"M2")

; ListB8=List("M2";"M3")

; ListA9=List("M1";"M2")

; ListB9=List("M2.1bR57";"M3")

; expectedResult1= 0

; expectedResult2= 1

; expectedResult3= 1

; expectedResult4= 2

; expectedResult5= 1

; expectedResult6= 0

; expectedResult7= 0

; expectedResult8= 1

; expectedResult9= 2

; test1= FilterValues ( ListA1 ; ListB1 )

; test2= FilterValues ( ListA2 ; ListB2 )

; test3= FilterValues ( ListA3 ; ListB3 )

; test4= FilterValues ( ListA4 ; ListB4 )

; test5= FilterValues ( ListA5 ; ListB5 )

; test6= FilterValues ( ListA6 ; ListB6 )

; test7= FilterValues ( ListA7 ; ListB7 )

; test8= FilterValues ( ListA8 ; ListB8 )

; test9= FilterValues ( ListA9 ; ListB9 )

; countTest1= ValueCount ( test1 )

; countTest2= ValueCount ( test2 )

; countTest3= ValueCount ( test3 )

; countTest4= ValueCount ( test4 )

; countTest5= ValueCount ( test5 )

; countTest6= ValueCount ( test6 )

; countTest7= ValueCount ( test7 )

; countTest8= ValueCount ( test8 )

; countTest9= ValueCount ( test9 )

"test1= " & Case ( countTest1 = expectedResult1 ; "success" ; countTest1 & " ( should be " & expectedResult1 & " )" )

; "test2= " & Case ( countTest2 = expectedResult2 ; "success" ; countTest2 & " ( should be " & expectedResult2 & " )" )

; "test3= " & Case ( countTest3 = expectedResult3 ; "success" ; countTest3 & " ( should be " & expectedResult3 & " )" )

; "test4= " & Case ( countTest4 = expectedResult4 ; "success" ; countTest4 & " ( should be " & expectedResult4 & " )" )

; "test5= " & Case ( countTest5 = expectedResult5 ; "success" ; countTest5 & " ( should be " & expectedResult5 & " )" )

; "test6= " & Case ( countTest6 = expectedResult6 ; "success" ; countTest6 & " ( should be " & expectedResult6 & " )" )

; "test7= " & Case ( countTest7 = expectedResult7 ; "success" ; countTest7 & " ( should be " & expectedResult7 & " )" )

; "test8= " & Case ( countTest8 = expectedResult8 ; "success" ; countTest8 & " ( should be " & expectedResult8 & " )" )

; "test9= " & Case ( countTest9 = expectedResult9 ; "success" ; countTest9 & " ( should be " & expectedResult9 & " )" )

)

; testResult= List (

"test1= " & test1

; "test2= " & test2

; "test3= " & test3

; "test4= " & test4

; "test5= " & test5

; "test6= " & test6

; "test7= " & test7

; "test8= " & test8

; "test9= " & test9

)

];

List ( headlineResult ; "¶Individual Results:" ; testResult )

)