/* Copyright 2013 University of North Carolina at Chapel Hill. All rights reserved. */
package abra;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import net.sf.samtools.SAMFileReader;
import net.sf.samtools.SAMFileWriter;
import net.sf.samtools.SAMFileWriterFactory;
import net.sf.samtools.SAMRecord;
import net.sf.samtools.SAMFileReader.ValidationStringency;
import net.sf.samtools.SAMRecordIterator;
public class ReAlignerStats {
private String regionsGtf;
private String inputSam;
private String outputPrefix;
private List<Feature> regions;
public ReAlignerStats(String regionsGtf, String inputSam) {
this.regionsGtf = regionsGtf;
this.inputSam = inputSam;
}
private boolean inRegion(SAMRecord read) {
for (Feature region : regions) {
if (region.getSeqname().equals(read.getReferenceName())) {
if ((read.getAlignmentStart() >= region.getStart()) &&
(read.getAlignmentStart() <= region.getEnd())) {
return true;
}
if ((read.getAlignmentEnd() >= region.getStart()) &&
(read.getAlignmentEnd() <= region.getEnd())) {
return true;
}
}
}
return false;
}
public void getOtherReads(String outputSam) throws IOException {
RegionLoader loader = new RegionLoader();
regions = loader.load(regionsGtf);
// printRegionHeader();
SAMFileReader reader = new SAMFileReader(new File(inputSam));
reader.setValidationStringency(ValidationStringency.SILENT);
SAMFileWriter output = new SAMFileWriterFactory().makeSAMOrBAMWriter(
reader.getFileHeader(), true, new File(outputSam));
int cnt = 0;
for (SAMRecord read : reader) {
if (!inRegion(read)) {
output.addAlignment(read);
}
cnt++;
if ((cnt % 1000000) == 0) {
System.out.println(cnt);
}
}
reader.close();
output.close();
}
public void run() throws IOException {
RegionLoader loader = new RegionLoader();
regions = loader.load(regionsGtf);
printRegionHeader();
SAMFileReader reader = new SAMFileReader(new File(inputSam));
reader.setValidationStringency(ValidationStringency.SILENT);
for (Feature region : regions) {
int count = 0;
SAMRecordIterator iter = reader.queryOverlapping(region.getSeqname(), (int) region.getStart(), (int) region.getEnd());
while (iter.hasNext()) {
iter.next();
count += 1;
}
iter.close();
System.out.print(count + ",");
}
reader.close();
}
private void printRegionHeader() {
for (Feature region : regions) {
System.out.print(region.getDescriptor() + ",");
}
System.out.println();
}
public static void main(String[] args) throws Exception {
//ReAlignerStats stats = new ReAlignerStats("/home/lmose/dev/ayc/regions/egfr.gtf", "/home/lmose/dev/ayc/sim/38/sorted_tiny.bam");
ReAlignerStats stats = new ReAlignerStats(args[0], args[1]);
// stats.run();
stats.getOtherReads(args[2]);
// diff();
}
public static void diff() {
String o1 = "9003,628,1304,2334,428,581,268,406,1612,588,1527,532,599,292,1144,1240,1557,1731,1483,63,197,965,808,609,163,199,649,632,895,22,82,4829,48,1183,1456,1148,2862,1543,710,770,511,768,2033,3469,912,554,6265,1894,447,2781,2307,1388,429,1021,687,2585,425,1358,591,2539,925,927,2082,2218,549,703,614,2977,1222,672,1172,2033,1180,820,1311,709,886,102,11,90,427,1708,3430,2633,1245,930,1243,1735,9,577,403,448,31954,414,2736,772,3377,1356,3,13,5,929,20,9,487,1759,3213,485,1625,1188,1220,1820,1649,1527,3966,1240,3117,1603,10262,3167,301,5516,4203,2226,549,452,1018,363,856,406,1,34,246,412,2114,3434,327,653,12961,2075,1603,3029,44,431,1998,3792,2570,62,1268,903,1950,0,3180,3454,7787,998,789,1742,937,19812,739,1502,870,685,750,3754,1978,1850,849,1249,2792,2366,1495,1679,1332,1555,12,1831,1659,1708,935,1583,1814,1199,1964,1468,1475,1045,2754,2769,1,196,293,21,12292,5511,3,538,922,1837,1785,721,866,2602,1799,1896,90,1255,2140,4007,1276,3515,1166,11213,1191,460,146,1008,462,767,778,3416,647,540,790,929,709,936,14816,1088,5694,1882,967,28477,1292,1175,784,1967,999,675,2085,1663,2113,1129,191,0,139,857,528,456,543,581,1200,435,601,645,629,241,270,899,642,819,4556,1075,606,375,0,273,312,159,899,1766,885,2184,679,823,736,5167,1321,901,1928,9858,362,734,1801,1208,1613,524,349,408,0,550,654,455,902,1427,1317,946,481,465,441,355,439,877,797,397,4263,1450,2426,941,404,271,1260,3595,5143,386,1703,164,655,335,10815,480,237,1407,428,1461,410,288,170,1126,1062,35,169,527,476,214,294,357,643,2442,659,1176,482,7486,2662,207,570,740,568,473,284,512,483,571,7,318,444,2094,203,1462,28,67,1074,5959,0,1,3,4,4547,647,712,106,860,355,562,1573,893,679,383,1358,762,74,649,523,1318,587,505,1629,2514,1610,568,695,728,1059,811,1316,2531,11,452,340,799,323,232,9,556,428,358,742,18,654,211,1167,1020,2135,1134,1010,2105,0,23,561,782,156,680,11053,2271,592,284,2119,214,5,114,1424,873,212,504,1169,233,117,6587,186,5,7,1154,124,776,609,3539,12018,2314,1896,1518,2772,502,1546,1046,890,3080,980,2032,1312,1151,272,2263,402,1769,1452,31,11875,583,7105,4804,3201,1468,604,754,911,887,131,724,1571,448,55,706,609,2628,1164,971,748,1015,765,307,845,643,773,1351,1119,863,1656,2161,351,397,747,1318,3601,1307,536,146,417,5545,1418,1745,2889,619,1031,2184,1355,483,2823,998,1379,518,650,64,362,1180,1100,4136,791,787,830,4392,4648,2409,827,530,300,450,720,1173,0,368,1938,893,1,987,1141,1156,404,804,1383,1289,1921,1146,704,44,427,7262,757,3884,822,104,2680,209,2848,1060,2849,1199,2166,1514,2007,1984,1992,2223,1431,748,813,2743,2017,1187,1558,2421,4013,221,498,2277,2366,1464,1562,1194,1651,1558,691,854,1193,687,3259,399,2461,2636,22,171,6977,1477,2466,684,365,734,1275,660,312,617,220,672,1374,390,1,1227,911,1600,1337,552,881,905,419,1163,3215,6847,1903,206,3362,1004,2129,1829,2348,714,534,1371,786,354,985,1317,1119,605,6541,27,472,905,108,3138,802,3032,264,754,1156,1403,508,1194,295,830,113,777,357,304,1180,1038,1269,1045,1311,346,1112,85,3781,579,44,1928,784,49,895,932,413,381,1309,313,1202,465,796,504,558,509,916,1577,2910,1184,23,145,1399,823,472,624,789,2982,2652,1014,748,685,0,0,0,8,1,4,1,2,2,0,0,0,1340,394,1518,22,3153,1724,737,2250,537,722,616,886,828,861,950,2147,853,1640,1490,924,1331,1213,6308,5591,142,284,2180,961,432,723,914,877,818,864,3745,655,1713,631,59,1498,2272,7841,1654,374,6,5353,1958,565,605,941,1144,2381,1500,991,785,1411,1649,1247,614,1769,3580,1503,647,1480,1613,911,1013,1082,1231,639,505,2024,6187,5394,5147,1533,1042,1817,463,1417,1387,666,713,924,798,568,2694,1466,2961,412,207,1626,635,958,1974,53,29226,13133,677,1013,428,726,1459,1115,12325,1397,4301,1224,910,6191,2698,2797,2798,1304,1420,651,446,2478,941,881,564,908,381,54,5051,1132,795,2917,4198,1372,1,1,1744,362,712,350,748,1090,958,337,696,398,341,1637,247,641,3813,1313,148,1,4005,3628,1884,1131,1534,923,533,1298,5442,1612,1052,379,771,296,341,472,1254,834,166,1151,542,350,1256,302,885,82,330,762,89,172,324,655,589,354,139,712,323,30,1,61,877,634,2638,720,1140,1418,873,4366,5616,1280,847,276,1630,1248,6845,7,21,67,2962,1486,587,478,1711,405,530,6657,1695,776,2501,76,1347,13384,478,0,873,188,973,715,394,558,94,295,761,233,712,115,443,2514,532,466,255,842,877,18388,14956,850,3743,1381,635,1568,743,711,487,1476,157,116,10,0,1205,1026,2624,699,745,740,1052,429,916,2201,1276,636,580,904,887,593,1323,111,1998,411,998,625,895,916,289,287,160,1815,877,1100,155,214,1,0,685,1839,490,2832,650,349,6,693,787,3136,1019,1832,0,34,22,700,3394,330,2702,946,624,2767,3490,1288,1339,733,2078,910,870,365,194,98,3377,744,765,1218,3437,309,17,0,1029,4641,2874,3077,7298,5345,813,1911,549,661,530,2437,422,3675,765,422,680,763,3,273,1148,621,1502,5344,17,11,1198,2196,978,3341,87,1144,4107,995,6355,1,177,225,729,58,419,733,828,1766,1703,1547,2171,1588,931,5,669,148,804,1453,2462,1168,316,3268,1957,10651,636,611,305,1041,1432,1743,263,2526,1205,503,2281,1082,974,5539,1649,820,2875,951,2652,1247,1615,341,2063,1018,1397,1775,2207,2352,2443,1393,829,1881,1778,2573,1176,1684,1745,854,1093,801,1317,1373,1289,924,857,267,1225,11625,32,104,347,1088,600,2762,1190,8571,3088,981,589,998,10925,13863,2,61,267,28,696,1171,1584,1133,831,1288,2087,3302,1249,1157,643,857,1290,972,6334,1643,1566,540,1416,1652,1399,1379,1709,3638,2677,2438,206,15041,4,8673,6136,21386,2095,1417,1566,1452,452,1671,1368,779,781,323,934,84,6,32,817,8644,205,139,53,1489,1243,1843,189,765,1266,1258,1226,2295,1023,2657,1462,1319,1147,706,945,5704,1830,4598,0,2815,1,117,201,358,5088,1701,1359,2514,1501,4955,0,878,0,989,1169,836,900,883,672,1477,625,400,1321,802,1195,1393,675,2193,267,13,9,10,181,1315,4504,1673,205,3947,3296,4910,643,175,135,1346,767,1146,461,330,265,3157,1760,418,468,631,609,2091,1446,428,854,526,737,3244,153,549,961,3218,1248,875,3165,6126,169,389,964,2629,2139,1799,1912,6258,694,4232,2415,591,674,306,845,27,497,15,1378,229,3510,1934,662,1131,1319,1361,5023,42,5042,1211,2241,3646,1099,24,1557,1114,66,2285,125,1888,4281,4483,1,0,0,0,2,1,1,0,0,0,1,5336,736,2445,2426,1515,2119,1672,1373,1465,673,1857,4579,2168,168,536,481,1840,1290,913,374,1859,547,663,1445,350,1539,1236,653,1056,355,309,434,323,1477,37,1559,8,519,47,46,972,1194,38,877,331,589,1147,394,746,288,817,536,547,482,3,28,871,1198,679,766,1208,408,4658,133,1463,2503,2902,3677,825,1279,521,562,2923,1461,1259,1230,579,779,216,864,800,2046,1778,949,1918,1529,3621,624,239,1497,1513,69,1595,1227,2886,2799,683,897,1102,874,15,81,653,532,1636,1545,283,467,99,16,598,385,206,195,17,880,298,193,223,970,22,257,1111,1456,1511,932,651,22,1765,2847,4518,1380,937,2677,2619,470,344,2818,240,390,367,66,202,1171,1299,0,123,633,2248,4895,8832,307,514,1358,704,257,4,870,516,21,1179,695,451,1088,795,1048,173,1100,704,1069,2302,411,1138,1122,2670,2540,3663,7662,3834,348,2057,4541,8416,10697,959,1520,539,0,714,2056,7868,105,1151,2488,585,8241,1277,8182,1459,1015,1201,1270,557,1717,1592,1336,348,1499,1850,1575,2513,2236,860,1702,319,185,539,24,31,830,886,3073,303,168,900,1316,1087,543,507,1139,655,1218,10288,8070,5428,13711,2960,2083,3218,2612,1604,3420,1911,1168,4476,355,2750,1245,2314,3865,1910,1816,1706,804,3604,2705,2067,588,2032,1682,1079,982,72,793,1149,1447,349,1166,2035,803,665,462,406,6,12,0,331,1416,135,2086,1403,1566,243,672,596,2708,1,53,30,805,2417,1053,178,651,525,468,1220,257,1624,1424,778,604,190,533,561,533,4267,11641,1818,1516,1737,1473,1630,1079,1360,705,837,1357,14721,6069,1678,5169,1,35,82,11753,268,16282,772,894,1966,1021,406,1429,3542,22224,2072,138,27,33,1268,1249,140,371,696,293,1281,4,746,4854,3712,168,132,985,950,639,641,1507,1117,720,943,6494,1262,304,103,12762,0,1,0,0,0,0,0,0,1,0,0,0,0,1,3,2,1,0,0,0,1,1,19,4061,3548,11,335,440,1377,238,512,886,1377,753,721,1668,1786,1658,505,2116,537,1367,2840,2691,923,552,2,1272,1172,3314,59,1091,5757,702,1269,893,1124,511,1597,189,401,66,652,510,101,40,0,0,3988,907,971,609,1421,3133,2,923,195,984,586,566,5504,2440,1691,3,11,1258,265,355,349,752,2438,469,1050,579,784,235,903,752,672,738,599,1091,485,1059,1387,3276,909,1268,1076,2378,652,4271,584,296,125,74,59,67,33,5050,3286,1081,365,651,577,1274,581,986,560,611,2425,238,1056,320,866,37,319,371,422,1146,2,1090,1496,1126,852,471,556,898,638,412,725,466,1460,49,442,1717,325,14,891,1678,824,1125,611,126,1418,575,451,2580,707,546,668,971,617,42,1345,1126,1729,487,414,918,383,546,25,986,553,604,571,404,1312,633,3700,2389,1075,4,23,432,1370,1591,13480,3727,1982,1608,1354,3247,1844,1948,1512,2682,1951,1857,2164,2811,216,4276,2131,1930,1907,1643,2695,29643,904,791,1151,2300,1773,4359,3305,19005,5642,507,88,1045,10,733,740,633,3018,214,2110,395,610,1199,2109,456,2034,923,5836,4079,418,2185,1913,631,678,526,246,999,865,735,33,0,1,469,519,704,1,579,160,2560,1921,141,682,401,21092,576,1665,581,1184,183,248,905,1607,4429,878,566,2802,2511,2039,5681,6178,3765,3928,662,3394,2877,6102,1948,1746,1376,9973,1820,1862,349,502,905,270,1480,1014,423,662,5087,301,6777,3051,347,1652,562,743,1282,735,807,345,297,842,1667,753,2051,521,1231,612,192,486,1541,1196,9810,693,1368,714,568,2558,2476,1485,2343,2290,591,97,784,607,277,261,108,691,328,271,1438,1614,4676,1685,643,578,614,1094,638,511,803,1106,584,2015,2178,352,842,2291,1109,459,1122,428,68,410,11669,791,927,1130,624,869,522,2043,1365,427,1201,397,1221,735,99,609,0,1677,1065,471,674,2345,525,985,1916,517,1535,270,9733,2577,448,455,729,644,45,819,586,697,1169,388,368,712,740,1088,2931,1160,1010,324,1105,694,965,781,443,709,905,329,352,140,1924,213,1261,586,144,174,3655,309,422,315,13351,240,1151,203,456,111,536,1428,3080,123,1482,1821,490,4858,324,283,461,828,1202,1324,397,325,300,3135,253,1860,1260,375,922,328,894,2043,138,91,1966,2896,893,220,190,388,950,579,462,759,942,1206,428,699,382,523,943,60,480,1185,1619,1548,1367,530,1295,622,2553,2186,2397,2254,179,1716,1279,1365,1266,578,161,679,1682,1058,276,622,982,1166,398,640,66,575,58,1864,1750,32,119,1444,4923,614,875,708,3704,1543,2410,312,1507,654,691,1070,569,280,1801,1366,11830,5693,12984,779,3487,1103,2783,7105,562,104,1537,1279,7576,5244,2723,2469,2313,3374,684,4555,3407,638,7,1,7,0,1,0,0,0,0,0,0,0,0,6,0,0,0,0,0,3,348,1,0,1576,1220,158,515,1097,694,241,323,712,1125,2934,0,245,439,592,610,1099,1108,1470,1048,498,595,1185,2292,13633,1,23,559,2460,1042,104,7,0,1417,1482,610,828,2925,555,1355,845,1777,922,1110,2725,55,846,559,5700,215,222,280,392,1672,391,399,1038,3506,504,582,518,495,372,507,25,338,285,292,2238,1131,1790,1548,363,777,589,40,11,400,113,2376,378,1187,1028,1108,1697,1689,1530,1378,2420,1338,1749,1099,263,1277,1030,1085,718,7060,1385,1306,15429,664,314,2132,1579,640,1378,812,419,2407,893,1406,1331,1379,1274,968,1684,2298,1336,1362,1969,1534,2137,803,982,1062,3977,1788,2580,7,1022,3672,1062,909,726,617,935,2092,1773,408,12601,6413,2195,918,398,701,904,1030,2990,4192,3667,2462,1623,489,1336,1453,569,1019,584,1724,158,806,2029,533,1355,557,884,894,799,1386,1034,989,893,871,1158,725,2018,46,118,33,1168,112,4,0,4099,3669,707,2819,2,181,63,250,1969,2736,1271,2639,1965,1597,1009,2265,933,784,1435,2708,4129,31,70,406,1016,2566,459,1835,2415,669,364,1899,521,2,26,125,547,0,0,1063,811,551,316,1091,394,1077,275,13691,144,81,636,344,565,285,456,1463,1047,543,1066,214,1226,144,1006,329,606,134,1800,1540,5460,562,27,266,3110,245,1825,1226,3502,1106,609,145,1296,1111,6,330,1849,2641,2833,969,3,1558,761,1923,1301,523,398,936,695,235,525,777,568,46,2665,1209,3115,962,3140,7004,1198,156,797,328,1441,99,46,879,498,2195,1260,1630,911,83,477,1366,2309,4480,83,6128,3126,5545,1986,3680,1470,1396,2438,649,2197,2110,871,995,350,1085,1245,146,2064,3568,360,774,1717,3334,3096,2953,965,1211,1870,1281,578,1518,2192,393,386,5326,1042,774,293,160,1156,123,5885,4192,216,1093,3192,1455,170,2233,986,909,3180,6518,524,3151,2309,2034,1470,256,766,22082,2459,766,573,265,144,1934,187,519,396,474,367,917,410,2884,668,1109,330,1974,301,633,1291,329,2056,666,343,246,2313,2067,200,3316,6463,1279,1237,805,638,263,628,723,1208,5794,132,773,2003,427,90,1882,465,608,1084,1149,103,844,1525,1127,1145,421,337,1043,221,246,2208,1932,198,1569,1958,3717,3148,581,488,633,841,1643,598,930,824,0,214,427,591,1337,1158,1147,675,360,783,646,854,620,712,858,504,412,649,621,332,534,370,981,5397,412,7077,9450,2155,8053,533,2951,171,3074,1787,591,226,500,20,650,529,637,2444,148,55,3,269,16,1234,920,130,212,1513,1410,536,1003,362,407,5314,1687,7731,2804,576,3709,4520,138,12495,226,508,1520,874,1008,298,937,570,353,449,1004,521,782,3,354,0,788,756,1038,0,2605,0,0,313,41,221,555,574,860,1439,94,536,3047,472,220,341,551,3417,1606,11425,746,1733,3327,0,2,1,307,157,119,152,806,1490,72,672,423,94,178,1481,11,5,2256,1296,193,1281,1689,574,1151,845,962,0,184,756,487,598,973,1458,124,4,2,1,4,0,1,1,0,2,0,6,1575,371,587,469,2035,541,1085,890,1009,91,4,2719,2348,2314,3399,593,0,4,6,861,895,683,476,756,688,415,1573,1093,642,1020,271,1355,1368,1264,5,4,731,372,585,1167,421,1600,381,892,672,760,734,734,54,489,2501,1221,458,807,452,246,2533,714,1122,763,436,13,3,1770,1046,1002,597,414,1150,2056,729,867,3179,82,11,5,839,1214,899,775,784,811,1283,1398,300,591,1423,1006,1047,394,592,1506,473,456,174,0,1,1,50,996,2581,694,7,3411,1881,3836,15,86,85,1,2785,9365,166,1265,2640,1170,876,4061,916,1809,766,494,991,1059,706,69,4,2,4,2,1,0,1,0,0,5051,1921,637,820,736,1145,1914,2883,1037,622,28,217,603,96,1051,358,32,13,128,108,214,594,974,1942,667,206,442,1128,1835,705,3006,810,1350,3069,407,419,193,1,1097,1193,381,811,475,565,387,758,1239,412,1093,831,1300,1341,1516,703,1422,1197,2741,3028,633,12,0,0,3,0,0,0,4,0,0,0,0,3,0,0,0,2,0,0,2,1,0,2,1,0,0,12,0,7,0,0,0,2,5,2,0,1,0,2,1,8005,785,988,844,0,1797,1432,104,1862,3768,1329,8368,1494,542,143,267,262,69,1947,329,5659,3503,2,6572,1520,9926,228,5716,1506,2718,3445,618,346,0,0,1294,659,1325,1017,3727,538,660,95,982,1502,5,4828,130,1,264,3157,1601,162,2121,613,65,1811,1189,233,1380,2947,4617,15881,1640,200,19,531,921,2369,0,898,1533,1020,740,494,324,970,1008,641,548,818,636,163,53,1585,270,6,1486,1234,1226,1570,453,1686,2138,1934,1713,1251,1924,1765,846,1690,2001,1556,1602,1522,1861,1627,6628,3976,1346,932,2268,0,222,319,546,382,1331,1083,1093,1001,1128,777,1140,1048,1951,690,2033,219,830,3178,5427,1922,474,177,1337,976,1096,327,877,942,1307,1391,2094,2698,218,363,3936,10649,5578,4751,161,230,42,222,603,1164,2315,532,962,885,1646,709,232,948,1027,4512,883,1287,1205,743,1187,3056,421,729,1060,780,2226,783,2312,2923,10019,1402,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0";
String r1 = "8210,617,1307,2328,408,561,264,339,1170,550,1507,519,580,265,1137,971,1380,1725,1473,42,191,544,803,559,151,195,644,614,881,17,79,4824,45,684,1452,808,2501,1532,705,766,515,760,2030,3461,904,548,5082,1885,431,2595,2301,1383,411,1011,683,2580,411,1352,587,2533,796,923,2079,2206,544,701,396,2951,1215,668,1166,2022,1173,802,1232,704,879,79,6,90,423,1696,3421,2628,1000,925,904,1730,3,571,352,400,2,383,2152,382,3356,1348,0,3,0,788,0,3,484,1754,2747,481,1311,1185,1216,1815,1645,1522,3963,1248,2742,1593,9842,1108,298,4888,3013,2218,539,441,1005,353,848,333,0,0,224,486,2103,2818,305,646,13651,879,600,2894,37,329,1987,3786,2377,41,1134,714,1898,0,4484,3440,7064,580,776,1598,903,0,736,1302,866,674,680,3405,1954,1826,839,1058,2783,2354,1492,1607,1327,1553,5,1823,1656,1703,927,1559,1806,1189,1960,1225,1466,1035,6124,8073,0,367,631,0,12309,5392,0,523,664,1833,1773,712,861,2594,1795,1612,82,1252,1498,2562,1263,2778,1158,7445,1188,316,100,1005,456,755,729,1287,681,468,784,917,701,926,14785,1103,5927,1870,961,0,1281,1161,776,1961,990,658,2078,1508,1216,1111,178,0,128,854,524,452,531,575,1192,419,595,640,618,231,266,882,625,807,4541,1072,603,372,0,259,292,148,894,1763,878,2173,667,818,649,5158,1317,878,1929,9845,357,621,1745,1196,1607,639,343,405,0,530,649,440,891,1417,1309,939,476,459,432,333,432,874,644,391,3923,1441,2421,929,374,247,1252,3021,5122,377,1697,161,650,333,10795,621,229,1396,417,1438,390,283,167,1120,1061,20,163,516,390,198,283,337,633,2437,638,691,466,7459,2652,193,565,733,560,457,275,504,467,555,2,313,437,2077,191,896,20,50,1071,5013,0,0,0,0,4538,637,695,104,854,330,559,1420,701,666,362,1088,757,69,643,514,1310,573,499,1623,2508,1596,556,691,756,1048,603,1312,1593,0,432,324,791,319,225,2,537,417,347,728,9,648,191,1020,999,2129,1128,995,2095,0,17,451,775,141,668,11040,2259,570,275,2095,189,0,63,1414,718,194,499,950,224,108,4127,185,0,0,633,117,774,605,2567,10903,2304,1885,1189,2762,491,1543,1039,774,4596,1037,2021,1169,1148,295,1529,429,1762,1375,20,11572,561,7449,4774,2116,1462,594,700,906,868,0,711,1565,443,52,687,589,2606,1150,962,736,1006,746,292,840,562,766,1344,1115,851,1649,2153,348,393,737,1324,3589,1303,530,136,415,5222,1417,1723,2455,276,1012,2179,1350,400,2816,987,1362,341,642,56,358,1171,876,4131,774,783,822,4385,4629,2390,821,521,292,442,715,1167,0,358,1931,882,0,984,1137,1151,397,801,1013,1284,1756,1133,700,40,400,4991,731,3875,817,102,2671,189,2826,1056,2273,1173,2164,1507,2022,1973,1977,2219,1428,743,808,2411,1781,1125,1551,2415,4009,219,496,2274,2358,1019,1556,1151,1468,1553,684,847,1186,679,3037,258,2438,2200,0,168,6973,1695,2898,671,353,724,1191,496,301,611,211,649,1351,366,0,1108,875,1592,1318,540,869,899,412,1156,2944,4224,1888,184,3359,999,2125,1753,2360,702,530,1361,775,349,976,1311,1112,575,4973,15,455,774,101,3135,790,3021,254,745,1150,1399,504,1189,282,824,111,763,347,298,1174,1031,1256,1035,1301,336,1107,75,3783,444,23,1920,769,31,886,925,392,376,1293,480,1670,751,1415,488,545,516,912,1573,2905,1181,0,143,1392,820,470,621,786,2618,2643,1010,673,680,0,0,0,0,0,0,0,0,0,0,0,0,1319,387,1512,16,2465,1289,718,1945,527,717,611,884,823,856,945,2142,946,1632,1475,920,701,1202,6273,5584,133,267,2172,954,426,717,907,872,815,842,3731,651,1709,621,44,1488,2268,7836,1646,372,0,5340,1557,554,597,937,1142,2374,1496,986,780,1402,1644,1243,611,1098,3576,1497,630,1477,1574,904,1009,1072,1221,0,482,2018,6182,5377,5124,1526,1034,1810,455,1410,1380,653,698,920,489,560,2395,1463,2941,403,203,1624,522,949,1969,74,29224,11231,668,1009,419,722,1448,1106,11167,1392,4287,1217,906,4915,2685,2788,2792,1293,1144,641,434,2471,921,866,555,895,379,45,5034,1126,790,2894,4186,1298,0,0,1731,345,705,342,742,1087,945,329,691,392,327,1295,223,623,4334,1307,124,0,3993,2803,1879,1124,1529,918,523,1288,4069,1597,1040,374,761,288,334,464,1243,831,158,1149,533,315,1244,291,878,79,321,753,79,169,321,645,579,352,125,705,317,17,0,0,873,628,2626,711,1128,1413,868,4362,5620,1267,835,265,1621,1236,6770,0,11,63,2957,1484,584,453,1581,398,525,6645,1686,762,1306,71,1339,13360,470,0,851,182,960,709,385,383,83,280,751,222,701,104,437,1330,516,458,250,836,865,18377,14935,858,3741,815,631,1300,558,708,472,671,154,114,5,0,1003,1023,1351,693,739,732,1042,426,689,2180,1271,630,587,896,884,589,1180,100,1993,402,988,571,785,856,277,284,147,1810,871,1090,141,211,0,0,0,1731,482,2872,758,346,0,696,794,3767,584,5511,0,21,11,694,2232,319,2103,770,615,1458,3479,965,1334,718,2070,906,865,362,16,74,2797,735,737,1207,3221,182,6,0,1020,2883,2292,3052,7282,5333,806,1413,547,660,521,2170,415,3672,753,270,679,736,0,266,1141,576,1497,3920,10,6,741,2186,993,2160,80,1009,3228,982,5166,0,171,214,718,46,413,562,818,1761,1093,1544,2148,1360,928,0,656,140,436,1447,2456,1165,296,2642,1949,7988,622,605,654,1925,2429,3425,414,4674,2153,743,3347,1987,1724,9599,2849,808,2278,946,2131,1241,1635,376,2054,1007,1393,1627,2205,2131,2437,1385,824,1874,1773,2486,1172,1665,1650,348,1088,791,957,1367,1283,899,854,260,1201,11610,0,97,340,1082,595,1806,1177,5853,3073,977,73,992,7285,12790,0,56,204,20,689,1164,1580,1116,826,1280,2082,3264,1240,1140,633,853,1277,964,5130,1601,1555,535,1515,1614,740,1374,1691,3626,2670,2199,197,10911,0,8066,4231,215,1611,1240,1509,1447,446,1667,1362,772,767,211,492,69,1,21,793,8612,199,135,47,1479,1238,1747,117,758,1258,1250,1218,2283,989,2036,1456,1314,1136,703,935,5692,1830,4592,0,2849,0,100,182,325,3789,191,1196,2508,1494,4933,0,974,0,1035,1284,831,893,881,659,1553,614,388,1308,788,1246,1378,691,2249,259,2,0,0,150,1305,4138,1626,193,3835,2048,3006,636,166,122,1340,749,1141,458,320,257,2146,1746,413,452,629,606,1933,1434,410,847,520,361,3230,129,544,952,2804,739,868,3156,6121,162,382,963,1901,2132,1786,1869,0,684,4225,2413,707,669,305,843,0,481,3,1173,220,2443,1349,655,789,1314,1344,3909,35,2559,1204,2233,3635,1084,22,1539,747,49,2275,124,1877,4270,4456,0,0,0,0,0,0,0,0,0,0,0,4431,732,1691,2411,1514,2099,1659,1369,1013,669,1848,4572,2161,71,531,434,1796,1285,904,368,1850,535,647,1432,333,1530,1232,648,1049,345,304,429,313,1453,0,1520,0,511,38,0,610,1188,33,867,307,587,1134,380,738,277,795,515,537,476,0,0,865,1180,677,761,1203,401,4702,187,1461,2501,2305,3535,819,1273,511,538,2556,1457,1247,1227,574,749,183,857,788,2040,1763,942,1911,1521,3616,615,225,1275,1504,60,1592,1218,2872,0,680,892,1052,562,5,66,638,516,1631,1540,268,462,92,8,591,379,196,183,0,874,287,190,221,953,15,253,1110,1444,1452,927,643,14,1762,2827,2425,1006,822,2666,2607,464,338,2380,227,382,344,61,200,640,1290,0,104,1,2240,6618,9165,350,569,1347,544,242,0,954,833,13,939,627,277,711,782,1041,139,1095,690,1052,1530,405,1212,1118,2653,2532,3655,7652,3821,345,2053,4526,8409,10677,604,1436,534,0,706,2046,7863,97,1150,2501,556,4959,1271,7338,1451,1004,1195,1266,552,1705,1561,1331,339,1493,1611,1568,2511,2222,841,1444,260,186,563,4,14,822,872,3061,294,163,883,1312,1072,540,495,1046,647,1207,9095,8052,5387,8924,2951,2073,3207,2605,1596,3413,1351,949,3250,2,2742,1237,2310,3851,1903,1208,1703,395,2286,2689,2064,579,1666,1659,677,977,48,781,1120,1440,333,1156,2024,793,484,448,399,0,0,0,269,1405,130,2084,1395,1560,227,651,580,2696,0,35,20,595,1688,1034,148,638,516,460,942,247,1485,1392,759,584,110,519,546,527,3957,6390,1456,1497,1728,1420,776,1060,1355,697,831,1353,13884,50,1151,5143,0,29,73,11764,246,16270,768,891,1962,1022,404,1425,3064,18847,1767,136,27,35,1596,1242,130,367,733,367,1532,1,574,6624,4349,163,124,979,943,627,636,1501,1109,717,921,6564,1243,302,99,10486,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4055,3540,3,519,427,1227,0,500,856,1371,447,717,1663,1469,1645,500,1777,532,1364,2308,2684,909,548,0,1269,1094,3368,0,1043,3029,691,1252,890,1119,507,1164,184,311,60,489,509,96,0,0,0,3974,889,750,607,1417,3126,0,918,187,981,581,547,4684,2192,1657,0,0,1237,217,337,344,748,2467,458,1058,574,831,223,889,769,668,765,577,1170,479,1097,1376,3267,878,1231,1225,2369,542,3310,575,288,116,61,50,46,17,2501,3005,591,363,649,560,1266,570,975,552,479,1318,174,1053,294,853,34,315,360,413,1135,0,1022,1155,1122,844,457,549,891,617,409,981,454,1452,41,439,1697,321,0,888,1676,820,1120,606,124,1416,571,443,2567,693,533,668,920,632,37,1337,1108,1643,327,407,904,362,545,22,983,547,596,565,386,1307,629,2418,2382,1069,0,0,421,1277,1035,13467,3717,1973,1605,1350,2745,1839,1932,1506,2675,1948,1855,2156,2400,209,4265,2125,1923,1903,1638,2071,12212,900,785,863,2294,1765,4355,3298,18982,5118,490,79,1031,5,729,723,628,3012,208,1995,379,607,1128,1184,379,2026,918,6152,3999,410,2409,1954,625,665,518,240,995,854,532,18,0,0,461,515,674,0,567,135,2554,1914,124,675,396,13360,569,1662,572,1178,175,253,893,1445,3006,869,338,2789,2374,1600,5673,6177,3758,3923,657,2847,2225,6092,1935,1183,1372,8484,1652,1846,325,498,900,256,1007,1008,400,652,5113,292,7420,3318,344,1923,510,937,870,785,940,215,307,851,1910,460,2021,516,1497,634,188,503,2668,1332,14524,682,1166,700,560,2255,2475,892,2327,2285,565,87,775,603,267,256,106,689,326,243,1428,1607,4799,1667,636,570,610,880,630,502,796,1100,576,1997,1847,348,831,2281,1101,445,1112,418,56,620,10372,787,922,1169,619,876,527,2016,1355,423,1195,391,1200,726,95,581,0,0,1061,462,658,2326,516,979,1911,514,1516,245,9714,2570,420,439,717,639,28,804,580,690,1153,380,359,681,733,1083,2915,1155,1005,312,1092,690,953,775,438,704,930,325,350,136,1924,202,1256,576,141,172,3647,304,438,250,0,233,1143,187,304,104,534,1417,3078,113,1466,1860,0,3590,321,276,359,825,1197,1303,366,323,298,3129,248,1858,1252,291,917,323,900,2038,137,88,1964,2886,867,210,147,385,704,572,453,751,927,1195,418,695,378,518,940,51,474,1179,1613,1541,1379,520,1287,618,2531,2184,2393,1929,170,1663,1256,1357,1259,567,146,676,1677,1051,267,617,973,1160,394,636,52,570,51,1850,1743,5,0,1440,4874,2,869,702,3697,1533,1752,299,1499,650,684,1064,560,278,1222,1360,6390,5567,13836,810,4458,1383,3110,7732,522,56,1533,1268,6568,5229,2196,2389,2132,2589,673,3924,2114,569,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,198,0,0,1624,1238,149,517,1010,855,236,319,707,1668,4086,0,242,428,569,602,1077,540,713,1044,489,579,1181,2289,11492,0,0,643,3457,1036,100,0,0,1706,1932,647,1032,3650,1023,1781,837,1767,916,1083,2340,33,840,552,4730,160,209,275,388,1664,375,388,1035,2924,499,576,514,491,363,501,15,327,220,261,2128,1124,1783,1537,349,770,583,16,0,250,0,2370,376,1029,1017,1098,1102,1288,1522,1356,2417,1331,1731,1095,256,1268,1020,1036,713,6501,1341,1307,12967,661,310,2124,1556,636,1372,820,417,2404,859,1395,1330,1378,1267,953,1127,1711,1296,1358,1273,880,2133,670,973,1060,3970,933,2566,0,1630,4871,1606,0,0,648,0,0,1334,384,9534,7472,0,0,356,0,0,0,1781,4275,3654,2439,1619,486,1333,1444,562,1012,579,1717,143,801,1804,520,1351,547,879,886,780,1374,888,981,877,863,1149,719,2008,38,110,15,874,96,0,0,3446,2818,700,2810,0,176,48,234,1839,2730,1262,2648,1959,1591,1005,2262,904,781,1424,2588,4122,23,64,401,988,2564,455,1265,2434,754,464,1334,513,0,10,105,573,0,0,1239,803,594,299,1093,378,1147,271,12463,133,75,487,337,560,280,413,1457,1686,626,1046,530,1223,259,1085,476,668,248,3479,3273,12801,991,15,322,4084,409,2031,1220,3483,1064,807,160,1293,1195,0,499,1838,2638,2829,964,0,1130,747,1916,1296,521,389,930,690,227,517,774,566,45,2658,1205,3094,959,3127,6983,1192,149,790,306,1437,95,40,765,494,1626,1253,1602,907,75,473,1361,2301,2769,67,6068,2707,4668,1983,3679,1461,1120,2434,643,1624,2251,0,622,326,1079,1241,126,2023,3376,225,772,1714,3329,3091,2937,968,1299,1858,1269,570,1508,1145,280,375,5300,1190,769,258,100,1141,110,5871,4185,208,1085,3187,1259,166,2226,973,895,4482,6502,518,3163,2299,2022,1464,229,444,13678,900,720,570,256,136,1931,141,520,384,471,367,904,400,2871,665,1082,325,2005,309,553,1286,324,2125,660,337,242,2591,2056,131,3307,6518,1266,1434,797,639,262,713,828,1206,4932,171,858,2198,461,84,2091,494,642,1076,1326,64,919,1528,1147,1152,413,335,1264,373,242,2168,1916,184,1568,1943,3168,2723,562,461,627,831,1420,580,924,817,0,199,423,581,1317,1153,1141,665,342,780,511,856,433,188,853,501,403,641,610,310,524,357,969,5384,407,7175,9565,1694,4414,528,2986,202,3070,1781,585,221,492,17,639,502,630,1667,146,16,0,260,0,864,901,100,77,1507,1366,531,993,347,397,4742,1055,7710,2650,693,2626,4483,132,9511,220,504,1516,868,992,186,932,565,344,426,0,507,771,0,335,0,779,753,896,0,2588,0,0,308,35,120,536,565,850,1382,0,521,2289,463,210,335,542,3411,1600,11405,739,1646,3317,0,0,0,300,146,107,139,795,1475,35,646,420,91,175,1472,0,0,2248,1286,161,1192,1437,570,1149,842,948,0,207,763,474,586,715,1467,74,0,0,0,0,0,0,0,0,0,0,0,1289,361,583,309,2031,508,494,886,989,58,0,2715,1853,2009,3392,563,0,0,0,835,888,678,458,716,683,405,1910,1090,634,1014,261,1292,1361,1243,0,0,719,363,573,1057,407,1590,366,883,667,747,622,722,45,482,2494,1218,454,806,449,242,2110,701,655,754,430,0,0,1759,1042,697,521,408,604,2044,684,852,3166,65,0,0,836,1208,754,737,745,797,1278,1382,286,568,787,930,818,395,553,1176,467,452,169,0,0,0,41,994,2577,681,0,3421,1525,3064,5,82,69,0,2599,8442,162,1255,2636,1049,870,3481,910,1825,571,485,789,1053,698,24,0,0,0,0,0,0,0,0,0,5034,1552,631,816,731,1139,1201,2847,1022,616,19,212,596,59,1047,208,25,6,0,102,212,531,967,1796,659,185,437,1122,1628,697,1958,794,1348,1889,403,412,183,0,1091,1190,376,810,458,560,378,753,1232,396,1086,828,1293,1331,972,699,1467,1417,2907,4199,850,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,9803,855,986,1067,0,2171,75,93,1451,2752,1118,6547,1328,257,137,264,255,65,1942,323,5650,2669,0,5912,1514,7661,179,5711,1229,2595,3181,607,327,0,0,1291,652,1318,1009,4579,530,657,87,975,1495,0,2553,88,0,255,2842,1585,146,2117,335,54,1792,1179,221,1360,2805,4610,15828,1056,172,12,504,596,1484,0,885,1525,1011,735,486,3001,5427,3346,2991,1972,812,626,154,0,1580,265,1,1496,1218,924,1540,428,1672,2132,1921,1185,1226,1912,1754,728,1687,1987,1335,1345,1067,2004,1624,3287,2500,1333,919,2407,0,208,318,543,378,1325,1077,1087,993,1121,773,569,1045,1085,688,2024,203,822,3164,3163,1319,472,175,1328,965,1088,325,871,456,1291,1382,2086,2695,207,357,2325,8610,3759,3217,158,221,37,221,592,1150,750,521,948,874,1640,689,169,941,1022,4524,666,1281,1200,737,1183,3073,413,629,1045,761,2216,772,1249,2311,10010,1395,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0";
String[] orig = o1.split(",");
String[] real = r1.split(",");
for (int i=0; i<orig.length; i++) {
int d = (Integer.valueOf(orig[i]) - Integer.valueOf(real[i]));
if (Math.abs(d) > 1000) {
System.out.println(i + " : " + d);
}
}
}
}