From 51d12fce8463f716a9c6c7707964777218694dc5 Mon Sep 17 00:00:00 2001 From: LukeCaruzo Date: Mon, 20 Nov 2017 15:01:08 +0100 Subject: [PATCH] Issue #69, not finished yet --- inst/java/deisotoper-1.0-SNAPSHOT.jar | Bin 74470 -> 74470 bytes .../R/FeaturesBasedDeisotoping.java | 144 +----------------- .../R/FeaturesBasedDeisotopingTest.java | 92 +++++++++++ .../ch/fgcz/proteomics/R/UtilitiesRTest.java | 67 ++++++++ 4 files changed, 164 insertions(+), 139 deletions(-) create mode 100644 java/deisotoper/src/test/java/ch/fgcz/proteomics/R/FeaturesBasedDeisotopingTest.java diff --git a/inst/java/deisotoper-1.0-SNAPSHOT.jar b/inst/java/deisotoper-1.0-SNAPSHOT.jar index e72baba063a64fe15602ba29b450f57bb00e43f6..45db5d0f4fda5f6e7a31c40d7746679c8a524836 100644 GIT binary patch delta 822 zcmXYuZ%7ky7{~YAZI$!Ra@+0p_cqO;X&T~uAsP~85Rt5`95vx@Rfh>&O&2$A8$Hw94;snmUcKkvnT?)yC7@AKU6t} zzsa6zaLd!o>ihg_1nme;F#RADv_Y2|s>B*ezY+Uwn{3b8ES87W`LVLs2&kkKHyaDg zWVCkH!#o#Pc7m&^aW>@g;48MQX-L?C`u;16Y>9Zy%W_(J!HW8?ktoYGkM>nT4^KE) z?$(`I33{M#bvIakVi&>pPZgZB`1R#omLDneLp*wYl=au%Zn1u4{v+#`m)h9A@5}Gl zdp-Z++Qa7jaI<|Ye;%{?sGm;5zp%~L0L7s*0iK%=@HtIE{vLXe>$xDEhp$cJbH_D) su4RqadqOmbz7e7!a3e$mU?R--PKPOlkNz)A-C$3h={Ns|QAct552nED)Bpeg delta 822 zcmXYuUr1A77{>RWvsKPbbKBWD`*XHw4o%Y#=Y?oUltE0|%C)elK%zhMVu>*VVHy~O z25YQ1jV`*&psQFhx>-eeBO)Z41wv#v@unaOB9%JN_jxYP?>z7OJnwtHbILQu@{G|E z4U0yz0oPC}YY7U8RJMIhzvtX^5C~Hnkfso@LBZT-s^X9BfKOnJn9!-KLPq#2fK#UU z9`Ku0sRXx`CRX3?Stn?lI>GcqziNUm)>nvCiPVkoZ_{L3#$+%&s?3d*T$)!Vsj$_M zXC|$sqYmczh_oAAi;uG*R|a0QWsQTvF4PZPU1Cebgp1{T$wedTzeYkV*EHH&0X;ln zW4YUR=Pc0u`D@i+>8V)+XP-$pY2oXudn`Xv;)i(r<{0a*zuRX0^1?^fFDyR{uO<^~ud3d@rBV9q3}0NU~WNN@+1GHG{XTbX;d~&Po{(h4VGk zp*ywvH8c$#vQZD1w$Wkmt&NU?eRlF{`|Q-PBaVPsJ8v%A^{Kk9b5I|6-9eYZPY${W zc1m;>d?3*|@TWv4!Cohw0`pEf0d6=c2KLBYXJqbMl_`pPNTJi7q;E zl8fh?-F)tto98~b`J8$W&yRZO4E&2bZ1GYAI_>4T1uvh|sPgx?sd7E9(gpZheSGe? ukDqJB$LrmG8bDw3(;&F%r+zRR;CrV76vs#Z7oaY%yH@w>e?zOK2>k~soDUlS diff --git a/java/deisotoper/src/main/java/ch/fgcz/proteomics/R/FeaturesBasedDeisotoping.java b/java/deisotoper/src/main/java/ch/fgcz/proteomics/R/FeaturesBasedDeisotoping.java index 3379c13..a381990 100644 --- a/java/deisotoper/src/main/java/ch/fgcz/proteomics/R/FeaturesBasedDeisotoping.java +++ b/java/deisotoper/src/main/java/ch/fgcz/proteomics/R/FeaturesBasedDeisotoping.java @@ -1,5 +1,10 @@ package ch.fgcz.proteomics.R; +/** + * @author Lucas Schmidt + * @since 2017-11-16 + */ + import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -14,11 +19,6 @@ import ch.fgcz.proteomics.fbdm.IsotopicSet; import ch.fgcz.proteomics.fbdm.Peak; -/** - * @author Lucas Schmidt - * @since 2017-11-16 - */ - public class FeaturesBasedDeisotoping { private Deisotoper deisotoper = new Deisotoper(); private MassSpectrum massSpectrum = new MassSpectrum(); @@ -145,138 +145,4 @@ public String getSummary() { return sb.toString(); } - - // public static void main(String[] args) { - // double[] mz = { 110.0715485, 110.1648788, 112.0395432, 113.0712204, - // 114.0746384, 115.05056, 115.9784622, - // 120.080986, 120.0833893, 121.0843735, 125.7498245, 129.0659332, 129.1023102, - // 130.0863342, 130.1057281, - // 131.0815735, 132.0849609, 132.5098419, 137.0346222, 141.0658417, 143.0816193, - // 145.0608368, 147.1128235, - // 149.0233917, 150.0266876, 153.0657654, 157.0970917, 159.076416, 160.0798035, - // 162.0875397, 162.0912323, - // 167.0816345, 170.092392, 171.0762177, 172.8989868, 175.118927, 180.0767212, - // 185.0920105, 189.1023407, - // 198.0873413, 199.0907135, 204.0980682, 205.0570374, 207.1127777, 208.0717316, - // 210.0866547, 210.7322388, - // 211.5193329, 212.10289, 214.0822296, 216.0977783, 223.0636444, 224.1031799, - // 225.0603638, 226.0820923, - // 227.0399933, 227.1023407, 228.098175, 230.1135101, 231.1125488, 231.1492462, - // 232.0926361, 232.2126312, - // 233.1646729, 235.1072845, 240.09758, 241.129364, 242.1128387, 246.1234741, - // 249.098175, 253.0928345, - // 254.1314087, 254.6329193, 255.1085358, 258.1084595, 259.1398315, 263.1368713, - // 267.1086426, 268.1119995, - // 269.1243591, 271.1038513, 273.1199646, 274.1184998, 276.1701965, 277.0926819, - // 277.1541138, 278.4438171, - // 279.108429, 285.1191101, 287.1348877, 289.650177, 292.1772461, 294.1808777, - // 295.1038513, 295.184082, - // 296.1346436, 297.1190491, 299.0617065, 300.133606, 301.0583801, 303.1295166, - // 310.4591064, 314.1459961, - // 315.129303, 318.1446228, 318.1605225, 324.1297607, 328.1278992, 331.8494568, - // 332.1560364, 333.1555786, - // 334.114502, 338.1456299, 342.1403198, 343.1411133, 346.176239, 351.1661377, - // 356.1558228, 357.1579285, - // 357.6632385, 358.1647949, 360.1513672, 360.6679077, 361.1502075, 363.2023926, - // 366.6683655, 368.6846924, - // 375.1660156, 375.2023926, 379.1607361, 381.2128296, 382.2158813, 387.1657104, - // 388.1895447, 390.9455261, - // 395.1658325, 397.1503906, 397.1950684, 397.6967163, 400.1613159, 403.135437, - // 403.1973877, 411.1614075, - // 418.1715698, 420.2235107, 421.1462402, 421.2265015, 426.1759949, 438.2343445, - // 439.2384644, 443.2040405, - // 444.1874084, 454.1725464, 461.2140198, 462.1977844, 471.1980896, 472.2180786, - // 479.2248535, 482.1990967, - // 489.2085571, 490.2118835, 490.2296448, 495.2563477, 507.2199402, 507.2555847, - // 508.2598572, 525.2663574, - // 526.2697754, 577.2515259, 578.2937012, 584.8656006, 596.3037109, 597.3069458, - // 617.3034668, 618.2872925, - // 635.3146362, 636.3175049, 653.3252563, 654.3284302 }; - // double[] intensity = { 6250.6640625, 563.5891113281, 787.7743530273, - // 42913.109375, 927.4467773438, - // 2023.1707763672, 529.0408325195, 25228.6796875, 1165.1545410156, - // 603.5643310547, 528.4467773438, - // 7070.5766601563, 31543.533203125, 19388.078125, 833.7221679688, 81864.546875, - // 3091.2973632813, - // 582.6003417969, 6660.9750976563, 34947.4921875, 684.2407836914, - // 3036.4206542969, 36999.45703125, - // 2973.7102050781, 829.9125366211, 6804.5180664063, 1259.5620117188, - // 46302.8125, 2067.9748535156, - // 1154.1105957031, 765.7245483398, 794.5812988281, 4291.3037109375, - // 888.9245605469, 606.1282958984, - // 766.3591918945, 14302.1279296875, 3288.0661621094, 688.5368652344, - // 35533.54296875, 2225.658203125, - // 670.2319335938, 677.4953613281, 6984.8188476563, 2347.3420410156, - // 594.0815429688, 2258.9313964844, - // 568.3290405273, 802.1146850586, 3599.0229492188, 7246.6596679688, - // 2139.9233398438, 828.2638549805, - // 884.8049316406, 1193.3479003906, 566.4050292969, 786.0283813477, - // 615.2380981445, 1079.8623046875, - // 1339.6888427734, 806.2881469727, 9631.443359375, 569.907409668, - // 1065.3564453125, 991.0939331055, - // 690.4099731445, 3580.0187988281, 672.0654296875, 845.2703857422, - // 1281.3441162109, 559.6304931641, - // 4143.1162109375, 1155.7521972656, 2598.6123046875, 953.2352905273, - // 3944.8764648438, 7301.6743164063, - // 4961.2807617188, 569.8205566406, 2566.8024902344, 795.173828125, - // 757.6403808594, 3254.8908691406, - // 7315.53515625, 1220.8388671875, 1115.0716552734, 524.3715820313, - // 676.455871582, 2324.4851074219, - // 808.6432495117, 1269.125, 581.4161376953, 31443.404296875, 2546.380859375, - // 2911.2058105469, - // 780.770324707, 738.4011230469, 1135.4598388672, 1176.7568359375, - // 3533.0815429688, 2457.2565917969, - // 562.0629882813, 928.1300048828, 1034.6174316406, 1035.1872558594, - // 2155.4260253906, 3214.2192382813, - // 586.0258178711, 545.24609375, 2240.283203125, 3230.6267089844, - // 1323.4107666016, 924.3392944336, - // 8073.1616210938, 767.8354492188, 789.9375610352, 2135.9985351563, - // 999.5626831055, 642.1485595703, - // 7692.0913085938, 1246.6643066406, 4829.984375, 799.643371582, - // 3193.9008789063, 1350.830078125, - // 901.1105957031, 687.5123901367, 996.9341430664, 1064.1864013672, - // 911.1711425781, 16409.24609375, - // 1171.5484619141, 960.3439331055, 935.4268188477, 677.4844970703, - // 657.7783813477, 2241.4836425781, - // 8700.474609375, 782.1491699219, 686.3291015625, 785.7287597656, - // 753.0210571289, 714.055847168, - // 2145.2751464844, 5911.2006835938, 1220.7615966797, 623.0693969727, - // 634.6696777344, 33137.39453125, - // 5135.7211914063, 813.663269043, 1231.4427490234, 933.5162963867, - // 3532.599609375, 1009.3364868164, - // 3219.3342285156, 800.7995605469, 3228.8891601563, 1368.7080078125, - // 6327.9125976563, 810.8509521484, - // 1239.9750976563, 791.6758422852, 1281.634765625, 6519.0903320313, - // 575.096496582, 65968.4140625, - // 11777.5908203125, 2284.7736816406, 2809.2331542969, 622.4571533203, - // 22998.53515625, 3657.8000488281, - // 1279.3221435547, 1236.6485595703, 9816.9814453125, 1331.3529052734, - // 87058.9140625, 21567.640625 }; - // - // FeaturesBasedDeisotoping dtoper = new FeaturesBasedDeisotoping(); - // - // double[] aa = { 99.06841 }; - // - // dtoper.setConfiguration(aa, 0.8, 0.5, 0.1, 0.1, 0.1, 0.03, 0.3, 1.0, 0, - // true); - // - // dtoper.setMz(mz); - // dtoper.setIntensity(intensity); - // dtoper.setPepMass(1.2345); - // dtoper.setCharge(2); - // - // dtoper.deisotope("none"); - // - // double[] mzout = dtoper.getMz(); - // double[] intensityout = dtoper.getIntensity(); - // - // System.out.println("Output Peaklist:"); - // for (int i = 0; i < mzout.length || i < intensityout.length; i++) { - // System.out.print(mzout[i] + " "); - // System.out.println(intensityout[i]); - // } - // System.out.println(); - // - // System.out.println(dtoper.getSummary()); - // } } \ No newline at end of file diff --git a/java/deisotoper/src/test/java/ch/fgcz/proteomics/R/FeaturesBasedDeisotopingTest.java b/java/deisotoper/src/test/java/ch/fgcz/proteomics/R/FeaturesBasedDeisotopingTest.java new file mode 100644 index 0000000..3118579 --- /dev/null +++ b/java/deisotoper/src/test/java/ch/fgcz/proteomics/R/FeaturesBasedDeisotopingTest.java @@ -0,0 +1,92 @@ +package ch.fgcz.proteomics.R; + +/** + * @author Lucas Schmidt + * @since 2017-11-20 + */ + +import org.junit.Test; + +public class FeaturesBasedDeisotopingTest { + @Test + public void test() { + double[] mz = { 110.0715485, 110.1648788, 112.0395432, 113.0712204, 114.0746384, 115.05056, 115.9784622, + 120.080986, 120.0833893, 121.0843735, 125.7498245, 129.0659332, 129.1023102, 130.0863342, 130.1057281, + 131.0815735, 132.0849609, 132.5098419, 137.0346222, 141.0658417, 143.0816193, 145.0608368, 147.1128235, + 149.0233917, 150.0266876, 153.0657654, 157.0970917, 159.076416, 160.0798035, 162.0875397, 162.0912323, + 167.0816345, 170.092392, 171.0762177, 172.8989868, 175.118927, 180.0767212, 185.0920105, 189.1023407, + 198.0873413, 199.0907135, 204.0980682, 205.0570374, 207.1127777, 208.0717316, 210.0866547, 210.7322388, + 211.5193329, 212.10289, 214.0822296, 216.0977783, 223.0636444, 224.1031799, 225.0603638, 226.0820923, + 227.0399933, 227.1023407, 228.098175, 230.1135101, 231.1125488, 231.1492462, 232.0926361, 232.2126312, + 233.1646729, 235.1072845, 240.09758, 241.129364, 242.1128387, 246.1234741, 249.098175, 253.0928345, + 254.1314087, 254.6329193, 255.1085358, 258.1084595, 259.1398315, 263.1368713, 267.1086426, 268.1119995, + 269.1243591, 271.1038513, 273.1199646, 274.1184998, 276.1701965, 277.0926819, 277.1541138, 278.4438171, + 279.108429, 285.1191101, 287.1348877, 289.650177, 292.1772461, 294.1808777, 295.1038513, 295.184082, + 296.1346436, 297.1190491, 299.0617065, 300.133606, 301.0583801, 303.1295166, 310.4591064, 314.1459961, + 315.129303, 318.1446228, 318.1605225, 324.1297607, 328.1278992, 331.8494568, 332.1560364, 333.1555786, + 334.114502, 338.1456299, 342.1403198, 343.1411133, 346.176239, 351.1661377, 356.1558228, 357.1579285, + 357.6632385, 358.1647949, 360.1513672, 360.6679077, 361.1502075, 363.2023926, 366.6683655, 368.6846924, + 375.1660156, 375.2023926, 379.1607361, 381.2128296, 382.2158813, 387.1657104, 388.1895447, 390.9455261, + 395.1658325, 397.1503906, 397.1950684, 397.6967163, 400.1613159, 403.135437, 403.1973877, 411.1614075, + 418.1715698, 420.2235107, 421.1462402, 421.2265015, 426.1759949, 438.2343445, 439.2384644, 443.2040405, + 444.1874084, 454.1725464, 461.2140198, 462.1977844, 471.1980896, 472.2180786, 479.2248535, 482.1990967, + 489.2085571, 490.2118835, 490.2296448, 495.2563477, 507.2199402, 507.2555847, 508.2598572, 525.2663574, + 526.2697754, 577.2515259, 578.2937012, 584.8656006, 596.3037109, 597.3069458, 617.3034668, 618.2872925, + 635.3146362, 636.3175049, 653.3252563, 654.3284302 }; + double[] intensity = { 6250.6640625, 563.5891113281, 787.7743530273, 42913.109375, 927.4467773438, + 2023.1707763672, 529.0408325195, 25228.6796875, 1165.1545410156, 603.5643310547, 528.4467773438, + 7070.5766601563, 31543.533203125, 19388.078125, 833.7221679688, 81864.546875, 3091.2973632813, + 582.6003417969, 6660.9750976563, 34947.4921875, 684.2407836914, 3036.4206542969, 36999.45703125, + 2973.7102050781, 829.9125366211, 6804.5180664063, 1259.5620117188, 46302.8125, 2067.9748535156, + 1154.1105957031, 765.7245483398, 794.5812988281, 4291.3037109375, 888.9245605469, 606.1282958984, + 766.3591918945, 14302.1279296875, 3288.0661621094, 688.5368652344, 35533.54296875, 2225.658203125, + 670.2319335938, 677.4953613281, 6984.8188476563, 2347.3420410156, 594.0815429688, 2258.9313964844, + 568.3290405273, 802.1146850586, 3599.0229492188, 7246.6596679688, 2139.9233398438, 828.2638549805, + 884.8049316406, 1193.3479003906, 566.4050292969, 786.0283813477, 615.2380981445, 1079.8623046875, + 1339.6888427734, 806.2881469727, 9631.443359375, 569.907409668, 1065.3564453125, 991.0939331055, + 690.4099731445, 3580.0187988281, 672.0654296875, 845.2703857422, 1281.3441162109, 559.6304931641, + 4143.1162109375, 1155.7521972656, 2598.6123046875, 953.2352905273, 3944.8764648438, 7301.6743164063, + 4961.2807617188, 569.8205566406, 2566.8024902344, 795.173828125, 757.6403808594, 3254.8908691406, + 7315.53515625, 1220.8388671875, 1115.0716552734, 524.3715820313, 676.455871582, 2324.4851074219, + 808.6432495117, 1269.125, 581.4161376953, 31443.404296875, 2546.380859375, 2911.2058105469, + 780.770324707, 738.4011230469, 1135.4598388672, 1176.7568359375, 3533.0815429688, 2457.2565917969, + 562.0629882813, 928.1300048828, 1034.6174316406, 1035.1872558594, 2155.4260253906, 3214.2192382813, + 586.0258178711, 545.24609375, 2240.283203125, 3230.6267089844, 1323.4107666016, 924.3392944336, + 8073.1616210938, 767.8354492188, 789.9375610352, 2135.9985351563, 999.5626831055, 642.1485595703, + 7692.0913085938, 1246.6643066406, 4829.984375, 799.643371582, 3193.9008789063, 1350.830078125, + 901.1105957031, 687.5123901367, 996.9341430664, 1064.1864013672, 911.1711425781, 16409.24609375, + 1171.5484619141, 960.3439331055, 935.4268188477, 677.4844970703, 657.7783813477, 2241.4836425781, + 8700.474609375, 782.1491699219, 686.3291015625, 785.7287597656, 753.0210571289, 714.055847168, + 2145.2751464844, 5911.2006835938, 1220.7615966797, 623.0693969727, 634.6696777344, 33137.39453125, + 5135.7211914063, 813.663269043, 1231.4427490234, 933.5162963867, 3532.599609375, 1009.3364868164, + 3219.3342285156, 800.7995605469, 3228.8891601563, 1368.7080078125, 6327.9125976563, 810.8509521484, + 1239.9750976563, 791.6758422852, 1281.634765625, 6519.0903320313, 575.096496582, 65968.4140625, + 11777.5908203125, 2284.7736816406, 2809.2331542969, 622.4571533203, 22998.53515625, 3657.8000488281, + 1279.3221435547, 1236.6485595703, 9816.9814453125, 1331.3529052734, 87058.9140625, 21567.640625 }; + + FeaturesBasedDeisotoping dtoper = new FeaturesBasedDeisotoping(); + + double[] aa = { 99.06841 }; + + dtoper.setConfiguration(aa, 0.8, 0.5, 0.1, 0.1, 0.1, 0.03, 0.3, 1.0, 0, true); + + dtoper.setMz(mz); + dtoper.setIntensity(intensity); + dtoper.setPepMass(1.2345); + dtoper.setCharge(2); + + dtoper.deisotope("none"); + + double[] mzout = dtoper.getMz(); + double[] intensityout = dtoper.getIntensity(); + + System.out.println("Output Peaklist:"); + for (int i = 0; i < mzout.length || i < intensityout.length; i++) { + System.out.print(mzout[i] + " "); + System.out.println(intensityout[i]); + } + System.out.println(); + + System.out.println(dtoper.getSummary()); + } +} diff --git a/java/deisotoper/src/test/java/ch/fgcz/proteomics/R/UtilitiesRTest.java b/java/deisotoper/src/test/java/ch/fgcz/proteomics/R/UtilitiesRTest.java index 2677eb3..19f9843 100644 --- a/java/deisotoper/src/test/java/ch/fgcz/proteomics/R/UtilitiesRTest.java +++ b/java/deisotoper/src/test/java/ch/fgcz/proteomics/R/UtilitiesRTest.java @@ -1,7 +1,74 @@ package ch.fgcz.proteomics.R; +/** + * @author Lucas Schmidt + * @since 2017-11-20 + */ + import static org.junit.Assert.*; +import org.junit.Test; + public class UtilitiesRTest { + @Test + public void testFindNNR() { + double[] testvector1 = { 2, 3 }; + double[] testq1 = { 2.3, 2.49, 2.5, 2.8, 2.9 }; + double[] testvector2 = { 85.9475706629195, 86.7750793375486, 86.9967229560885, 87.6731262158718, + 88.6829821533834, 89.3396244108142, 89.8757880719337, 89.9584765519992, 90.2825646251909, + 90.431521530632, 91.1389143263587, 91.921342144088, 92.2280356720829, 92.2415691164642, + 92.4377087687997, 92.5932143517964, 92.6500683333295, 92.8603607201231, 93.0491255652764, + 93.0623082543646, 93.3548338320611, 94.8106060770257, 94.9067505814658, 95.0189208409334, + 95.0890198758729, 95.3262380215399, 95.6130846412633, 95.7925786610902, 96.0254409596587, + 96.35566170251, 96.3820762532736, 96.6643606292586, 96.9811909782282, 97.4360136701071, 97.746473210741, + 97.9059534858245, 97.9252710745944, 97.9932950413078, 98.0576941325114, 98.2027928423104, + 98.3950806568394, 98.5216607448496, 98.6125035807534, 99.7475028100491, 100.328571560527, + 100.637917766864, 100.718101434643, 100.833207927132, 100.961423954928, 100.982024504662, + 100.996346397962, 101.422700667736, 102.288507766316, 102.362217478546, 102.453825772869, + 102.467483144163, 102.754701074105, 103.20327914459, 103.22183290181, 103.314750747746, + 103.333977285928, 103.363483484325, 103.422411325728, 104.011688682475, 104.197147724307, + 104.426539295269, 105.078168257753, 105.26040540922, 105.400901272821, 105.461610038605, + 105.860977822103, 105.92488873846, 105.975075090741, 106.055844074642, 106.562673640634, + 106.907740376078, 107.286944340326, 107.913015923358, 108.154319483362, 108.373006215209, + 109.962207556301, 109.975693121142, 110.042692353348, 110.183057433971, 111.089702456451, + 111.402628677836, 111.619554942092, 111.928468788626, 112.210900515379, 113.197816821342, + 113.426947990167, 115.660867000129, 115.738388967384, 116.366726086019, 116.673517752972, + 116.76284457042, 117.270241719093, 117.669586987771, 120.214589175879, 127.695481003 }; + double[] testvector3 = { -1, -0.98, -0.96, -0.94, -0.92, -0.9, -0.88, -0.86, -0.84, -0.82, -0.8, -0.78, -0.76, + -0.74, -0.72, -0.7, -0.68, -0.66, -0.64, -0.62, -0.6, -0.58, -0.56, -0.54, -0.52, -0.5, -0.48, -0.46, + -0.44, -0.42, -0.4, -0.38, -0.36, -0.34, -0.32, -0.3, -0.28, -0.26, -0.24, -0.22, -0.2, -0.18, -0.16, + -0.14, -0.12, -0.1, -0.08, -0.0599999999999999, -0.04, -0.02, 0, 0.02, 0.04, 0.0600000000000001, + 0.0800000000000001, 0.1, 0.12, 0.14, 0.16, 0.18, 0.2, 0.22, 0.24, 0.26, 0.28, 0.3, 0.32, 0.34, 0.36, + 0.38, 0.4, 0.42, 0.44, 0.46, 0.48, 0.5, 0.52, 0.54, 0.56, 0.58, 0.6, 0.62, 0.64, 0.66, 0.68, 0.7, 0.72, + 0.74, 0.76, 0.78, 0.8, 0.82, 0.84, 0.86, 0.88, 0.9, 0.92, 0.94, 0.96, 0.98, 1 }; + double[] testq3 = { -1000, 0, 0.001, 10, 10000 }; + + // Test 1 + double[] result1 = { 1, 1, 2, 2, 2 }; + double[] findNN1 = UtilitiesR.findNNR(testq1, testvector1); + assertEquals("Result must be same length!", result1.length, findNN1.length); + for (int i = 0; i < result1.length; i++) { + assertEquals("Every item must be same!", (int) findNN1[i], (int) result1[i]); + } + + // Test 2 + int j = 1; + int sum = 0; + int sumj = 0; + for (double i : UtilitiesR.findNNR(testvector2, testvector2)) { + sum = (int) i + sum; + sumj = j + sumj; + assertEquals("i must be equals to j!", (int) i, j); + j++; + } + assertEquals("Sum of testvector2 must be equals to sum of j!", sum, sumj); + // Test 3 + double[] result3 = { 1, 51, 51, 101, 101 }; + double[] findNN3 = UtilitiesR.findNNR(testq3, testvector3); + assertEquals("Result must be same length!", result3.length, findNN3.length); + for (int i = 0; i < result3.length; i++) { + assertEquals("Every item must be same!", (int) findNN3[i], (int) result3[i]); + } + } } \ No newline at end of file