NCBI C++ Toolkit Cross Reference

  C++/src/objtools/validator/valid_biosource.cpp


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342
/* $Id: valid_biosource.cpp 64852 2014-10-16 17:56:39Z kans $ * =========================================================================== * * PUBLIC DOMAIN NOTICE * National Center for Biotechnology Information * * This software/database is a "United States Government Work" under the * terms of the United States Copyright Act. It was written as part of * the author's official duties as a United States Government employee and * thus cannot be copyrighted. This software/database is freely available * to the public for use. The National Library of Medicine and the U.S. * Government have not placed any restriction on its use or reproduction. * * Although all reasonable efforts have been taken to ensure the accuracy * and reliability of the software and data, the NLM and the U.S. * Government do not and cannot warrant the performance or results that * may be obtained by using this software or data. The NLM and the U.S. * Government disclaim all warranties, express or implied, including * warranties of performance, merchantability or fitness for any particular * purpose. * * Please cite the author in any work or product based on this material. * * =========================================================================== * * Author: Jonathan Kans, Clifford Clausen, Aaron Ucko, Mati Shomrat, .... * * File Description: * Implementation of private parts of the validator * ....... * */ #include <ncbi_pch.hpp> #include <corelib/ncbistd.hpp> #include <corelib/ncbistr.hpp> #include <corelib/ncbiapp.hpp> #include <objmgr/object_manager.hpp> #include <objtools/validator/validatorp.hpp> #include <objtools/validator/utilities.hpp> #include <serial/iterator.hpp> #include <serial/enumvalues.hpp> #include <objects/general/Dbtag.hpp> #include <objects/general/Person_id.hpp> #include <objects/general/Name_std.hpp> #include <objects/general/User_object.hpp> #include <objects/general/User_field.hpp> #include <objects/seqalign/Seq_align.hpp> #include <objects/seqset/Bioseq_set.hpp> #include <objects/seqset/Seq_entry.hpp> #include <objects/seq/Bioseq.hpp> #include <objects/seq/Seq_annot.hpp> #include <objects/seq/Seqdesc.hpp> #include <objects/seq/Seq_descr.hpp> #include <objects/seq/Pubdesc.hpp> #include <objects/seq/MolInfo.hpp> #include <objects/seqfeat/BioSource.hpp> #include <objects/seqfeat/OrgMod.hpp> #include <objects/seqfeat/OrgName.hpp> #include <objects/seqfeat/Org_ref.hpp> #include <objects/seqfeat/Seq_feat.hpp> #include <objects/seqfeat/SubSource.hpp> #include <objects/seqloc/Seq_loc.hpp> #include <objects/seqloc/Seq_interval.hpp> #include <objects/seqloc/Seq_point.hpp> #include <objects/seqloc/Textseq_id.hpp> #include <objects/seqres/Seq_graph.hpp> #include <objects/submit/Seq_submit.hpp> #include <objects/submit/Submit_block.hpp> #include <objmgr/bioseq_ci.hpp> #include <objmgr/seqdesc_ci.hpp> #include <objmgr/graph_ci.hpp> #include <objmgr/seq_annot_ci.hpp> #include <objmgr/util/feature.hpp> #include <objmgr/util/sequence.hpp> #include <objmgr/feat_ci.hpp> #include <objmgr/align_ci.hpp> #include <objmgr/seq_vector.hpp> #include <objmgr/scope.hpp> #include <objects/pub/Pub.hpp> #include <objects/pub/Pub_equiv.hpp> #include <objects/biblio/Author.hpp> #include <objects/biblio/Auth_list.hpp> #include <objects/biblio/Cit_art.hpp> #include <objects/biblio/Cit_book.hpp> #include <objects/biblio/Cit_gen.hpp> #include <objects/biblio/Cit_jour.hpp> #include <objects/biblio/Cit_let.hpp> #include <objects/biblio/Cit_proc.hpp> #include <objects/biblio/Cit_sub.hpp> #include <objects/biblio/PubMedId.hpp> #include <objects/biblio/PubStatus.hpp> #include <objects/biblio/Title.hpp> #include <objects/biblio/Imprint.hpp> #include <objects/biblio/Affil.hpp> #include <objects/misc/sequence_macros.hpp> #include <objects/taxon3/taxon3.hpp> #include <objects/taxon3/Taxon3_reply.hpp> #include <objtools/error_codes.hpp> #include <util/sgml_entity.hpp> #include <util/line_reader.hpp> #include <util/util_misc.hpp> #include <algorithm> #include <math.h> #include <serial/iterator.hpp> #define NCBI_USE_ERRCODE_X Objtools_Validator BEGIN_NCBI_SCOPE BEGIN_SCOPE(objects) BEGIN_SCOPE(validator) using namespace sequence; auto_ptr<CTextFsa> CValidError_imp::m_SourceQualTags; class CCachedTaxon3 { public: typedef map<string, CRef<CT3Reply> > CCachedReplyMap; void Init() { if (m_taxon.get() == 0) { m_taxon.reset(new CTaxon3); m_taxon->Init(); m_cache.reset(new CCachedReplyMap); } } CRef<CTaxon3_reply> SendOrgRefList(const vector< CRef<COrg_ref> >& query) { if (!m_enable_caching) return m_taxon->SendOrgRefList(query); CRef<CTaxon3_reply> result(new CTaxon3_reply); ITERATE (vector<CRef< COrg_ref> >, it, query) { string id; //CNcbiOstrstream ostream; //ostream << MSerial_AsnText << **it << ends; //id = ostream.str() NStr::IntToString(id, (**it).GetTaxId()); if ((**it).IsSetTaxname()) id += (**it).GetTaxname(); CRef<CT3Reply>& reply = (*m_cache)[id]; if (/*id < 1 ||*/ reply.Empty()) { CTaxon3_request request; CRef<CT3Request> rq(new CT3Request); CRef<COrg_ref> org(new COrg_ref); org->Assign(**it); rq->SetOrg(*org); request.SetRequest().push_back(rq); CRef<CTaxon3_reply> result = m_taxon->SendRequest (request); reply = *result->SetReply().begin(); } else { #ifdef _DEBUG //cerr << "Using cache for:" << id << endl; #endif } result->SetReply().push_back(reply); } return result; } protected: static auto_ptr<CTaxon3> m_taxon; static auto_ptr<CCachedReplyMap> m_cache; static bool m_enable_caching; }; bool CCachedTaxon3::m_enable_caching = true; auto_ptr<CTaxon3> CCachedTaxon3::m_taxon; auto_ptr<CCachedTaxon3::CCachedReplyMap> CCachedTaxon3::m_cache; #define CCachedTaxon CCachedTaxon3 static bool s_UnbalancedParentheses (string str) { if (NStr::IsBlank(str)) { return false; } int par = 0, bkt = 0; string::iterator it = str.begin(); while (it != str.end()) { if (*it == '(') { ++par; } else if (*it == ')') { --par; if (par < 0) { return true; } } else if (*it == '[') { ++bkt; } else if (*it == ']') { --bkt; if (bkt < 0) { return true ; } } ++it; } if (par > 0 || bkt > 0) { return true; } else { return false; } } #if 0 const char* sm_ValidModifiedPrimerBases[] = { "ac4c", "chm5u", "cm", "cmnm5s2u", "cmnm5u", "d", "fm", "gal q", "gm", "i", "i6a", "m1a", "m1f", "m1g", "m1i", "m22g", "m2a", "m2g", "m3c", "m4c", "m5c", "m6a", "m7g", "mam5u", "mam5s2u", "man q", "mcm5s2u", "mcm5u", "mo5u", "ms2i6a", "ms2t6a", "mt6a", "mv", "o5u", "osyw", "p", "q", "s2c", "s2t", "s2u", "s4u", "t", "t6a", "tm", "um", "yw", "x", "OTHER" }; static bool s_IsValidPrimerSequence (string str, char& bad_ch) { bad_ch = 0; if (NStr::IsBlank(str)) { return false; } if (NStr::Find(str, ",") == string::npos) { if (NStr::Find(str, "(") != string::npos || NStr::Find(str, ")") != string::npos) { return false; } } else { if (!NStr::StartsWith(str, "(") || !NStr::EndsWith(str, ")")) { return false; } } if (NStr::Find(str, ";") != string::npos) { return false; } const char* *list_begin = sm_ValidModifiedPrimerBases; const char* *list_end = &(sm_ValidModifiedPrimerBases[sizeof(sm_ValidModifiedPrimerBases) / sizeof(const char*)]); size_t pos = 0; string::iterator sit = str.begin(); while (sit != str.end()) { if (*sit == '<') { size_t pos2 = NStr::Find (str, ">", pos + 1); if (pos2 == string::npos) { bad_ch = '<'; return false; } string match = str.substr(pos + 1, pos2 - pos - 1); if (find(list_begin, list_end, match) == list_end) { bad_ch = '<'; return false; } sit += pos2 - pos + 1; pos = pos2 + 1; } else { if (*sit != '(' && *sit != ')' && *sit != ',' && *sit != ':') { if (!isalpha (*sit)) { bad_ch = *sit; return false; } char ch = toupper(*sit); if (strchr ("ABCDGHKMNRSTVWY", ch) == NULL) { bad_ch = tolower (ch); return false; } } ++sit; ++pos; } } return true; } #endif bool CValidError_imp::IsSyntheticConstruct (const CBioSource& src) { if (!src.IsSetOrg()) { return false; } if (src.GetOrg().IsSetTaxname()) { const string & taxname = src.GetOrg().GetTaxname(); if (NStr::EqualNocase(taxname, "synthetic construct") || NStr::FindNoCase(taxname, "vector") != string::npos) { return true; } } if (src.GetOrg().IsSetLineage()) { if (NStr::FindNoCase(src.GetOrg().GetLineage(), "artificial sequences") != string::npos) { return true; } } if (src.GetOrg().IsSetOrgname() && src.GetOrg().GetOrgname().IsSetDiv() && NStr::EqualNocase(src.GetOrg().GetOrgname().GetDiv(), "syn")) { return true; } return false; } bool CValidError_imp::IsArtificial (const CBioSource& src) { if (src.IsSetOrigin() && (src.GetOrigin() == CBioSource::eOrigin_artificial)) { return true; } return false; } bool CValidError_imp::IsOrganelle (int genome) { bool rval = false; switch (genome) { case CBioSource::eGenome_chloroplast: case CBioSource::eGenome_chromoplast: case CBioSource::eGenome_kinetoplast: case CBioSource::eGenome_mitochondrion: case CBioSource::eGenome_cyanelle: case CBioSource::eGenome_nucleomorph: case CBioSource::eGenome_apicoplast: case CBioSource::eGenome_leucoplast: case CBioSource::eGenome_proplastid: case CBioSource::eGenome_hydrogenosome: case CBioSource::eGenome_chromatophore: rval = true; break; default: rval = false; break; } return rval; } bool CValidError_imp::IsOrganelle (CBioseq_Handle seq) { bool rval = false; CSeqdesc_CI sd(seq, CSeqdesc::e_Source); if (sd && sd->GetSource().IsSetGenome() && IsOrganelle(sd->GetSource().GetGenome())) { rval = true; } return rval; } void CValidError_imp::ValidateLatLonCountry (string countryname, string lat_lon, const CSerialObject& obj, const CSeq_entry *ctx) { CSubSource::ELatLonCountryErr errcode; string error = CSubSource::ValidateLatLonCountry(countryname, lat_lon, IsLatLonCheckState(), errcode); if (!NStr::IsBlank(error)) { switch (errcode) { case CSubSource::eLatLonCountryErr_Country: PostObjErr (eDiag_Info, eErr_SEQ_DESCR_LatLonCountry, error, obj, ctx); break; case CSubSource::eLatLonCountryErr_State: PostObjErr (eDiag_Info, eErr_SEQ_DESCR_LatLonState, error, obj, ctx); break; case CSubSource::eLatLonCountryErr_Water: PostObjErr (eDiag_Info, eErr_SEQ_DESCR_LatLonWater, error, obj, ctx); break; case CSubSource::eLatLonCountryErr_Value: PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_LatLonValue, error, obj, ctx); break; default: break; } } } /* note - special case for sex because it prevents a different message from being displayed, do not list here */ static const CSubSource::ESubtype sUnexpectedViralSubSourceQualifiers[] = { CSubSource::eSubtype_cell_line, CSubSource::eSubtype_cell_type, CSubSource::eSubtype_tissue_type, CSubSource::eSubtype_dev_stage }; static const int sNumUnexpectedViralSubSourceQualifiers = sizeof (sUnexpectedViralSubSourceQualifiers) / sizeof (CSubSource::TSubtype); static bool IsUnexpectedViralSubSourceQualifier (CSubSource::TSubtype subtype) { int i; bool rval = false; for (i = 0; i < sNumUnexpectedViralSubSourceQualifiers && !rval; i++) { if (subtype == sUnexpectedViralSubSourceQualifiers[i]) { rval = true; } } return rval; } static const COrgMod::TSubtype sUnexpectedViralOrgModQualifiers[] = { COrgMod::eSubtype_breed, COrgMod::eSubtype_cultivar, COrgMod::eSubtype_specimen_voucher }; static const int sNumUnexpectedViralOrgModQualifiers = sizeof (sUnexpectedViralOrgModQualifiers) / sizeof (COrgMod::TSubtype); static bool IsUnexpectedViralOrgModQualifier (COrgMod::TSubtype subtype) { int i; bool rval = false; for (i = 0; i < sNumUnexpectedViralOrgModQualifiers && !rval; i++) { if (subtype == sUnexpectedViralOrgModQualifiers[i]) { rval = true; } } return rval; } CBioSourceKind& CBioSourceKind::operator=(const CBioSource& bsrc) { SetNotGood(); if (bsrc.IsSetGenome()) { CBioSource::EGenome genome = (CBioSource::EGenome) bsrc.GetGenome(); switch (genome) { // case CBioSource::eGenome_genomic: break; // case CBioSource::eGenome_plastid: break; // case CBioSource::eGenome_macronuclear: break; // case CBioSource::eGenome_extrachrom: break; // case CBioSource::eGenome_plasmid: break; // case CBioSource::eGenome_transposon: break; // case CBioSource::eGenome_insertion_seq: break; // case CBioSource::eGenome_proviral: break; // case CBioSource::eGenome_virion: break; // case CBioSource::eGenome_endogenous_virus: break; case CBioSource::eGenome_chloroplast: case CBioSource::eGenome_chromoplast: case CBioSource::eGenome_kinetoplast: case CBioSource::eGenome_mitochondrion: case CBioSource::eGenome_cyanelle: case CBioSource::eGenome_nucleomorph: case CBioSource::eGenome_apicoplast: case CBioSource::eGenome_leucoplast: case CBioSource::eGenome_proplastid: case CBioSource::eGenome_hydrogenosome: case CBioSource::eGenome_chromatophore: m_organelle = true; break; case CBioSource::eGenome_chromosome: m_eukaryote = true; break; // case CBioSource::eGenome_chromatophore: break; default: break; } } else if (bsrc.IsSetLineage()) { const string& lineage = bsrc.GetLineage(); if (NStr::StartsWith(lineage, "Eukaryota")) m_eukaryote = true; else if (NStr::StartsWith(lineage, "Bacteria")) m_bacteria = true; else if (NStr::StartsWith(lineage, "Archaea")) m_archaea = true; //else // NCBI_ASSERT(0, "Not fully implemented switch statement"); } return *this; } void CValidError_imp::ValidateBioSource (const CBioSource& bsrc, const CSerialObject& obj, const CSeq_entry *ctx) { if ( !bsrc.CanGetOrg() ) { PostObjErr(eDiag_Error, eErr_SEQ_DESCR_NoOrgFound, "No organism has been applied to this Bioseq. Other qualifiers may exist.", obj, ctx); return; } const COrg_ref& orgref = bsrc.GetOrg(); // validate legal locations. if ( bsrc.GetGenome() == CBioSource::eGenome_transposon || bsrc.GetGenome() == CBioSource::eGenome_insertion_seq ) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_ObsoleteSourceLocation, "Transposon and insertion sequence are no longer legal locations", obj, ctx); } if (IsIndexerVersion() && bsrc.IsSetGenome() && bsrc.GetGenome() == CBioSource::eGenome_chromosome) { PostObjErr(eDiag_Info, eErr_SEQ_DESCR_ChromosomeLocation, "INDEXER_ONLY - BioSource location is chromosome", obj, ctx); } bool isViral = false, isAnimal = false, isPlant = false, isBacteria = false, isArchaea = false, isFungal = false; if (bsrc.IsSetLineage()) { string lineage = bsrc.GetLineage(); if (NStr::StartsWith(lineage, "Viruses; ", NStr::eNocase)) { isViral = true; } else if (NStr::StartsWith(lineage, "Eukaryota; Metazoa; ", NStr::eNocase)) { isAnimal = true; } else if (NStr::StartsWith(lineage, "Eukaryota; Viridiplantae; Streptophyta; Embryophyta; ", NStr::eNocase) || NStr::StartsWith(lineage, "Eukaryota; Rhodophyta; ", NStr::eNocase) || NStr::StartsWith(lineage, "Eukaryota; stramenopiles; Phaeophyceae; ", NStr::eNocase)) { isPlant = true; } else if (NStr::StartsWith(lineage, "Bacteria; ", NStr::eNocase)) { isBacteria = true; } else if (NStr::StartsWith(lineage, "Archaea; ", NStr::eNocase)) { isArchaea = true; } else if (NStr::StartsWith(lineage, "Eukaryota; Fungi; ", NStr::eNocase)) { isFungal = true; } } int chrom_count = 0; bool chrom_conflict = false; int country_count = 0, lat_lon_count = 0, altitude_count = 0, collection_date_count = 0; int fwd_primer_seq_count = 0, rev_primer_seq_count = 0; int fwd_primer_name_count = 0, rev_primer_name_count = 0; CPCRSetList pcr_set_list; const CSubSource *chromosome = 0; string countryname; string lat_lon; double lat_value = 0.0, lon_value = 0.0; bool germline = false; bool rearranged = false; bool transgenic = false; bool env_sample = false; bool metagenomic = false; bool sex = false; bool mating_type = false; bool iso_source = false; bool has_plasmid_name = false; int collected_by_count = 0; int identified_by_count = 0; int segment_count = 0; FOR_EACH_SUBSOURCE_ON_BIOSOURCE (ssit, bsrc) { ValidateSubSource (**ssit, obj, ctx); if (!(*ssit)->IsSetSubtype()) { continue; } if ((*ssit)->IsSetName()) { string str = (*ssit)->GetName(); if (NStr::Equal (str, "N/A") || NStr::Equal (str, "Missing")) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, "Subsource name should not be " + str, obj, ctx); } } int subtype = (*ssit)->GetSubtype(); switch ( subtype ) { case CSubSource::eSubtype_country: ++country_count; if (!NStr::IsBlank (countryname)) { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_BadCountryCode, "Multiple country names on BioSource", obj, ctx); } countryname = (**ssit).GetName(); break; case CSubSource::eSubtype_lat_lon: if ((*ssit)->IsSetName()) { lat_lon = (*ssit)->GetName(); bool format_correct = false, lat_in_range = false, lon_in_range = false, precision_correct = false; CSubSource::IsCorrectLatLonFormat (lat_lon, format_correct, precision_correct, lat_in_range, lon_in_range, lat_value, lon_value); } ++lat_lon_count; if (lat_lon_count > 1) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_LatLonProblem, "Multiple lat_lon on BioSource", obj, ctx); } break; case CSubSource::eSubtype_altitude: ++altitude_count; if (!(*ssit)->IsSetName() || !CSubSource::IsAltitudeValid ((*ssit)->GetName())) { string val = ""; if ((*ssit)->IsSetName()) { val = (*ssit)->GetName(); } PostObjErr(eDiag_Info, eErr_SEQ_DESCR_BadAltitude, "bad altitude qualifier value " + val, obj, ctx); } break; case CSubSource::eSubtype_chromosome: ++chrom_count; if ( chromosome != 0 ) { if ( NStr::CompareNocase((**ssit).GetName(), chromosome->GetName()) != 0) { chrom_conflict = true; } } else { chromosome = ssit->GetPointer(); } break; case CSubSource::eSubtype_fwd_primer_name: if ((*ssit)->IsSetName()) { pcr_set_list.AddFwdName((*ssit)->GetName()); } ++fwd_primer_name_count; break; case CSubSource::eSubtype_rev_primer_name: if ((*ssit)->IsSetName()) { pcr_set_list.AddRevName((*ssit)->GetName()); } ++rev_primer_name_count; break; case CSubSource::eSubtype_fwd_primer_seq: if ((*ssit)->IsSetName()) { pcr_set_list.AddFwdSeq((*ssit)->GetName()); } ++fwd_primer_seq_count; break; case CSubSource::eSubtype_rev_primer_seq: if ((*ssit)->IsSetName()) { pcr_set_list.AddRevSeq((*ssit)->GetName()); } ++rev_primer_seq_count; break; case CSubSource::eSubtype_transposon_name: case CSubSource::eSubtype_insertion_seq_name: break; case 0: break; case CSubSource::eSubtype_other: break; case CSubSource::eSubtype_germline: germline = true; break; case CSubSource::eSubtype_rearranged: rearranged = true; break; case CSubSource::eSubtype_transgenic: transgenic = true; break; case CSubSource::eSubtype_metagenomic: metagenomic = true; break; case CSubSource::eSubtype_environmental_sample: env_sample = true; break; case CSubSource::eSubtype_isolation_source: iso_source = true; break; case CSubSource::eSubtype_sex: { sex = true; EDiagSev sev = eDiag_Warning; if (IsGpipe() && IsGenomic()) { sev = eDiag_Error; } if (isAnimal || isPlant) { /* always allow /sex, but now check values */ const string str = (*ssit)->GetName(); if (! CSubSource::IsValidSexQualifierValue(str)) { PostObjErr(eDiag_Error, eErr_SEQ_DESCR_BioSourceInconsistency, "Invalid value (" + str + ") for /sex qualifier", obj, ctx); } } else if (isViral) { PostObjErr(sev, eErr_SEQ_DESCR_BioSourceInconsistency, "Virus has unexpected Sex qualifier", obj, ctx); } else if (isBacteria || isArchaea || isFungal) { PostObjErr(sev, eErr_SEQ_DESCR_BioSourceInconsistency, "Unexpected use of /sex qualifier", obj, ctx); } else { const string str = (*ssit)->GetName(); if (! CSubSource::IsValidSexQualifierValue(str)) { // otherwise values are restricted to specific list PostObjErr(eDiag_Error, eErr_SEQ_DESCR_BioSourceInconsistency, "Invalid value (" + str + ") for /sex qualifier", obj, ctx); } } } break; case CSubSource::eSubtype_mating_type: mating_type = true; if (isAnimal || isPlant || isViral) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, "Unexpected use of /mating_type qualifier", obj, ctx); } else if (CSubSource::IsValidSexQualifierValue((*ssit)->GetName())) { // complain if one of the values that should go in /sex PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, "Unexpected use of /mating_type qualifier", obj, ctx); } break; case CSubSource::eSubtype_plasmid_name: if (!bsrc.IsSetGenome() || bsrc.GetGenome() != CBioSource::eGenome_plasmid) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, "Plasmid subsource but not plasmid location", obj, ctx); } has_plasmid_name = true; break; case CSubSource::eSubtype_plastid_name: { if ((*ssit)->IsSetName()) { CBioSource::TGenome genome = CBioSource::eGenome_unknown; if (bsrc.IsSetGenome()) { genome = bsrc.GetGenome(); } const string& subname = ((*ssit)->GetName()); CBioSource::EGenome genome_from_name = CBioSource::GetGenomeByOrganelle (subname, NStr::eCase, false); if (genome_from_name == CBioSource::eGenome_chloroplast || genome_from_name == CBioSource::eGenome_chromoplast || genome_from_name == CBioSource::eGenome_kinetoplast || genome_from_name == CBioSource::eGenome_plastid || genome_from_name == CBioSource::eGenome_apicoplast || genome_from_name == CBioSource::eGenome_leucoplast || genome_from_name == CBioSource::eGenome_proplastid || genome_from_name == CBioSource::eGenome_chromatophore) { if (genome_from_name != genome) { string val_name = CBioSource::GetOrganelleByGenome(genome_from_name); if (NStr::StartsWith(val_name, "plastid:")) { val_name = val_name.substr(8); } PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, "Plastid name subsource " + val_name + " but not " + val_name + " location", obj, ctx); } } else { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, "Plastid name subsource contains unrecognized value", obj, ctx); } } } break; case CSubSource::eSubtype_frequency: break; case CSubSource::eSubtype_collection_date: ++collection_date_count; break; case CSubSource::eSubtype_collected_by: ++collected_by_count; break; case CSubSource::eSubtype_identified_by: ++identified_by_count; break; case CSubSource::eSubtype_segment: ++segment_count; break; case CSubSource::eSubtype_cell_line: if ((*ssit)->IsSetName() && orgref.IsSetTaxname()) { string warning = CSubSource::CheckCellLine((*ssit)->GetName(), orgref.GetTaxname()); if (!NStr::IsBlank(warning)) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_SuspectedContaminatedCellLine, warning, obj, ctx); } } break; default: break; } if (isViral && IsUnexpectedViralSubSourceQualifier (subtype)) { string subname = CSubSource::GetSubtypeName(subtype); if (subname.length() > 0) { subname[0] = toupper(subname[0]); } PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, "Virus has unexpected " + subname + " qualifier", obj, ctx); } } if ( germline && rearranged ) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, "Germline and rearranged should not both be present", obj, ctx); } if (transgenic && env_sample) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, "Transgenic and environmental sample should not both be present", obj, ctx); } if (metagenomic && (! env_sample)) { PostObjErr(eDiag_Critical, eErr_SEQ_DESCR_BioSourceInconsistency, "Metagenomic should also have environmental sample annotated", obj, ctx); } if (sex && mating_type) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, "Sex and mating type should not both be present", obj, ctx); } if (bsrc.IsSetGenome() && bsrc.GetGenome() == CBioSource::eGenome_plasmid && !has_plasmid_name) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, "Plasmid location set but plasmid name missing. Add a plasmid source modifier with the plasmid name. Use unnamed if the name is not known.", obj, ctx); } if ( chrom_count > 1 ) { string msg = chrom_conflict ? "Multiple conflicting chromosome qualifiers" : "Multiple identical chromosome qualifiers"; PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_MultipleChromosomes, msg, obj, ctx); } if (country_count > 1) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_MultipleSourceQualifiers, "Multiple country qualifiers present", obj, ctx); } if (lat_lon_count > 1) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_MultipleSourceQualifiers, "Multiple lat_lon qualifiers present", obj, ctx); } if (altitude_count > 1) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_MultipleSourceQualifiers, "Multiple altitude qualifiers present", obj, ctx); } if (fwd_primer_seq_count > 1) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_MultipleSourceQualifiers, "Multiple fwd_primer_seq qualifiers present", obj, ctx); } if (rev_primer_seq_count > 1) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_MultipleSourceQualifiers, "Multiple rev_primer_seq qualifiers present", obj, ctx); } if (fwd_primer_name_count > 1) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_MultipleSourceQualifiers, "Multiple fwd_primer_name qualifiers present", obj, ctx); } if (rev_primer_name_count > 1) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_MultipleSourceQualifiers, "Multiple rev_primer_name qualifiers present", obj, ctx); } if (collection_date_count > 1) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_MultipleSourceQualifiers, "Multiple collection_date qualifiers present", obj, ctx); } if (collected_by_count > 1) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_MultipleSourceQualifiers, "Multiple collected_by qualifiers present", obj, ctx); } if (identified_by_count > 1) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_MultipleSourceQualifiers, "Multiple identified_by qualifiers present", obj, ctx); } if (segment_count > 1) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_MultipleSourceQualifiers, "Multiple segment qualifiers present", obj, ctx); } if ((fwd_primer_seq_count > 0 && rev_primer_seq_count == 0) || (fwd_primer_seq_count == 0 && rev_primer_seq_count > 0)) { if (fwd_primer_name_count == 0 && rev_primer_name_count == 0) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BadPCRPrimerSequence, "PCR primer does not have both sequences", obj, ctx); } } if (!pcr_set_list.AreSetsUnique()) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_DuplicatePCRPrimerSequence, "PCR primer sequence has duplicates", obj, ctx); } // check that country and lat_lon are compatible ValidateLatLonCountry(countryname, lat_lon, obj, ctx); // validates orgref in the context of lineage if ( !orgref.IsSetOrgname() || !orgref.GetOrgname().IsSetLineage() || NStr::IsBlank(orgref.GetOrgname().GetLineage())) { if (IsIndexerVersion()) { EDiagSev sev = eDiag_Error; if (IsRefSeq()) { FOR_EACH_DBXREF_ON_ORGREF(it, orgref) { if ((*it)->IsSetDb() && NStr::EqualNocase((*it)->GetDb(), "taxon")) { sev = eDiag_Critical; break; } } } if (IsEmbl() || IsDdbj()) { sev = eDiag_Warning; } if (! IsWP()) { PostObjErr(sev, eErr_SEQ_DESCR_MissingLineage, "No lineage for this BioSource.", obj, ctx); } } } else { const COrgName& orgname = orgref.GetOrgname(); const string& lineage = orgname.GetLineage(); if ( bsrc.GetGenome() == CBioSource::eGenome_kinetoplast ) { if ( lineage.find("Kinetoplastida") == string::npos ) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BadOrganelle, "Only Kinetoplastida have kinetoplasts", obj, ctx); } } else if ( bsrc.GetGenome() == CBioSource::eGenome_nucleomorph ) { if ( lineage.find("Chlorarachniophyceae") == string::npos && lineage.find("Cryptophyta") == string::npos ) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BadOrganelle, "Only Chlorarachniophyceae and Cryptophyta have nucleomorphs", obj, ctx); } } else if ( bsrc.GetGenome() == CBioSource::eGenome_macronuclear) { if ( lineage.find("Ciliophora") == string::npos ) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BadOrganelle, "Only Ciliophora have macronuclear locations", obj, ctx); } } if (orgname.IsSetDiv()) { const string& div = orgname.GetDiv(); if ((NStr::EqualCase(div, "BCT") || NStr::EqualCase(div, "VRL")) && bsrc.GetGenome() != CBioSource::eGenome_unknown && bsrc.GetGenome() != CBioSource::eGenome_genomic && bsrc.GetGenome() != CBioSource::eGenome_plasmid && bsrc.GetGenome() != CBioSource::eGenome_chromosome) { if (NStr::EqualCase(div, "VRL") && bsrc.GetGenome() == CBioSource::eGenome_proviral) { // it's ok } else { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, "Bacterial or viral source should not have organelle location", obj, ctx); } } else if (NStr::EqualCase(div, "ENV") && !env_sample) { PostObjErr(eDiag_Error, eErr_SEQ_DESCR_BioSourceInconsistency, "BioSource with ENV division is missing environmental sample subsource", obj, ctx); } } if (!metagenomic && NStr::FindNoCase(lineage, "metagenomes") != string::npos) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, "If metagenomes appears in lineage, BioSource should have metagenomic qualifier", obj, ctx); } } // look for conflicts in orgmods, also look for unexpected viral qualifiers bool specific_host = false; FOR_EACH_ORGMOD_ON_ORGREF (it, orgref) { if (!(*it)->IsSetSubtype()) { continue; } COrgMod::TSubtype subtype = (*it)->GetSubtype(); if (subtype == COrgMod::eSubtype_nat_host) { specific_host = true; } else if (subtype == COrgMod::eSubtype_strain) { if (env_sample) { PostObjErr(eDiag_Error, eErr_SEQ_DESCR_BioSourceInconsistency, "Strain should not be present in an environmental sample", obj, ctx); } } else if (subtype == COrgMod::eSubtype_metagenome_source) { if (!metagenomic) { PostObjErr(eDiag_Error, eErr_SEQ_DESCR_BioSourceInconsistency, "Metagenome source should also have metagenomic qualifier", obj, ctx); } } if (isViral && IsUnexpectedViralOrgModQualifier (subtype)) { string subname = COrgMod::GetSubtypeName(subtype); if (subname.length() > 0) { subname[0] = toupper(subname[0]); } PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, "Virus has unexpected " + subname + " qualifier", obj, ctx); } } if (env_sample && !iso_source && !specific_host) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, "Environmental sample should also have isolation source or specific host annotated", obj, ctx); } ValidateOrgRef (orgref, obj, ctx); if (bsrc.IsSetPcr_primers()) { ValidatePCRReactionSet(bsrc.GetPcr_primers(), obj, ctx); } } void CValidError_imp::x_ReportPCRSeqProblem (const string& primer_kind, char badch, const CSerialObject& obj, const CSeq_entry *ctx) { if (badch < ' ' || badch > '~') { badch = '?'; } string msg = "PCR " + primer_kind + " primer sequence format is incorrect, first bad character is '"; msg += badch; msg += "'"; PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_BadPCRPrimerSequence, msg, obj, ctx); } void CValidError_imp::x_CheckPCRPrimer (const CPCRPrimer& primer, const string& primer_kind, const CSerialObject& obj, const CSeq_entry *ctx) { char badch = 0; if (primer.IsSetSeq() && ! CPCRPrimerSeq::IsValid(primer.GetSeq(), badch)) { x_ReportPCRSeqProblem(primer_kind, badch, obj, ctx); } badch = 0; if (primer.IsSetName() && primer.GetName().Get().length() > 10 && CPCRPrimerSeq::IsValid(primer.GetName(), badch)) { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_BadPCRPrimerName, "PCR " + primer_kind + " primer name appears to be a sequence", obj, ctx); } } void CValidError_imp::ValidatePCRReactionSet (const CPCRReactionSet& pcrset, const CSerialObject& obj, const CSeq_entry *ctx) { ITERATE(CPCRReactionSet::Tdata, it, pcrset.Get()) { if ((*it)->IsSetForward()) { ITERATE(CPCRPrimerSet::Tdata, pit, (*it)->GetForward().Get()) { x_CheckPCRPrimer(**pit, "forward", obj, ctx); } } if ((*it)->IsSetReverse()) { ITERATE(CPCRPrimerSet::Tdata, pit, (*it)->GetReverse().Get()) { x_CheckPCRPrimer(**pit, "reverse", obj, ctx); } } } } void CValidError_imp::ValidateSubSource (const CSubSource& subsrc, const CSerialObject& obj, const CSeq_entry *ctx) { if (!subsrc.IsSetSubtype()) { PostObjErr(eDiag_Critical, eErr_SEQ_DESCR_BadSubSource, "Unknown subsource subtype 0", obj, ctx); return; } int subtype = subsrc.GetSubtype(); switch ( subtype ) { case CSubSource::eSubtype_country: { string countryname = subsrc.GetName(); bool is_miscapitalized = false; if ( CCountries::IsValid(countryname, is_miscapitalized) ) { if (is_miscapitalized) { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_BadCountryCapitalization, "Bad country capitalization [" + countryname + "]", obj, ctx); } if (NStr::EndsWith (countryname, ":")) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BadCountryCode, "Colon at end of country name [" + countryname + "]", obj, ctx); } if ( CCountries::WasValid(countryname) ) { PostObjErr(eDiag_Info, eErr_SEQ_DESCR_ReplacedCountryCode, "Replaced country name [" + countryname + "]", obj, ctx); } } else { if ( countryname.empty() ) { countryname = "?"; } PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BadCountryCode, "Bad country name [" + countryname + "]", obj, ctx); } } break; case CSubSource::eSubtype_lat_lon: if (subsrc.IsSetName()) { bool format_correct = false, lat_in_range = false, lon_in_range = false, precision_correct = false; double lat_value = 0.0, lon_value = 0.0; string lat_lon = subsrc.GetName(); CSubSource::IsCorrectLatLonFormat (lat_lon, format_correct, precision_correct, lat_in_range, lon_in_range, lat_value, lon_value); if (!format_correct) { size_t pos = NStr::Find(lat_lon, ","); if (pos != string::npos) { CSubSource::IsCorrectLatLonFormat (lat_lon.substr(0, pos), format_correct, precision_correct, lat_in_range, lon_in_range, lat_value, lon_value); if (format_correct) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_LatLonFormat, "lat_lon format has extra text after correct dd.dd N|S ddd.dd E|W format", obj, ctx); } } } if (!format_correct) { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_LatLonFormat, "lat_lon format is incorrect - should be dd.dd N|S ddd.dd E|W", obj, ctx); } else { if (!lat_in_range) { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_LatLonRange, "latitude value is out of range - should be between 90.00 N and 90.00 S", obj, ctx); } if (!lon_in_range) { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_LatLonRange, "longitude value is out of range - should be between 180.00 E and 180.00 W", obj, ctx); } if (!precision_correct) { /* PostObjErr (eDiag_Info, eErr_SEQ_DESCR_LatLonPrecision, "lat_lon precision is incorrect - should only have two digits to the right of the decimal point", obj, ctx); */ } } } break; case CSubSource::eSubtype_chromosome: break; case CSubSource::eSubtype_fwd_primer_name: if (subsrc.IsSetName()) { string name = subsrc.GetName(); char bad_ch; if (name.length() > 10 && CPCRPrimerSeq::IsValid(name, bad_ch)) { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_BadPCRPrimerName, "PCR primer name appears to be a sequence", obj, ctx); } } break; case CSubSource::eSubtype_rev_primer_name: if (subsrc.IsSetName()) { string name = subsrc.GetName(); char bad_ch; if (name.length() > 10 && CPCRPrimerSeq::IsValid(name, bad_ch)) { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_BadPCRPrimerName, "PCR primer name appears to be a sequence", obj, ctx); } } break; case CSubSource::eSubtype_fwd_primer_seq: { char bad_ch = 0; if (!subsrc.IsSetName() || !CPCRPrimerSeq::IsValid(subsrc.GetName(), bad_ch)) { x_ReportPCRSeqProblem("forward", bad_ch, obj, ctx); } } break; case CSubSource::eSubtype_rev_primer_seq: { char bad_ch = 0; if (!subsrc.IsSetName() || !CPCRPrimerSeq::IsValid(subsrc.GetName(), bad_ch)) { x_ReportPCRSeqProblem("reverse", bad_ch, obj, ctx); } } break; case CSubSource::eSubtype_transposon_name: case CSubSource::eSubtype_insertion_seq_name: PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_ObsoleteSourceQual, "Transposon name and insertion sequence name are no " "longer legal qualifiers", obj, ctx); break; case 0: PostObjErr(eDiag_Critical, eErr_SEQ_DESCR_BadSubSource, "Unknown subsource subtype 0", obj, ctx); break; case CSubSource::eSubtype_other: ValidateSourceQualTags(subsrc.GetName(), obj, ctx); break; case CSubSource::eSubtype_germline: break; case CSubSource::eSubtype_rearranged: break; case CSubSource::eSubtype_transgenic: break; case CSubSource::eSubtype_metagenomic: break; case CSubSource::eSubtype_environmental_sample: break; case CSubSource::eSubtype_isolation_source: break; case CSubSource::eSubtype_sex: break; case CSubSource::eSubtype_mating_type: break; case CSubSource::eSubtype_plasmid_name: break; case CSubSource::eSubtype_plastid_name: break; case CSubSource::eSubtype_cell_line: break; case CSubSource::eSubtype_cell_type: break; case CSubSource::eSubtype_tissue_type: break; case CSubSource::eSubtype_frequency: if (subsrc.IsSetName() && !NStr::IsBlank(subsrc.GetName())) { const string& frequency = subsrc.GetName(); if (NStr::Equal(frequency, "0")) { //ignore } else if (NStr::Equal(frequency, "1")) { PostObjErr(eDiag_Info, eErr_SEQ_DESCR_BioSourceInconsistency, "bad frequency qualifier value " + frequency, obj, ctx); } else { string::const_iterator sit = frequency.begin(); bool bad_frequency = false; if (*sit == '0') { ++sit; } if (sit != frequency.end() && *sit == '.') { ++sit; if (sit == frequency.end()) { bad_frequency = true; } while (sit != frequency.end() && isdigit (*sit)) { ++sit; } if (sit != frequency.end()) { bad_frequency = true; } } else { bad_frequency = true; } if (bad_frequency) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, "bad frequency qualifier value " + frequency, obj, ctx); } } } break; case CSubSource::eSubtype_collection_date: if (!subsrc.IsSetName()) { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_BadCollectionDate, "Collection_date format is not in DD-Mmm-YYYY format", obj, ctx); } else { string problem = CSubSource::GetCollectionDateProblem(subsrc.GetName()); if (!NStr::IsBlank(problem)) { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_BadCollectionDate, problem, obj, ctx); } } break; default: break; } if (subsrc.IsSetName()) { if (CSubSource::NeedsNoText(subtype)) { if (subsrc.IsSetName() && !NStr::IsBlank(subsrc.GetName())) { string subname = CSubSource::GetSubtypeName (subtype); if (subname.length() > 0) { subname[0] = toupper(subname[0]); } NStr::ReplaceInPlace(subname, "-", "_"); PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, subname + " qualifier should not have descriptive text", obj, ctx); } } else { const string& subname = subsrc.GetName(); if (s_UnbalancedParentheses(subname)) { PostObjErr(eDiag_Error, eErr_SEQ_DESCR_UnbalancedParentheses, "Unbalanced parentheses in subsource '" + subname + "'", obj, ctx); } if (ContainsSgml(subname)) { PostObjErr(eDiag_Warning, eErr_GENERIC_SgmlPresentInText, "subsource " + subname + " has SGML", obj, ctx); } } } } static bool s_FindWholeName (string taxname, string value) { if (NStr::IsBlank(taxname) || NStr::IsBlank(value)) { return false; } size_t pos = NStr::Find (taxname, value); size_t value_len = value.length(); while (pos != string::npos && ( ( (pos != 0 && isalpha (taxname.c_str()[pos - 1])) || isalpha (taxname.c_str()[pos + value_len])))) { pos = NStr::Find(taxname, value, pos + value_len); } if (pos == string::npos) { return false; } else { return true; } } void CValidError_imp::ValidateOrgRef (const COrg_ref& orgref, const CSerialObject& obj, const CSeq_entry *ctx) { // Organism must have a name. if ( (!orgref.IsSetTaxname() || orgref.GetTaxname().empty()) && (!orgref.IsSetCommon() || orgref.GetCommon().empty()) ) { PostObjErr(eDiag_Error, eErr_SEQ_DESCR_NoOrgFound, "No organism name has been applied to this Bioseq. Other qualifiers may exist.", obj, ctx); } string taxname = ""; if (orgref.IsSetTaxname()) { taxname = orgref.GetTaxname(); if((NStr::EndsWith(taxname, " sp.", NStr::eNocase) || NStr::EndsWith(taxname, " sp", NStr::eNocase)) && !NStr::StartsWith(taxname, "uncultured ", NStr::eNocase) && !NStr::Equal(taxname, "Haemoproteus sp.", NStr::eNocase) && !NStr::StartsWith(taxname, "symbiont ", NStr::eNocase) && !NStr::StartsWith(taxname, "endosymbiont ", NStr::eNocase) && NStr::FindNoCase(taxname, " symbiont ") == NPOS && NStr::FindNoCase(taxname, " endosymbiont ") == NPOS) { EDiagSev sev; if(IsGenomeSubmission()) sev = eDiag_Error; else sev = eDiag_Warning; PostObjErr(sev, eErr_SEQ_DESCR_OrganismIsUndefinedSpecies, "Organism \"" + taxname + "\" is undefined species and does not have a specific identifier.", obj, ctx); } if (s_UnbalancedParentheses (taxname)) { PostObjErr(eDiag_Error, eErr_SEQ_DESCR_UnbalancedParentheses, "Unbalanced parentheses in taxname '" + orgref.GetTaxname() + "'", obj, ctx); } if (ContainsSgml(taxname)) { PostObjErr(eDiag_Warning, eErr_GENERIC_SgmlPresentInText, "taxname " + taxname + " has SGML", obj, ctx); } } if ( orgref.IsSetDb() ) { ValidateDbxref(orgref.GetDb(), obj, true, ctx); } bool has_taxon = false; FOR_EACH_DBXREF_ON_ORGREF (dbt, orgref) { if ( NStr::CompareNocase((*dbt)->GetDb(), "taxon") != 0 ) continue; has_taxon = true; if (! (*dbt)->IsSetTag()) continue; const CObject_id& id = (*dbt)->GetTag(); if (! id.IsId()) continue; if (m_FirstTaxID == 0) { SetFirstTaxID (id.GetId()); } else if (m_FirstTaxID != id.GetId()) { SetMultTaxIDs(); } } if ( IsRequireTaxonID() ) { if ( !has_taxon ) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_NoTaxonID, "BioSource is missing taxon ID", obj, ctx); } } if ( !orgref.IsSetOrgname() ) { return; } const COrgName& orgname = orgref.GetOrgname(); ValidateOrgName(orgname, has_taxon, obj, ctx); // Look for modifiers in taxname string taxname_search = taxname; // skip first two words size_t pos = NStr::Find (taxname_search, " "); if (pos == string::npos) { taxname_search = ""; } else { taxname_search = taxname_search.substr(pos + 1); NStr::TruncateSpacesInPlace(taxname_search); pos = NStr::Find (taxname_search, " "); if (pos == string::npos) { taxname_search = ""; } else { taxname_search = taxname_search.substr(pos + 1); NStr::TruncateSpacesInPlace(taxname_search); } } // determine if variety is present and in taxname - if so, // can ignore missing subspecies // also look for specimen-voucher (nat-host) if identical to taxname FOR_EACH_ORGMOD_ON_ORGNAME (it, orgname) { if (!(*it)->IsSetSubtype() || !(*it)->IsSetSubname()) { continue; } int subtype = (*it)->GetSubtype(); const string& subname = (*it)->GetSubname(); string orgmod_name = COrgMod::GetSubtypeName(subtype); if (orgmod_name.length() > 0) { orgmod_name[0] = toupper(orgmod_name[0]); } NStr::ReplaceInPlace(orgmod_name, "-", " "); if (subtype == COrgMod::eSubtype_sub_species) { if (!orgref.IsSubspeciesValid(subname)) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, "Subspecies value specified is not found in taxname", obj, ctx); } } else if (subtype == COrgMod::eSubtype_variety) { if (!orgref.IsVarietyValid(subname)) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, orgmod_name + " value specified is not found in taxname", obj, ctx); } } else if (subtype == COrgMod::eSubtype_forma || subtype == COrgMod::eSubtype_forma_specialis) { if (!s_FindWholeName(taxname_search, subname)) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, orgmod_name + " value specified is not found in taxname", obj, ctx); } } else if (subtype == COrgMod::eSubtype_nat_host) { if (NStr::EqualNocase(subname, taxname)) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BadOrgMod, "Specific host is identical to taxname", obj, ctx); } } } } void CValidError_imp::ValidateOrgName (const COrgName& orgname, const bool has_taxon, const CSerialObject& obj, const CSeq_entry *ctx) { if ( orgname.IsSetMod() ) { bool has_strain = false; FOR_EACH_ORGMOD_ON_ORGNAME (omd_itr, orgname) { const COrgMod& omd = **omd_itr; int subtype = omd.GetSubtype(); if (omd.IsSetSubname()) { string str = omd.GetSubname(); if (NStr::Equal (str, "N/A") || NStr::Equal (str, "Missing")) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, "Orgmod name should not be " + str, obj, ctx); } } switch (subtype) { case 0: case 1: PostObjErr(eDiag_Critical, eErr_SEQ_DESCR_BadOrgMod, "Unknown orgmod subtype " + NStr::IntToString(subtype), obj, ctx); break; case COrgMod::eSubtype_strain: if (omd.IsSetSubname()) { string str = omd.GetSubname(); if (NStr::StartsWith (str, "subsp. ")) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, "Orgmod.strain should not start with subsp.", obj, ctx); } else if (NStr::StartsWith (str, "serovar ")) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, "Orgmod.strain should not start with serovar", obj, ctx); } } if (has_strain) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BadOrgMod, "Multiple strain qualifiers on the same BioSource", obj, ctx); } has_strain = true; break; case COrgMod::eSubtype_serovar: if (omd.IsSetSubname()) { string str = omd.GetSubname(); if (NStr::StartsWith (str, "subsp. ")) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, "Orgmod.serovar should not start with subsp.", obj, ctx); } else if (NStr::StartsWith (str, "strain ")) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, "Orgmod.serovar should not start with strain", obj, ctx); } } break; case COrgMod::eSubtype_sub_species: if (omd.IsSetSubname()) { string str = omd.GetSubname(); if (NStr::Find (str, "subsp. ") != string::npos) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, "Orgmod.sub-species should not contain subsp.", obj, ctx); } } break; case COrgMod::eSubtype_variety: if ( (!orgname.IsSetDiv() || !NStr::EqualNocase( orgname.GetDiv(), "PLN" )) && (!orgname.IsSetLineage() || (NStr::Find(orgname.GetLineage(), "Cyanobacteria") == string::npos && NStr::Find(orgname.GetLineage(), "Myxogastria") == string::npos && NStr::Find(orgname.GetLineage(), "Oomycetes") == string::npos))) { if ( !has_taxon ) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BadOrgMod, "Orgmod variety should only be in plants, fungi, or cyanobacteria", obj, ctx); } } break; case COrgMod::eSubtype_other: ValidateSourceQualTags( omd.GetSubname(), obj, ctx); break; case COrgMod::eSubtype_synonym: if ((*omd_itr)->IsSetSubname() && !NStr::IsBlank((*omd_itr)->GetSubname())) { const string& val = (*omd_itr)->GetSubname(); // look for synonym/gb_synonym duplication FOR_EACH_ORGMOD_ON_ORGNAME (it2, orgname) { if ((*it2)->IsSetSubtype() && (*it2)->GetSubtype() == COrgMod::eSubtype_gb_synonym && (*it2)->IsSetSubname() && NStr::EqualNocase(val, (*it2)->GetSubname())) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, "OrgMod synonym is identical to OrgMod gb_synonym", obj, ctx); } } } break; case COrgMod::eSubtype_bio_material: case COrgMod::eSubtype_culture_collection: case COrgMod::eSubtype_specimen_voucher: ValidateOrgModVoucher (omd, obj, ctx); break; default: break; } if ( omd.IsSetSubname()) { const string& subname = omd.GetSubname(); if (subtype != COrgMod::eSubtype_old_name && s_UnbalancedParentheses(subname)) { PostObjErr(eDiag_Error, eErr_SEQ_DESCR_UnbalancedParentheses, "Unbalanced parentheses in orgmod '" + subname + "'", obj, ctx); } if (ContainsSgml(subname)) { PostObjErr(eDiag_Warning, eErr_GENERIC_SgmlPresentInText, "orgmod " + subname + " has SGML", obj, ctx); } } } // look for multiple source vouchers FOR_EACH_ORGMOD_ON_ORGNAME (omd_itr, orgname) { if(!(*omd_itr)->IsSetSubtype() || !(*omd_itr)->IsSetSubname()) { continue; } const COrgMod& omd = **omd_itr; int subtype = omd.GetSubtype(); if (subtype != COrgMod::eSubtype_specimen_voucher && subtype != COrgMod::eSubtype_bio_material && subtype != COrgMod::eSubtype_culture_collection) { continue; } string inst1 = "", coll1 = "", id1 = ""; if (!COrgMod::ParseStructuredVoucher(omd.GetSubname(), inst1, coll1, id1)) { continue; } if (NStr::EqualNocase(inst1, "personal") || NStr::EqualCase(coll1, "DNA")) { continue; } COrgName::TMod::const_iterator it_next = omd_itr; ++it_next; while (it_next != orgname.GetMod().end()) { if (!(*it_next)->IsSetSubtype() || !(*it_next)->IsSetSubname() || (*it_next)->GetSubtype() != subtype) { ++it_next; continue; } int subtype_next = (*it_next)->GetSubtype(); if (subtype_next != COrgMod::eSubtype_specimen_voucher && subtype_next != COrgMod::eSubtype_bio_material && subtype_next != COrgMod::eSubtype_culture_collection) { ++it_next; continue; } string inst2 = "", coll2 = "", id2 = ""; if (!COrgMod::ParseStructuredVoucher((*it_next)->GetSubname(), inst2, coll2, id2) || NStr::IsBlank(inst2) || NStr::EqualNocase(inst2, "personal") || NStr::EqualCase(coll2, "DNA") || !NStr::EqualNocase (inst1, inst2)) { ++it_next; continue; } // at this point, we have identified two vouchers // with the same institution codes // that are not personal and not DNA collections if (!NStr::IsBlank(coll1) && !NStr::IsBlank(coll2) && NStr::EqualNocase(coll1, coll2)) { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_MultipleSourceVouchers, "Multiple vouchers with same institution:collection", obj, ctx); } else { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_MultipleSourceVouchers, "Multiple vouchers with same institution", obj, ctx); } ++it_next; } } } } bool CValidError_imp::IsOtherDNA(const CBioseq_Handle& bsh) const { if ( bsh ) { CSeqdesc_CI sd(bsh, CSeqdesc::e_Molinfo); if ( sd ) { const CSeqdesc::TMolinfo& molinfo = sd->GetMolinfo(); if ( molinfo.CanGetBiomol() && molinfo.GetBiomol() == CMolInfo::eBiomol_other ) { return true; } } } return false; } static bool s_CompleteGenomeNeedsChromosome (const CBioSource& source) { bool rval = false; if (!source.IsSetGenome() || source.GetGenome() == CBioSource::eGenome_genomic || source.GetGenome() == CBioSource::eGenome_unknown) { bool is_viral = false; if (source.IsSetOrg()) { if (source.GetOrg().IsSetDivision() && NStr::Equal(source.GetOrg().GetDivision(), "PHG")) { is_viral = true; } else if (source.GetOrg().IsSetLineage()) { if (NStr::StartsWith(source.GetOrg().GetLineage(), "Viruses; ") || NStr::StartsWith(source.GetOrg().GetLineage(), "Viroids; ")) { is_viral = true; } } } rval = !is_viral; } return rval; } bool s_IsBacteria(const CBioSource& source) { bool rval = false; if (source.IsSetLineage()) { string lineage = source.GetLineage(); if (NStr::StartsWith(lineage, "Bacteria; ", NStr::eNocase)) { rval = true; } } return rval; } bool s_IsBioSample(const CBioseq_Handle& bsh) { bool rval = false; CSeqdesc_CI d(bsh, CSeqdesc::e_User); while (d && !rval) { if (d->GetUser().IsSetType() && d->GetUser().GetType().IsStr() && NStr::Equal(d->GetUser().GetType().GetStr(), "DBLink")) { ITERATE(CUser_object::TData, f, d->GetUser().GetData()) { if ((*f)->IsSetLabel() && (*f)->GetLabel().IsStr() && NStr::Equal((*f)->GetLabel().GetStr(), "BioSample") && (*f)->IsSetData() && ((*f)->GetData().IsStr() || (*f)->GetData().IsStrs())) { rval = true; break; } } } ++d; } return rval; } void CValidError_imp::ValidateBioSourceForSeq (const CBioSource& source, const CSerialObject& obj, const CSeq_entry *ctx, const CBioseq_Handle& bsh) { m_biosource_kind = source; if ( source.IsSetIs_focus() ) { // skip proteins, segmented bioseqs, or segmented parts if ( !bsh.IsAa() && !(bsh.GetInst().GetRepr() == CSeq_inst::eRepr_seg) && !(GetAncestor(*(bsh.GetCompleteBioseq()), CBioseq_set::eClass_parts) != 0) ) { if ( !CFeat_CI(bsh, CSeqFeatData::e_Biosrc) ) { PostObjErr(eDiag_Error, eErr_SEQ_DESCR_UnnecessaryBioSourceFocus, "BioSource descriptor has focus, " "but no BioSource feature", obj, ctx); } } } if ( source.CanGetOrigin() && source.GetOrigin() == CBioSource::eOrigin_synthetic ) { if ( !IsOtherDNA(bsh) && !bsh.IsAa()) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_InvalidForType, "Molinfo-biomol other should be used if " "Biosource-location is synthetic", obj, ctx); } } // check locations for HIV biosource if (bsh.IsSetInst() && bsh.GetInst().IsSetMol() && source.IsSetOrg() && source.GetOrg().IsSetTaxname() && (NStr::EqualNocase(source.GetOrg().GetTaxname(), "Human immunodeficiency virus") || NStr::EqualNocase(source.GetOrg().GetTaxname(), "Human immunodeficiency virus 1") || NStr::EqualNocase(source.GetOrg().GetTaxname(), "Human immunodeficiency virus 2"))) { if (bsh.GetInst().GetMol() == CSeq_inst::eMol_dna) { if (!source.IsSetGenome() || source.GetGenome() != CBioSource::eGenome_proviral) { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, "HIV with moltype DNA should be proviral", obj, ctx); } } else if (bsh.GetInst().GetMol() == CSeq_inst::eMol_rna) { CSeqdesc_CI mi(bsh, CSeqdesc::e_Molinfo); if (mi && mi->GetMolinfo().IsSetBiomol() && mi->GetMolinfo().GetBiomol() == CMolInfo::eBiomol_mRNA) { PostObjErr (eDiag_Info, eErr_SEQ_DESCR_BioSourceInconsistency, "HIV with mRNA molecule type is rare", obj, ctx); } } } CSeqdesc_CI mi(bsh, CSeqdesc::e_Molinfo); CSeqdesc_CI ti(bsh, CSeqdesc::e_Title); // look for viral completeness if (mi && mi->IsMolinfo() && ti && ti->IsTitle()) { const CMolInfo& molinfo = mi->GetMolinfo(); if (molinfo.IsSetBiomol() && molinfo.GetBiomol() == CMolInfo::eBiomol_genomic && molinfo.IsSetCompleteness() && molinfo.GetCompleteness() == CMolInfo::eCompleteness_complete && NStr::Find(ti->GetTitle(), "complete genome") != string::npos && s_CompleteGenomeNeedsChromosome (source)) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BioSourceNeedsChromosome, "Non-viral complete genome not labeled as chromosome", obj, ctx); } } if (mi) { // look for synthetic/artificial bool is_synthetic_construct = IsSyntheticConstruct (source); bool is_artificial = IsArtificial(source); if (is_synthetic_construct) { if ((!mi->GetMolinfo().IsSetBiomol() || mi->GetMolinfo().GetBiomol() != CMolInfo::eBiomol_other_genetic) && !bsh.IsAa()) { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_InvalidForType, "synthetic construct should have other-genetic", obj, ctx); } if (!is_artificial) { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_InvalidForType, "synthetic construct should have artificial origin", obj, ctx); } } else if (is_artificial) { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_InvalidForType, "artificial origin should have other-genetic and synthetic construct", obj, ctx); } if (is_artificial) { if ((!mi->GetMolinfo().IsSetBiomol() || mi->GetMolinfo().GetBiomol() != CMolInfo::eBiomol_other_genetic) && !bsh.IsAa()) { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_InvalidForType, "artificial origin should have other-genetic", obj, ctx); } } } // validate subsources in context FOR_EACH_SUBSOURCE_ON_BIOSOURCE (it, source) { if (!(*it)->IsSetSubtype()) { continue; } CSubSource::TSubtype subtype = (*it)->GetSubtype(); switch (subtype) { case CSubSource::eSubtype_other: // look for conflicting cRNA notes on subsources if (mi && (*it)->IsSetName() && NStr::EqualNocase((*it)->GetName(), "cRNA")) { const CMolInfo& molinfo = mi->GetMolinfo(); if (!molinfo.IsSetBiomol() || molinfo.GetBiomol() != CMolInfo::eBiomol_cRNA) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, "cRNA note conflicts with molecule type", obj, ctx); } else { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, "cRNA note redundant with molecule type", obj, ctx); } } break; default: break; } } // look at orgref in context if (source.IsSetOrg()) { const COrg_ref& orgref = source.GetOrg(); // look at uncultured sequence length and required modifiers if (orgref.IsSetTaxname()) { if (NStr::EqualNocase(orgref.GetTaxname(), "uncultured bacterium") && bsh.GetBioseqLength() >= 10000 && source.IsSetGenome() && source.GetGenome() != CBioSource::eGenome_plasmid) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, "Uncultured bacterium sequence length is suspiciously high", obj, ctx); } if (NStr::StartsWith(orgref.GetTaxname(), "uncultured ", NStr::eNocase)) { bool is_env_sample = false; FOR_EACH_SUBSOURCE_ON_BIOSOURCE (it, source) { if ((*it)->IsSetSubtype() && (*it)->GetSubtype() == CSubSource::eSubtype_environmental_sample) { is_env_sample = true; break; } } if (!is_env_sample) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, "Uncultured should also have /environmental_sample", obj, ctx); } } } if (mi) { const CMolInfo& molinfo = mi->GetMolinfo(); // look for conflicting cRNA notes on orgmod FOR_EACH_ORGMOD_ON_ORGREF (it, orgref) { if ((*it)->IsSetSubtype() && (*it)->GetSubtype() == COrgMod::eSubtype_other && (*it)->IsSetSubname() && NStr::EqualNocase((*it)->GetSubname(), "cRNA")) { if (!molinfo.IsSetBiomol() || molinfo.GetBiomol() != CMolInfo::eBiomol_cRNA) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, "cRNA note conflicts with molecule type", obj, ctx); } else { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, "cRNA note redundant with molecule type", obj, ctx); } } } if (orgref.IsSetLineage()) { const string& lineage = orgref.GetOrgname().GetLineage(); // look for incorrect DNA stage if (molinfo.IsSetBiomol() && molinfo.GetBiomol () == CMolInfo::eBiomol_genomic && bsh.IsSetInst() && bsh.GetInst().IsSetMol() && bsh.GetInst().GetMol() == CSeq_inst::eMol_dna && NStr::StartsWith(lineage, "Viruses; ") && NStr::FindNoCase(lineage, "no DNA stage") != string::npos) { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, "Genomic DNA viral lineage indicates no DNA stage", obj, ctx); } if (NStr::FindNoCase (lineage, "negative-strand viruses") != string::npos) { bool is_ambisense = false; if (NStr::FindNoCase(lineage, "Arenavirus") != string::npos || NStr::FindNoCase(lineage, "Arenaviridae") != string::npos || NStr::FindNoCase(lineage, "Phlebovirus") != string::npos || NStr::FindNoCase(lineage, "Tospovirus") != string::npos || NStr::FindNoCase(lineage, "Tenuivirus") != string::npos) { is_ambisense = true; } bool is_synthetic = false; if (orgref.IsSetDivision() && NStr::EqualNocase(orgref.GetDivision(), "SYN")) { is_synthetic = true; } else if (source.IsSetOrigin() && (source.GetOrigin() == CBioSource::eOrigin_mut || source.GetOrigin() == CBioSource::eOrigin_artificial || source.GetOrigin() == CBioSource::eOrigin_synthetic)) { is_synthetic = true; } bool has_cds = false; CFeat_CI cds_ci(bsh, SAnnotSelector(CSeqFeatData::e_Cdregion)); while (cds_ci) { has_cds = true; if (cds_ci->GetLocation().GetStrand() == eNa_strand_minus) { if (!molinfo.IsSetBiomol() || molinfo.GetBiomol() != CMolInfo::eBiomol_genomic) { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, "Negative-strand virus with minus strand CDS should be genomic", obj, ctx); } } else { if (!is_synthetic && !is_ambisense && (!molinfo.IsSetBiomol() || (molinfo.GetBiomol() != CMolInfo::eBiomol_cRNA && molinfo.GetBiomol() != CMolInfo::eBiomol_mRNA))) { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, "Negative-strand virus with plus strand CDS should be mRNA or cRNA", obj, ctx); } } ++cds_ci; } if (!has_cds) { CFeat_CI misc_ci(bsh, SAnnotSelector(CSeqFeatData::eSubtype_misc_feature)); while (misc_ci) { if (misc_ci->IsSetComment() && NStr::FindNoCase (misc_ci->GetComment(), "nonfunctional") != string::npos) { if (misc_ci->GetLocation().GetStrand() == eNa_strand_minus) { if (!molinfo.IsSetBiomol() || molinfo.GetBiomol() != CMolInfo::eBiomol_genomic) { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, "Negative-strand virus with nonfunctional minus strand misc_feature should be genomic", obj, ctx); } } else { if (!is_synthetic && !is_ambisense && (!molinfo.IsSetBiomol() || (molinfo.GetBiomol() != CMolInfo::eBiomol_cRNA && molinfo.GetBiomol() != CMolInfo::eBiomol_mRNA))) { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_BioSourceInconsistency, "Negative-strand virus with nonfunctional plus strand misc_feature should be mRNA or cRNA", obj, ctx); } } } ++misc_ci; } } } } } if (!bsh.IsAa() && orgref.IsSetLineage()) { const string& lineage = orgref.GetOrgname().GetLineage(); // look for viral taxonomic conflicts if ((NStr::Find(lineage, " ssRNA viruses; ") != string::npos || NStr::Find(lineage, " ssRNA negative-strand viruses; ") != string::npos || NStr::Find(lineage, " ssRNA positive-strand viruses, no DNA stage; ") != string::npos || NStr::Find(lineage, " unassigned ssRNA viruses; ") != string::npos) && (!bsh.IsSetInst_Mol() || bsh.GetInst_Mol() != CSeq_inst::eMol_rna)) { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_MolInfoConflictsWithBioSource, "Taxonomy indicates single-stranded RNA, sequence does not agree.", obj, ctx); } if (NStr::Find(lineage, " dsRNA viruses; ") != string::npos && (!bsh.IsSetInst_Mol() || bsh.GetInst_Mol() != CSeq_inst::eMol_rna)) { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_MolInfoConflictsWithBioSource, "Taxonomy indicates double-stranded RNA, sequence does not agree.", obj, ctx); } if (NStr::Find(lineage, " ssDNA viruses; ") != string::npos && (!bsh.IsSetInst_Mol() || bsh.GetInst_Mol() != CSeq_inst::eMol_dna)) { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_MolInfoConflictsWithBioSource, "Taxonomy indicates single-stranded DNA, sequence does not agree.", obj, ctx); } if (NStr::Find(lineage, " dsDNA viruses; ") != string::npos && (!bsh.IsSetInst_Mol() || bsh.GetInst_Mol() != CSeq_inst::eMol_dna)) { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_MolInfoConflictsWithBioSource, "Taxonomy indicates double-stranded DNA, sequence does not agree.", obj, ctx); } } } if (IsGpipe() || IsIndexerVersion()) { if (s_IsBacteria(source) && s_IsBioSample(bsh)) { bool has_strain = false; bool has_isolate = false; bool env_sample = false; if (source.IsSetSubtype()) { ITERATE(CBioSource::TSubtype, s, source.GetSubtype()) { if ((*s)->IsSetSubtype() && (*s)->GetSubtype() == CSubSource::eSubtype_environmental_sample) { env_sample = true; break; } } } if (!env_sample && source.IsSetOrg() && source.GetOrg().IsSetOrgname() && source.GetOrg().GetOrgname().IsSetMod()) { ITERATE(COrgName::TMod, om, source.GetOrg().GetOrgname().GetMod()) { if ((*om)->IsSetSubtype()) { if ((*om)->GetSubtype() == COrgMod::eSubtype_isolate) { has_isolate = true; break; } else if ((*om)->GetSubtype() == COrgMod::eSubtype_strain) { has_strain = true; break; } } } } if ( ! has_strain && ! has_isolate && ! env_sample ) { PostObjErr(eDiag_Error, eErr_SEQ_DESCR_BioSourceInconsistency, "Bacteria should have strain or isolate or environmental sample", obj, ctx); } } } } bool CValidError_imp::IsTransgenic(const CBioSource& bsrc) { if (bsrc.CanGetSubtype()) { FOR_EACH_SUBSOURCE_ON_BIOSOURCE (sbs_itr, bsrc) { const CSubSource& sbs = **sbs_itr; if (sbs.GetSubtype() == CSubSource::eSubtype_transgenic) { return true; } } } return false; } const string CValidError_imp::sm_SourceQualPrefixes[] = { "acronym:", "altitude:", "anamorph:", "authority:", "biotype:", "biovar:", "bio_material:", "breed:", "cell_line:", "cell_type:", "chemovar:", "chromosome:", "clone:", "clone_lib:", "collected_by:", "collection_date:", "common:", "country:", "cultivar:", "culture_collection:", "dev_stage:", "dosage:", "ecotype:", "endogenous_virus_name:", "environmental_sample:", "forma:", "forma_specialis:", "frequency:", "fwd_pcr_primer_name", "fwd_pcr_primer_seq", "fwd_primer_name", "fwd_primer_seq", "genotype:", "germline:", "group:", "haplogroup:", "haplotype:", "identified_by:", "insertion_seq_name:", "isolate:", "isolation_source:", "lab_host:", "lat_lon:", "left_primer:", "linkage_group:", "map:", "mating_type:", "metagenome_source:", "metagenomic:", "nat_host:", "pathovar:", "phenotype:", "placement:", "plasmid_name:", "plastid_name:", "pop_variant:", "rearranged:", "rev_pcr_primer_name", "rev_pcr_primer_seq", "rev_primer_name", "rev_primer_seq", "right_primer:", "segment:", "serogroup:", "serotype:", "serovar:", "sex:", "specimen_voucher:", "strain:", "subclone:", "subgroup:", "substrain:", "subtype:", "sub_species:", "synonym:", "taxon:", "teleomorph:", "tissue_lib:", "tissue_type:", "transgenic:", "transposon_name:", "type:", "variety:", "whole_replicon:", }; void CValidError_imp::InitializeSourceQualTags() { m_SourceQualTags.reset(new CTextFsa(true)); size_t size = sizeof(sm_SourceQualPrefixes) / sizeof(string); for (size_t i = 0; i < size; ++i ) { m_SourceQualTags->AddWord(sm_SourceQualPrefixes[i]); } m_SourceQualTags->Prime(); } void CValidError_imp::ValidateSourceQualTags (const string& str, const CSerialObject& obj, const CSeq_entry *ctx) { if ( NStr::IsBlank(str) ) return; size_t str_len = str.length(); int state = m_SourceQualTags->GetInitialState(); for ( size_t i = 0; i < str_len; ++i ) { state = m_SourceQualTags->GetNextState(state, str[i]); if ( m_SourceQualTags->IsMatchFound(state) ) { string match = m_SourceQualTags->GetMatches(state)[0]; if ( match.empty() ) { match = "?"; } size_t match_len = match.length(); bool okay = true; if ( (int)(i - match_len) >= 0 ) { char ch = str[i - match_len]; if ( !isspace((unsigned char) ch) && ch != ';' ) { okay = false; #if 0 // look to see if there's a longer match in the list for (size_t k = 0; k < sizeof (CValidError_imp::sm_SourceQualPrefixes) / sizeof (string); k++) { size_t pos = NStr::FindNoCase (str, CValidError_imp::sm_SourceQualPrefixes[k]); if (pos != string::npos) { if (pos == 0 || isspace ((unsigned char) str[pos]) || str[pos] == ';') { okay = true; match = CValidError_imp::sm_SourceQualPrefixes[k]; break; } } } #endif } } if ( okay ) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_StructuredSourceNote, "Source note has structured tag '" + match + "'", obj, ctx); } } } } static bool x_HasTentativeName(const CUser_object &user_object) { if( ! FIELD_IS_SET_AND_IS(user_object, Type, Str) || user_object.GetType().GetStr() != "StructuredComment" ) { return false; } FOR_EACH_USERFIELD_ON_USEROBJECT( user_field_iter, user_object ) { const CUser_field &field = **user_field_iter; if( FIELD_IS_SET_AND_IS(field, Label, Str) && FIELD_IS_SET_AND_IS(field, Data, Str) ) { if( GET_FIELD(field.GetLabel(), Str) == "Tentative Name" ) { if( GET_FIELD(field.GetData(), Str) != "not provided" ) { return true; } } } } return false; } static string x_GetTentativeName(const CUser_object &user_object) { if( ! FIELD_IS_SET_AND_IS(user_object, Type, Str) || user_object.GetType().GetStr() != "StructuredComment" ) { return ""; } FOR_EACH_USERFIELD_ON_USEROBJECT( user_field_iter, user_object ) { const CUser_field &field = **user_field_iter; if( FIELD_IS_SET_AND_IS(field, Label, Str) && FIELD_IS_SET_AND_IS(field, Data, Str) ) { if( GET_FIELD(field.GetLabel(), Str) == "Tentative Name" ) { if( GET_FIELD(field.GetData(), Str) != "not provided" ) { return GET_FIELD(field.GetData(), Str); } } } } return ""; } void CValidError_imp::GatherTentativeName (const CSeq_entry& se, vector<CConstRef<CSeqdesc> >& usr_descs, vector<CConstRef<CSeq_entry> >& desc_ctxs, vector<CConstRef<CSeq_feat> >& usr_feats) { // get source descriptors FOR_EACH_DESCRIPTOR_ON_SEQENTRY (it, se) { if ((*it)->IsUser() && x_HasTentativeName((*it)->GetUser())) { CConstRef<CSeqdesc> desc; desc.Reset(*it); usr_descs.push_back(desc); CConstRef<CSeq_entry> r_se; r_se.Reset(&se); desc_ctxs.push_back(r_se); } } // also get features FOR_EACH_ANNOT_ON_SEQENTRY (annot_it, se) { FOR_EACH_SEQFEAT_ON_SEQANNOT (feat_it, **annot_it) { if ((*feat_it)->IsSetData() && (*feat_it)->GetData().IsUser() && x_HasTentativeName((*feat_it)->GetData().GetUser())) { CConstRef<CSeq_feat> feat; feat.Reset(*feat_it); usr_feats.push_back(feat); } } } // if set, recurse if (se.IsSet()) { FOR_EACH_SEQENTRY_ON_SEQSET (it, se.GetSet()) { GatherTentativeName (**it, usr_descs, desc_ctxs, usr_feats); } } } void CValidError_imp::GatherSources (const CSeq_entry& se, vector<CConstRef<CSeqdesc> >& src_descs, vector<CConstRef<CSeq_entry> >& desc_ctxs, vector<CConstRef<CSeq_feat> >& src_feats) { // get source descriptors FOR_EACH_DESCRIPTOR_ON_SEQENTRY (it, se) { if ((*it)->IsSource() && (*it)->GetSource().IsSetOrg()) { CConstRef<CSeqdesc> desc; desc.Reset(*it); src_descs.push_back(desc); CConstRef<CSeq_entry> r_se; r_se.Reset(&se); desc_ctxs.push_back(r_se); } } // also get features FOR_EACH_ANNOT_ON_SEQENTRY (annot_it, se) { FOR_EACH_SEQFEAT_ON_SEQANNOT (feat_it, **annot_it) { if ((*feat_it)->IsSetData() && (*feat_it)->GetData().IsBiosrc() && (*feat_it)->GetData().GetBiosrc().IsSetOrg()) { CConstRef<CSeq_feat> feat; feat.Reset(*feat_it); src_feats.push_back(feat); } } } // if set, recurse if (se.IsSet()) { FOR_EACH_SEQENTRY_ON_SEQSET (it, se.GetSet()) { GatherSources (**it, src_descs, desc_ctxs, src_feats); } } } CRef<CTaxon3_reply> CValidError_imp::RequestSpecificHost (const vector<CConstRef<CSeqdesc> > & src_descs, const vector<CConstRef<CSeq_entry> > & desc_ctxs, const vector<CConstRef<CSeq_feat> > & src_feats, TSpecificHostWithParentList& host_list) { host_list.clear(); vector<CRef<COrg_ref> > org_rq_list; //first do descriptors vector<CConstRef<CSeqdesc> >::const_iterator desc_it = src_descs.begin(); vector<CConstRef<CSeq_entry> >::const_iterator ctx_it = desc_ctxs.begin(); while (desc_it != src_descs.end() && ctx_it != desc_ctxs.end()) { FOR_EACH_ORGMOD_ON_BIOSOURCE (mod_it, (*desc_it)->GetSource()) { if ((*mod_it)->IsSetSubtype() && (*mod_it)->GetSubtype() == COrgMod::eSubtype_nat_host && (*mod_it)->IsSetSubname()) { string host = SpecificHostValueToCheck((*mod_it)->GetSubname()); if (!NStr::IsBlank(host)) { CRef<COrg_ref> rq(new COrg_ref); rq->SetTaxname(host); host_list.push_back(COrgrefWithParent_SpecificHost(rq.GetObject(),**desc_it, **ctx_it)); org_rq_list.push_back(rq); } } } ++desc_it; ++ctx_it; } // collect features with specific hosts vector<CConstRef<CSeq_feat> >::const_iterator feat_it = src_feats.begin(); while (feat_it != src_feats.end()) { FOR_EACH_ORGMOD_ON_BIOSOURCE (mod_it, (*feat_it)->GetData().GetBiosrc()) { if ((*mod_it)->IsSetSubtype() && (*mod_it)->GetSubtype() == COrgMod::eSubtype_nat_host && (*mod_it)->IsSetSubname()) { string host = SpecificHostValueToCheck((*mod_it)->GetSubname()); if (!NStr::IsBlank(host)) { CRef<COrg_ref> rq(new COrg_ref); rq->SetTaxname(host); host_list.push_back(COrgrefWithParent_SpecificHost(rq.GetObject(), **feat_it)); org_rq_list.push_back(rq); } } } ++feat_it; } if (org_rq_list.size() > 0) { CTaxon3 taxon3; taxon3.Init(); CRef<CTaxon3_reply> reply = taxon3.SendOrgRefList(org_rq_list); return reply; } else { CRef<CTaxon3_reply> reply; return reply; } } void CValidError_imp::ValidateSpecificHost (const vector<CConstRef<CSeqdesc> > & src_descs, const vector<CConstRef<CSeq_entry> > & desc_ctxs, const vector<CConstRef<CSeq_feat> > & src_feats) { TSpecificHostWithParentList host_list; CRef<CTaxon3_reply> reply = RequestSpecificHost(src_descs, desc_ctxs, src_feats, host_list); if (reply) { CTaxon3_reply::TReply::const_iterator reply_it = reply->GetReply().begin(); TSpecificHostWithParentList::iterator org_it = host_list.begin(); // process descriptor and feature responses while (reply_it != reply->GetReply().end() && org_it != host_list.end()) { string host = (*org_it).GetOrgref().GetTaxname(); string err_str = InterpretSpecificHostResult(host, **reply_it); if (!NStr::IsBlank(err_str)) { EErrType et = eErr_SEQ_DESCR_BadSpecificHost; EDiagSev sev = eDiag_Warning; if(NStr::Find(err_str, "ambiguous") != string::npos) { et = eErr_SEQ_DESCR_AmbiguousSpecificHost; sev = eDiag_Info; } if ((*org_it).HasParentSeqdesc()) { PostObjErr (sev, et, err_str, (*org_it).GetSeqdescParent(), &((*org_it).GetSeqentryParent())); } else { PostErr (sev, et, err_str, (*org_it).GetSeqfeatParent()); } } ++reply_it; ++org_it; } } } void CValidError_imp::ValidateSpecificHost (const CSeq_entry& se) { vector<CConstRef<CSeqdesc> > src_descs; vector<CConstRef<CSeq_entry> > desc_ctxs; vector<CConstRef<CSeq_feat> > src_feats; GatherSources (se, src_descs, desc_ctxs, src_feats); ValidateSpecificHost(src_descs, desc_ctxs, src_feats); } void CValidError_imp::ValidateTentativeName(const CSeq_entry& se) { vector<CConstRef<CSeqdesc> > src_descs; vector<CConstRef<CSeq_entry> > desc_ctxs; vector<CConstRef<CSeq_feat> > src_feats; GatherTentativeName (se, src_descs, desc_ctxs, src_feats); // request list for taxon3 vector< CRef<COrg_ref> > org_rq_list; // first do descriptors vector<CConstRef<CSeqdesc> >::iterator desc_it = src_descs.begin(); vector<CConstRef<CSeq_entry> >::iterator ctx_it = desc_ctxs.begin(); while (desc_it != src_descs.end() && ctx_it != desc_ctxs.end()) { const string& taxname = x_GetTentativeName((*desc_it)->GetUser()); CRef<COrg_ref> rq(new COrg_ref); rq->SetTaxname(taxname); org_rq_list.push_back(rq); ++desc_it; ++ctx_it; } // now do features vector<CConstRef<CSeq_feat> >::iterator feat_it = src_feats.begin(); while (feat_it != src_feats.end()) { const string& taxname = x_GetTentativeName((*feat_it)->GetData().GetUser()); CRef<COrg_ref> rq(new COrg_ref); rq->SetTaxname(taxname); org_rq_list.push_back(rq); ++feat_it; } if (org_rq_list.size() > 0) { CCachedTaxon taxon3; taxon3.Init(); CRef<CTaxon3_reply> reply = taxon3.SendOrgRefList(org_rq_list); if (reply) { CTaxon3_reply::TReply::const_iterator reply_it = reply->GetReply().begin(); // process descriptor responses desc_it = src_descs.begin(); ctx_it = desc_ctxs.begin(); while (reply_it != reply->GetReply().end() && desc_it != src_descs.end() && ctx_it != desc_ctxs.end()) { if ((*reply_it)->IsError()) { string err_str = "?"; if ((*reply_it)->GetError().IsSetMessage()) { err_str = (*reply_it)->GetError().GetMessage(); } PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_BadTentativeName, "Taxonomy lookup failed with message '" + err_str + "'", **desc_it, *ctx_it); } ++reply_it; ++desc_it; ++ctx_it; } // process feat responses feat_it = src_feats.begin(); while (reply_it != reply->GetReply().end() && feat_it != src_feats.end()) { if ((*reply_it)->IsError()) { string err_str = "?"; if ((*reply_it)->GetError().IsSetMessage()) { err_str = (*reply_it)->GetError().GetMessage(); } PostErr (eDiag_Warning, eErr_SEQ_DESCR_BadTentativeName, "Taxonomy lookup failed with message '" + err_str + "'", **feat_it); } ++reply_it; ++feat_it; } } } } void CValidError_imp::ValidateTaxonomy(const CSeq_entry& se) { bool is_insd_patent = false; bool is_insd = false; bool is_patent = false; VISIT_ALL_BIOSEQS_WITHIN_SEQENTRY (bs_itr, se) { const CBioseq& bs = *bs_itr; FOR_EACH_SEQID_ON_BIOSEQ (sid_itr, bs) { const CSeq_id& sid = **sid_itr; SWITCH_ON_SEQID_CHOICE (sid) { case NCBI_SEQID(Genbank): case NCBI_SEQID(Embl): case NCBI_SEQID(Ddbj): is_insd = true; break; case NCBI_SEQID(Patent): is_patent = true; break; default: break; } } } if (is_insd && is_patent) { is_insd_patent = true; } vector<CConstRef<CSeqdesc> > src_descs; vector<CConstRef<CSeq_entry> > desc_ctxs; vector<CConstRef<CSeq_feat> > src_feats; GatherSources (se, src_descs, desc_ctxs, src_feats); // request list for taxon3 vector< CRef<COrg_ref> > org_rq_list; // first do descriptors vector<CConstRef<CSeqdesc> >::iterator desc_it = src_descs.begin(); vector<CConstRef<CSeq_entry> >::iterator ctx_it = desc_ctxs.begin(); while (desc_it != src_descs.end() && ctx_it != desc_ctxs.end()) { CRef<COrg_ref> rq(new COrg_ref); const COrg_ref& org = (*desc_it)->GetSource().GetOrg(); rq->Assign(org); org_rq_list.push_back(rq); ++desc_it; ++ctx_it; } // now do features vector<CConstRef<CSeq_feat> >::iterator feat_it = src_feats.begin(); while (feat_it != src_feats.end()) { CRef<COrg_ref> rq(new COrg_ref); const COrg_ref& org = (*feat_it)->GetData().GetBiosrc().GetOrg(); rq->Assign(org); org_rq_list.push_back(rq); ++feat_it; } if (org_rq_list.size() > 0) { CCachedTaxon taxon3; taxon3.Init(); CRef<CTaxon3_reply> reply = taxon3.SendOrgRefList(org_rq_list); if (reply) { CTaxon3_reply::TReply::const_iterator reply_it = reply->GetReply().begin(); vector<CRef<COrg_ref> >::const_iterator rq_it = org_rq_list.begin(); // process descriptor responses desc_it = src_descs.begin(); ctx_it = desc_ctxs.begin(); while (reply_it != reply->GetReply().end() && desc_it != src_descs.end() && ctx_it != desc_ctxs.end() && rq_it != org_rq_list.end()) { if ((*reply_it)->IsError()) { string err_str = "?"; if ((*reply_it)->GetError().IsSetMessage()) { err_str = (*reply_it)->GetError().GetMessage(); } if (NStr::Equal(err_str, "Organism not found")) { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_OrganismNotFound, "Organism not found in taxonomy database", **desc_it, *ctx_it); } else { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_TaxonomyLookupProblem, "Taxonomy lookup failed with message '" + err_str + "'", **desc_it, *ctx_it); } } else if ((*reply_it)->IsData()) { bool is_species_level = true; bool is_unidentified = false; bool force_consult = false; bool has_nucleomorphs = false; if ((*reply_it)->GetData().IsSetOrg()) { const COrg_ref& orp_req = **rq_it; const COrg_ref& orp_rep = (*reply_it)->GetData().GetOrg(); if (orp_req.IsSetTaxname() && orp_rep.IsSetTaxname()) { const string& taxname_req = orp_req.GetTaxname(); const string& taxname_rep = orp_rep.GetTaxname(); if (NStr::Equal (taxname_rep, "unidentified")) { is_unidentified = true; } if (orp_rep.IsSetDb() && orp_req.IsSetDb()) { int taxid_req = 0; int taxid_rep = 0; bool found_should_be_id = false; bool found_is_id = false; FOR_EACH_DBXREF_ON_ORGREF (q_itr, orp_req) { const CDbtag& dbt = **q_itr; if (dbt.IsSetDb() && NStr::Equal(dbt.GetDb(), "taxon") && dbt.IsSetTag()) { const CObject_id& id = dbt.GetTag(); if (id.IsId()) { taxid_req = id.GetId(); found_is_id = true; } } } FOR_EACH_DBXREF_ON_ORGREF (p_itr, orp_rep) { const CDbtag& dbt = **p_itr; if (dbt.IsSetDb() && NStr::Equal(dbt.GetDb(), "taxon") && dbt.IsSetTag()) { const CObject_id& id = dbt.GetTag(); if (id.IsId()) { taxid_rep = id.GetId(); found_should_be_id = true; } } } if (found_is_id && found_should_be_id && taxid_req != taxid_rep) { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_TaxonomyLookupProblem, "Organism name is '" + taxname_req + "', taxonomy ID should be '" + NStr::IntToString (taxid_rep) + "' but is " + NStr::IntToString (taxid_req) + "'", **desc_it, *ctx_it); } } } } (*reply_it)->GetData().GetTaxFlags(is_species_level, force_consult, has_nucleomorphs); if (!is_species_level && ! IsWP()) { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_TaxonomyIsSpeciesProblem, "Taxonomy lookup reports is_species_level FALSE", **desc_it, *ctx_it); } if (force_consult) { if (is_insd_patent && is_unidentified) { force_consult = false; } } if (force_consult) { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_TaxonomyConsultRequired, "Taxonomy lookup reports taxonomy consultation needed", **desc_it, *ctx_it); } if ((*desc_it)->GetSource().IsSetGenome()) { CBioSource::TGenome genome = (*desc_it)->GetSource().GetGenome(); if (genome == CBioSource::eGenome_nucleomorph && !has_nucleomorphs) { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_TaxonomyNucleomorphProblem, "Taxonomy lookup does not have expected nucleomorph flag", **desc_it, *ctx_it); } else if (genome == CBioSource::eGenome_plastid && (!(*reply_it)->GetData().HasPlastids())) { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_TaxonomyPlastidsProblem, "Taxonomy lookup does not have expected plastid flag", **desc_it, *ctx_it); } } } ++reply_it; ++desc_it; ++ctx_it; ++rq_it; } // process feat responses feat_it = src_feats.begin(); while (reply_it != reply->GetReply().end() && feat_it != src_feats.end() && rq_it != org_rq_list.end()) { if ((*reply_it)->IsError()) { string err_str = "?"; if ((*reply_it)->GetError().IsSetMessage()) { err_str = (*reply_it)->GetError().GetMessage(); } PostErr (eDiag_Warning, eErr_SEQ_DESCR_TaxonomyLookupProblem, "Taxonomy lookup failed with message '" + err_str + "'", **feat_it); } else if ((*reply_it)->IsData()) { bool is_species_level = true; bool force_consult = false; bool has_nucleomorphs = false; (*reply_it)->GetData().GetTaxFlags(is_species_level, force_consult, has_nucleomorphs); if (!is_species_level && ! IsWP()) { PostErr (eDiag_Warning, eErr_SEQ_DESCR_TaxonomyLookupProblem, "Taxonomy lookup reports is_species_level FALSE", **feat_it); } if (force_consult) { PostErr (eDiag_Warning, eErr_SEQ_DESCR_TaxonomyLookupProblem, "Taxonomy lookup reports taxonomy consultation needed", **feat_it); } if ((*feat_it)->GetData().GetBiosrc().IsSetGenome()) { CBioSource::TGenome genome = (*feat_it)->GetData().GetBiosrc().GetGenome(); if (genome == CBioSource::eGenome_nucleomorph && !has_nucleomorphs) { PostErr (eDiag_Warning, eErr_SEQ_DESCR_TaxonomyNucleomorphProblem, "Taxonomy lookup does not have expected nucleomorph flag", **feat_it); } else if (genome == CBioSource::eGenome_plastid && (!(*reply_it)->GetData().HasPlastids())) { PostErr (eDiag_Warning, eErr_SEQ_DESCR_TaxonomyPlastidsProblem, "Taxonomy lookup does not have expected plastid flag", **feat_it); } } } ++reply_it; ++feat_it; ++rq_it; } } } // Now look at specific-host values ValidateSpecificHost (src_descs, desc_ctxs, src_feats); ValidateTentativeName (se); } void CValidError_imp::ValidateTaxonomy(const COrg_ref& org, int genome) { // request list for taxon3 vector< CRef<COrg_ref> > org_rq_list; CRef<COrg_ref> rq(new COrg_ref); rq->Assign(org); org_rq_list.push_back(rq); CCachedTaxon taxon3; taxon3.Init(); CRef<CTaxon3_reply> reply = taxon3.SendOrgRefList(org_rq_list); if (reply) { CTaxon3_reply::TReply::const_iterator reply_it = reply->GetReply().begin(); vector<CRef<COrg_ref> >::const_iterator rq_it = org_rq_list.begin(); while (reply_it != reply->GetReply().end() && rq_it != org_rq_list.end()) { if ((*reply_it)->IsError()) { string err_str = "?"; if ((*reply_it)->GetError().IsSetMessage()) { err_str = (*reply_it)->GetError().GetMessage(); } if (NStr::Equal(err_str, "Organism not found")) { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_OrganismNotFound, "Organism not found in taxonomy database", org); } else { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_TaxonomyLookupProblem, "Taxonomy lookup failed with message '" + err_str + "'", org); } } else if ((*reply_it)->IsData()) { bool is_species_level = true; bool force_consult = false; bool has_nucleomorphs = false; if ((*reply_it)->GetData().IsSetOrg()) { const COrg_ref& orp_req = **rq_it; const COrg_ref& orp_rep = (*reply_it)->GetData().GetOrg(); if (orp_req.IsSetTaxname() && orp_rep.IsSetTaxname()) { const string& taxname_req = orp_req.GetTaxname(); if (orp_rep.IsSetDb() && orp_req.IsSetDb()) { int taxid_req = 0; int taxid_rep = 0; FOR_EACH_DBXREF_ON_ORGREF (q_itr, orp_req) { const CDbtag& dbt = **q_itr; if (dbt.IsSetDb() && NStr::Equal(dbt.GetDb(), "taxon") && dbt.IsSetTag()) { const CObject_id& id = dbt.GetTag(); if (id.IsId()) { taxid_req = id.GetId(); } } } FOR_EACH_DBXREF_ON_ORGREF (p_itr, orp_rep) { const CDbtag& dbt = **p_itr; if (dbt.IsSetDb() && NStr::Equal(dbt.GetDb(), "taxon") && dbt.IsSetTag()) { const CObject_id& id = dbt.GetTag(); if (id.IsId()) { taxid_rep = id.GetId(); } } } if (taxid_req != taxid_rep) { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_TaxonomyLookupProblem, "Organism name is '" + taxname_req + "', taxonomy ID should be '" + NStr::IntToString (taxid_rep) + "' but is " + NStr::IntToString (taxid_req) + "'", org); } } } } (*reply_it)->GetData().GetTaxFlags(is_species_level, force_consult, has_nucleomorphs); if (!is_species_level && ! IsWP()) { PostErr (eDiag_Warning, eErr_SEQ_DESCR_TaxonomyIsSpeciesProblem, "Taxonomy lookup reports is_species_level FALSE", org); } if (force_consult) { PostErr (eDiag_Warning, eErr_SEQ_DESCR_TaxonomyConsultRequired, "Taxonomy lookup reports taxonomy consultation needed", org); } if (genome == CBioSource::eGenome_nucleomorph && !has_nucleomorphs) { PostErr (eDiag_Warning, eErr_SEQ_DESCR_TaxonomyNucleomorphProblem, "Taxonomy lookup does not have expected nucleomorph flag", org); } } ++reply_it; ++rq_it; } } // Now look at specific-host values org_rq_list.clear(); FOR_EACH_ORGMOD_ON_ORGREF (mod_it, org) { if ((*mod_it)->IsSetSubtype() && (*mod_it)->GetSubtype() == COrgMod::eSubtype_nat_host && (*mod_it)->IsSetSubname() && isupper ((*mod_it)->GetSubname().c_str()[0])) { string host = SpecificHostValueToCheck((*mod_it)->GetSubname()); if (!NStr::IsBlank(host)) { CRef<COrg_ref> rq(new COrg_ref); rq->SetTaxname(host); org_rq_list.push_back(rq); } } } if (org_rq_list.size() > 0) { reply = taxon3.SendOrgRefList(org_rq_list); if (reply) { CTaxon3_reply::TReply::const_iterator reply_it = reply->GetReply().begin(); vector< CRef<COrg_ref> >::iterator rq_it = org_rq_list.begin(); while (reply_it != reply->GetReply().end() && rq_it != org_rq_list.end()) { string host = (*rq_it)->GetTaxname(); if ((*reply_it)->IsError()) { string err_str = "?"; if ((*reply_it)->GetError().IsSetMessage()) { err_str = (*reply_it)->GetError().GetMessage(); } if(NStr::Find(err_str, "ambiguous") != string::npos) { PostErr (eDiag_Info, eErr_SEQ_DESCR_AmbiguousSpecificHost, "Specific host value is ambiguous: " + host, org); } else { PostErr (eDiag_Warning, eErr_SEQ_DESCR_BadSpecificHost, "Invalid value for specific host: " + host, org); } } else if ((*reply_it)->IsData()) { if (HasMisSpellFlag((*reply_it)->GetData())) { PostErr (eDiag_Warning, eErr_SEQ_DESCR_BadSpecificHost, "Specific host value is misspelled: " + host, org); } else if ((*reply_it)->GetData().IsSetOrg()) { if ( ! FindMatchInOrgRef (host, (*reply_it)->GetData().GetOrg()) && ! IsCommonName((*reply_it)->GetData())) { PostErr (eDiag_Warning, eErr_SEQ_DESCR_BadSpecificHost, "Specific host value is incorrectly capitalized: " + host, org); } } else { PostErr (eDiag_Warning, eErr_SEQ_DESCR_BadSpecificHost, "Invalid value for specific host: " + host, org); } } ++reply_it; ++rq_it; } } } } CPCRSet::CPCRSet(size_t pos) : m_OrigPos (pos) { } CPCRSet::~CPCRSet(void) { } CPCRSetList::CPCRSetList(void) { m_SetList.clear(); } CPCRSetList::~CPCRSetList(void) { for (size_t i = 0; i < m_SetList.size(); i++) { delete m_SetList[i]; } m_SetList.clear(); } void CPCRSetList::AddFwdName (string name) { unsigned int pcr_num = 0; if (NStr::StartsWith(name, "(") && NStr::EndsWith(name, ")") && NStr::Find(name, ",") != string::npos) { name = name.substr(1, name.length() - 2); vector<string> mult_names; NStr::Tokenize(name, ",", mult_names); unsigned int name_num = 0; while (name_num < mult_names.size()) { while (pcr_num < m_SetList.size() && !NStr::IsBlank(m_SetList[pcr_num]->GetFwdName())) { pcr_num++; } if (pcr_num == m_SetList.size()) { m_SetList.push_back(new CPCRSet(pcr_num)); } m_SetList[pcr_num]->SetFwdName(mult_names[name_num]); name_num++; pcr_num++; } } else { while (pcr_num < m_SetList.size() && !NStr::IsBlank(m_SetList[pcr_num]->GetFwdName())) { pcr_num++; } if (pcr_num == m_SetList.size()) { m_SetList.push_back(new CPCRSet(pcr_num)); } m_SetList[pcr_num]->SetFwdName(name); } } void CPCRSetList::AddRevName (string name) { unsigned int pcr_num = 0; if (NStr::StartsWith(name, "(") && NStr::EndsWith(name, ")") && NStr::Find(name, ",") != string::npos) { name = name.substr(1, name.length() - 2); vector<string> mult_names; NStr::Tokenize(name, ",", mult_names); unsigned int name_num = 0; while (name_num < mult_names.size()) { while (pcr_num < m_SetList.size() && !NStr::IsBlank(m_SetList[pcr_num]->GetRevName())) { pcr_num++; } if (pcr_num == m_SetList.size()) { m_SetList.push_back(new CPCRSet(pcr_num)); } m_SetList[pcr_num]->SetRevName(mult_names[name_num]); name_num++; pcr_num++; } } else { while (pcr_num < m_SetList.size() && !NStr::IsBlank(m_SetList[pcr_num]->GetRevName())) { pcr_num++; } if (pcr_num == m_SetList.size()) { m_SetList.push_back(new CPCRSet(pcr_num)); } m_SetList[pcr_num]->SetRevName(name); } } void CPCRSetList::AddFwdSeq (string name) { unsigned int pcr_num = 0; if (NStr::StartsWith(name, "(") && NStr::EndsWith(name, ")") && NStr::Find(name, ",") != string::npos) { name = name.substr(1, name.length() - 2); vector<string> mult_names; NStr::Tokenize(name, ",", mult_names); unsigned int name_num = 0; while (name_num < mult_names.size()) { while (pcr_num < m_SetList.size() && !NStr::IsBlank(m_SetList[pcr_num]->GetFwdSeq())) { pcr_num++; } if (pcr_num == m_SetList.size()) { m_SetList.push_back(new CPCRSet(pcr_num)); } m_SetList[pcr_num]->SetFwdSeq(mult_names[name_num]); name_num++; pcr_num++; } } else { while (pcr_num < m_SetList.size() && !NStr::IsBlank(m_SetList[pcr_num]->GetFwdSeq())) { pcr_num++; } if (pcr_num == m_SetList.size()) { m_SetList.push_back(new CPCRSet(pcr_num)); } m_SetList[pcr_num]->SetFwdSeq(name); } } void CPCRSetList::AddRevSeq (string name) { unsigned int pcr_num = 0; if (NStr::StartsWith(name, "(") && NStr::EndsWith(name, ")") && NStr::Find(name, ",") != string::npos) { name = name.substr(1, name.length() - 2); vector<string> mult_names; NStr::Tokenize(name, ",", mult_names); unsigned int name_num = 0; while (name_num < mult_names.size()) { while (pcr_num < m_SetList.size() && !NStr::IsBlank(m_SetList[pcr_num]->GetRevSeq())) { pcr_num++; } if (pcr_num == m_SetList.size()) { m_SetList.push_back(new CPCRSet(pcr_num)); } m_SetList[pcr_num]->SetRevSeq(mult_names[name_num]); name_num++; pcr_num++; } } else { while (pcr_num < m_SetList.size() && !NStr::IsBlank(m_SetList[pcr_num]->GetRevSeq())) { pcr_num++; } if (pcr_num == m_SetList.size()) { m_SetList.push_back(new CPCRSet(pcr_num)); } m_SetList[pcr_num]->SetRevSeq(name); } } static bool s_PCRSetCompare ( const CPCRSet* p1, const CPCRSet* p2 ) { int compare = NStr::CompareNocase(p1->GetFwdSeq(), p2->GetFwdSeq()); if (compare < 0) { return true; } else if (compare > 0) { return false; } else if ((compare = NStr::CompareNocase(p1->GetRevSeq(), p2->GetRevSeq())) < 0) { return true; } else if (compare > 0) { return false; } else if ((compare = NStr::CompareNocase(p1->GetFwdName(), p2->GetFwdName())) < 0) { return true; } else if (compare > 0) { return false; } else if ((compare = NStr::CompareNocase(p1->GetRevName(), p2->GetRevName())) < 0) { return true; } else if (p1->GetOrigPos() < p2->GetOrigPos()) { return true; } else { return false; } } static bool s_PCRSetEqual ( const CPCRSet* p1, const CPCRSet* p2 ) { if (NStr::EqualNocase(p1->GetFwdSeq(), p2->GetFwdSeq()) && NStr::EqualNocase(p1->GetRevSeq(), p2->GetRevSeq()) && NStr::EqualNocase(p1->GetFwdName(), p2->GetFwdName()) && NStr::EqualNocase(p1->GetRevName(), p2->GetRevName())) { return true; } else { return false; } } bool CPCRSetList::AreSetsUnique(void) { stable_sort (m_SetList.begin(), m_SetList.end(), s_PCRSetCompare); return seq_mac_is_unique (m_SetList.begin(), m_SetList.end(), s_PCRSetEqual); } // ===== for validating instituation and collection codes in specimen-voucher, ================ void CValidError_imp::ValidateOrgModVoucher(const COrgMod& orgmod, const CSerialObject& obj, const CSeq_entry *ctx) { if (!orgmod.IsSetSubtype() || !orgmod.IsSetSubname() || NStr::IsBlank(orgmod.GetSubname())) { return; } int subtype = orgmod.GetSubtype(); string val = orgmod.GetSubname(); string error = ""; switch (subtype) { case COrgMod::eSubtype_culture_collection: error = COrgMod::IsCultureCollectionValid(val); break; case COrgMod::eSubtype_bio_material: error = COrgMod::IsBiomaterialValid(val); break; case COrgMod::eSubtype_specimen_voucher: error = COrgMod::IsSpecimenVoucherValid(val); break; default: break; } if (NStr::IsBlank(error)) { // do nothing } else if (NStr::FindNoCase(error, "should be structured") != string::npos) { PostObjErr(eDiag_Error, eErr_SEQ_DESCR_UnstructuredVoucher, error, obj, ctx); } else if (NStr::FindNoCase(error, "missing institution code") != string::npos) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BadInstitutionCode, error, obj, ctx); } else if (NStr::FindNoCase(error, "missing specific identifier") != string::npos) { PostObjErr(eDiag_Warning, eErr_SEQ_DESCR_BadVoucherID, error, obj, ctx); } else if (NStr::FindNoCase(error, "should be") != string::npos) { EDiagSev level = eDiag_Info; if (NStr::StartsWith(error, "DNA")) { level = eDiag_Warning; } PostObjErr(level, eErr_SEQ_DESCR_WrongVoucherType, error, obj, ctx); } else if (NStr::StartsWith(error, "Personal")) { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_MissingPersonalCollectionName, error, obj, ctx); } else if (NStr::FindNoCase(error, "should not be qualified with a <COUNTRY> designation") != string::npos) { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_BadInstitutionCountry, error, obj, ctx); } else if (NStr::FindNoCase(error, "needs to be qualified with a <COUNTRY> designation") != string::npos) { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_BadInstitutionCode, error, obj, ctx); } else if (NStr::FindNoCase(error, " exists, but collection ") != string::npos) { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_BadCollectionCode, error, obj, ctx); } else { PostObjErr (eDiag_Warning, eErr_SEQ_DESCR_BadInstitutionCode, error, obj, ctx); } } END_SCOPE(validator) END_SCOPE(objects) END_NCBI_SCOPE

source navigation ]   [ diff markup ]   [ identifier search ]   [ freetext search ]   [ file search ]  

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.