3
$\begingroup$

I've run some calculations with the xtb software. From its output I got XYZ and MOL files with the system's structure information, and also a charge file with the calculated charges.

I would like to merge these two files into one or to create a new one (one that supports the charges like MOL or MOL2) with the charges added.

As there are a lot of files to merge, making the process automatic will decrease the errors.

Here is the MOL output:

 xtb: 6.5.1 (579679a)
          08092221593D

140170  0     0  0            999 V2000
    2.6154    6.4064    0.9956 C   0  0  0  0  0  0  0  0  0  0  0  0
    4.8578    2.7738    1.5382 C   0  0  0  0  0  0  0  0  0  0  0  0
    8.7755    1.6888    2.8422 C   0  0  0  0  0  0  0  0  0  0  0  0
   12.3803    4.0139    3.6724 C   0  0  0  0  0  0  0  0  0  0  0  0
   14.4811    8.0604    3.5495 C   0  0  0  0  0  0  0  0  0  0  0  0
   14.7628   12.5956    3.8804 C   0  0  0  0  0  0  0  0  0  0  0  0
   12.2314   15.9121    5.2439 C   0  0  0  0  0  0  0  0  0  0  0  0
    8.0491   16.1020    6.2971 C   0  0  0  0  0  0  0  0  0  0  0  0
    4.3849   13.8269    6.4268 C   0  0  0  0  0  0  0  0  0  0  0  0
    1.9317   10.3116    6.0240 C   0  0  0  0  0  0  0  0  0  0  0  0
    2.5655    5.6280    2.1771 C   0  0  0  0  0  0  0  0  0  0  0  0
    5.1268    2.3726    2.8718 C   0  0  0  0  0  0  0  0  0  0  0  0
    9.0773    2.2650    4.1013 C   0  0  0  0  0  0  0  0  0  0  0  0
   12.0035    5.2635    4.2054 C   0  0  0  0  0  0  0  0  0  0  0  0
   13.5944    9.1063    3.2349 C   0  0  0  0  0  0  0  0  0  0  0  0
   13.8120   13.3380    3.1439 C   0  0  0  0  0  0  0  0  0  0  0  0
   11.1970   16.3391    4.3698 C   0  0  0  0  0  0  0  0  0  0  0  0
    7.1033   16.0816    5.2396 C   0  0  0  0  0  0  0  0  0  0  0  0
    3.7923   13.4377    5.2013 C   0  0  0  0  0  0  0  0  0  0  0  0
    1.8727    9.6802    4.7586 C   0  0  0  0  0  0  0  0  0  0  0  0
    2.3785    7.7477    1.0115 C   0  0  0  0  0  0  0  0  0  0  0  0
    3.9239    3.7276    1.2646 C   0  0  0  0  0  0  0  0  0  0  0  0
    7.4778    1.5634    2.4333 C   0  0  0  0  0  0  0  0  0  0  0  0
   11.4867    2.9689    3.6452 C   0  0  0  0  0  0  0  0  0  0  0  0
   14.0231    6.7778    3.7699 C   0  0  0  0  0  0  0  0  0  0  0  0
   14.8634   11.2314    3.7574 C   0  0  0  0  0  0  0  0  0  0  0  0
   13.2537   15.1192    4.8081 C   0  0  0  0  0  0  0  0  0  0  0  0
    9.3682   16.3578    6.0715 C   0  0  0  0  0  0  0  0  0  0  0  0
    5.3899   14.7451    6.4745 C   0  0  0  0  0  0  0  0  0  0  0  0
    2.4918   11.5427    6.1782 C   0  0  0  0  0  0  0  0  0  0  0  0
    2.0483    6.2519    3.3426 C   0  0  0  0  0  0  0  0  0  0  0  0
    4.1735    2.7427    3.8532 C   0  0  0  0  0  0  0  0  0  0  0  0
    8.0189    2.3406    5.0369 C   0  0  0  0  0  0  0  0  0  0  0  0
   10.7860    5.3145    4.9239 C   0  0  0  0  0  0  0  0  0  0  0  0
   12.2136    8.7905    3.1968 C   0  0  0  0  0  0  0  0  0  0  0  0
   13.1029   12.6442    2.1282 C   0  0  0  0  0  0  0  0  0  0  0  0
   11.4425   16.2051    2.9792 C   0  0  0  0  0  0  0  0  0  0  0  0
    7.5166   16.6283    3.9997 C   0  0  0  0  0  0  0  0  0  0  0  0
    4.1292   14.1863    4.0465 C   0  0  0  0  0  0  0  0  0  0  0  0
    2.2291   10.4449    3.6202 C   0  0  0  0  0  0  0  0  0  0  0  0
    1.7997    5.4842    4.5093 C   0  0  0  0  0  0  0  0  0  0  0  0
    4.3387    2.3324    5.2019 C   0  0  0  0  0  0  0  0  0  0  0  0
    8.1671    3.0483    6.2595 C   0  0  0  0  0  0  0  0  0  0  0  0
   10.1209    6.5319    5.2123 C   0  0  0  0  0  0  0  0  0  0  0  0
   11.2534    9.6203    2.5774 C   0  0  0  0  0  0  0  0  0  0  0  0
   12.3500   13.3264    1.1466 C   0  0  0  0  0  0  0  0  0  0  0  0
   10.5758   16.8019    2.0305 C   0  0  0  0  0  0  0  0  0  0  0  0
    6.5915   16.7546    2.9314 C   0  0  0  0  0  0  0  0  0  0  0  0
    3.5515   13.8555    2.7932 C   0  0  0  0  0  0  0  0  0  0  0  0
    2.1840    9.8586    2.3280 C   0  0  0  0  0  0  0  0  0  0  0  0
    2.1162    8.4415    2.2180 C   0  0  0  0  0  0  0  0  0  0  0  0
    3.1644    4.3427    2.2940 C   0  0  0  0  0  0  0  0  0  0  0  0
    6.3936    1.8785    3.2932 C   0  0  0  0  0  0  0  0  0  0  0  0
   10.2644    3.0226    4.3495 C   0  0  0  0  0  0  0  0  0  0  0  0
   12.6538    6.5197    3.9629 C   0  0  0  0  0  0  0  0  0  0  0  0
   13.8757   10.5024    3.0610 C   0  0  0  0  0  0  0  0  0  0  0  0
   13.2525   14.6070    3.4858 C   0  0  0  0  0  0  0  0  0  0  0  0
    9.8563   16.6076    4.7638 C   0  0  0  0  0  0  0  0  0  0  0  0
    5.8565   15.3993    5.3093 C   0  0  0  0  0  0  0  0  0  0  0  0
    2.9690   12.2844    5.0728 C   0  0  0  0  0  0  0  0  0  0  0  0
    1.8844    7.6630    3.3789 C   0  0  0  0  0  0  0  0  0  0  0  0
    3.1807    3.7133    3.5633 C   0  0  0  0  0  0  0  0  0  0  0  0
    6.6914    2.0049    4.6747 C   0  0  0  0  0  0  0  0  0  0  0  0
   10.0670    4.1338    5.2103 C   0  0  0  0  0  0  0  0  0  0  0  0
   11.7676    7.6173    3.8365 C   0  0  0  0  0  0  0  0  0  0  0  0
   12.9660   11.2456    2.2735 C   0  0  0  0  0  0  0  0  0  0  0  0
   12.3952   15.2449    2.5579 C   0  0  0  0  0  0  0  0  0  0  0  0
    8.8910   16.8909    3.7647 C   0  0  0  0  0  0  0  0  0  0  0  0
    5.1088   15.2137    4.1167 C   0  0  0  0  0  0  0  0  0  0  0  0
    2.6925   11.7802    3.7750 C   0  0  0  0  0  0  0  0  0  0  0  0
    1.1823    6.1326    5.6093 C   0  0  0  0  0  0  0  0  0  0  0  0
    3.2381    2.5050    6.0837 C   0  0  0  0  0  0  0  0  0  0  0  0
    7.2235    2.8209    7.2901 C   0  0  0  0  0  0  0  0  0  0  0  0
    9.1335    6.5533    6.2147 C   0  0  0  0  0  0  0  0  0  0  0  0
    9.8922    9.4440    2.8898 C   0  0  0  0  0  0  0  0  0  0  0  0
   11.4589   12.5836    0.3322 C   0  0  0  0  0  0  0  0  0  0  0  0
   10.8812   16.6308    0.6495 C   0  0  0  0  0  0  0  0  0  0  0  0
    7.0004   17.5061    1.7965 C   0  0  0  0  0  0  0  0  0  0  0  0
    3.7126   14.7775    1.7314 C   0  0  0  0  0  0  0  0  0  0  0  0
    2.3234   10.7199    1.2150 C   0  0  0  0  0  0  0  0  0  0  0  0
    1.5821    8.2989    4.6110 C   0  0  0  0  0  0  0  0  0  0  0  0
    2.3389    4.1816    4.6048 C   0  0  0  0  0  0  0  0  0  0  0  0
    5.6556    2.0803    5.6374 C   0  0  0  0  0  0  0  0  0  0  0  0
    9.0411    4.1580    6.1804 C   0  0  0  0  0  0  0  0  0  0  0  0
   10.4451    7.5992    4.3331 C   0  0  0  0  0  0  0  0  0  0  0  0
   11.7517   10.6933    1.7928 C   0  0  0  0  0  0  0  0  0  0  0  0
   12.2292   14.7312    1.2441 C   0  0  0  0  0  0  0  0  0  0  0  0
    9.3032   17.2384    2.4518 C   0  0  0  0  0  0  0  0  0  0  0  0
    5.4037   15.9878    2.9656 C   0  0  0  0  0  0  0  0  0  0  0  0
    2.9370   12.5850    2.6348 C   0  0  0  0  0  0  0  0  0  0  0  0
    1.1060    7.4876    5.6696 C   0  0  0  0  0  0  0  0  0  0  0  0
    2.2582    3.3935    5.7862 C   0  0  0  0  0  0  0  0  0  0  0  0
    6.0214    2.2581    7.0022 C   0  0  0  0  0  0  0  0  0  0  0  0
    8.7063    5.3904    6.7904 C   0  0  0  0  0  0  0  0  0  0  0  0
    9.5223    8.5497    3.8597 C   0  0  0  0  0  0  0  0  0  0  0  0
   11.0732   11.3403    0.7420 C   0  0  0  0  0  0  0  0  0  0  0  0
   11.6303   15.5656    0.2674 C   0  0  0  0  0  0  0  0  0  0  0  0
    8.3155   17.7389    1.5616 C   0  0  0  0  0  0  0  0  0  0  0  0
    4.5773   15.8218    1.8258 C   0  0  0  0  0  0  0  0  0  0  0  0
    2.6471   12.0340    1.3638 C   0  0  0  0  0  0  0  0  0  0  0  0
    2.8822    5.9347    0.0623 H   0  0  0  0  0  0  0  0  0  0  0  0
    5.4684    2.3857    0.7370 H   0  0  0  0  0  0  0  0  0  0  0  0
    9.5780    1.4859    2.1486 H   0  0  0  0  0  0  0  0  0  0  0  0
   13.3259    3.9246    3.1576 H   0  0  0  0  0  0  0  0  0  0  0  0
   15.5442    8.2537    3.5477 H   0  0  0  0  0  0  0  0  0  0  0  0
   15.4188   13.1152    4.5637 H   0  0  0  0  0  0  0  0  0  0  0  0
   12.1781   16.1740    6.2901 H   0  0  0  0  0  0  0  0  0  0  0  0
    7.7339   15.8416    7.2958 H   0  0  0  0  0  0  0  0  0  0  0  0
    4.0866   13.3367    7.3404 H   0  0  0  0  0  0  0  0  0  0  0  0
    1.5927    9.7794    6.8990 H   0  0  0  0  0  0  0  0  0  0  0  0
    2.4639    8.3002    0.0888 H   0  0  0  0  0  0  0  0  0  0  0  0
    3.8109    4.0686    0.2469 H   0  0  0  0  0  0  0  0  0  0  0  0
    7.2725    1.2664    1.4155 H   0  0  0  0  0  0  0  0  0  0  0  0
   11.7249    2.0829    3.0746 H   0  0  0  0  0  0  0  0  0  0  0  0
   14.7318    5.9701    3.8829 H   0  0  0  0  0  0  0  0  0  0  0  0
   15.6161   10.6960    4.3178 H   0  0  0  0  0  0  0  0  0  0  0  0
   13.9932   14.7651    5.5108 H   0  0  0  0  0  0  0  0  0  0  0  0
   10.0670   16.2875    6.8912 H   0  0  0  0  0  0  0  0  0  0  0  0
    5.8578   14.9567    7.4236 H   0  0  0  0  0  0  0  0  0  0  0  0
    2.5740   11.9580    7.1708 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.8329    5.5465    6.4447 H   0  0  0  0  0  0  0  0  0  0  0  0
    3.2195    1.9677    7.0198 H   0  0  0  0  0  0  0  0  0  0  0  0
    7.4570    3.1395    8.2953 H   0  0  0  0  0  0  0  0  0  0  0  0
    8.7267    7.5030    6.5288 H   0  0  0  0  0  0  0  0  0  0  0  0
    9.1601   10.0959    2.4370 H   0  0  0  0  0  0  0  0  0  0  0  0
   10.9540   13.0736   -0.4860 H   0  0  0  0  0  0  0  0  0  0  0  0
   10.3958   17.2479   -0.0899 H   0  0  0  0  0  0  0  0  0  0  0  0
    6.2625   17.8432    1.0853 H   0  0  0  0  0  0  0  0  0  0  0  0
    3.1458   14.6441    0.8228 H   0  0  0  0  0  0  0  0  0  0  0  0
    2.1745   10.3292    0.2202 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.6889    7.9539    6.5489 H   0  0  0  0  0  0  0  0  0  0  0  0
    1.4525    3.5570    6.4847 H   0  0  0  0  0  0  0  0  0  0  0  0
    5.2888    2.1084    7.7794 H   0  0  0  0  0  0  0  0  0  0  0  0
    7.9753    5.4063    7.5844 H   0  0  0  0  0  0  0  0  0  0  0  0
    8.5000    8.5068    4.2048 H   0  0  0  0  0  0  0  0  0  0  0  0
   10.2424   10.8390    0.2682 H   0  0  0  0  0  0  0  0  0  0  0  0
   11.7390   15.3140   -0.7771 H   0  0  0  0  0  0  0  0  0  0  0  0
    8.6218   18.2523    0.6630 H   0  0  0  0  0  0  0  0  0  0  0  0
    4.6873   16.4912    0.9873 H   0  0  0  0  0  0  0  0  0  0  0  0
    2.7536   12.6473    0.4827 H   0  0  0  0  0  0  0  0  0  0  0  0
  1 11  4  0  0  0  0
  2 12  4  0  0  0  0
  3 13  4  0  0  0  0
  4 14  4  0  0  0  0
  5 15  4  0  0  0  0
  6 16  4  0  0  0  0
  7 17  4  0  0  0  0
  8 18  4  0  0  0  0
  9 19  4  0  0  0  0
 10 20  4  0  0  0  0
  1 21  2  0  0  0  0
  2 22  2  0  0  0  0
  3 23  2  0  0  0  0
  4 24  2  0  0  0  0
  5 25  2  0  0  0  0
  6 26  2  0  0  0  0
  7 27  2  0  0  0  0
  8 28  2  0  0  0  0
  9 29  2  0  0  0  0
 10 30  2  0  0  0  0
 11 31  4  0  0  0  0
 12 32  4  0  0  0  0
 13 33  4  0  0  0  0
 14 34  4  0  0  0  0
 15 35  4  0  0  0  0
 16 36  4  0  0  0  0
 17 37  4  0  0  0  0
 18 38  4  0  0  0  0
 19 39  4  0  0  0  0
 20 40  4  0  0  0  0
 31 41  4  0  0  0  0
 32 42  4  0  0  0  0
 33 43  4  0  0  0  0
 34 44  4  0  0  0  0
 35 45  4  0  0  0  0
 36 46  4  0  0  0  0
 37 47  4  0  0  0  0
 38 48  4  0  0  0  0
 39 49  4  0  0  0  0
 40 50  4  0  0  0  0
 21 51  4  0  0  0  0
 50 51  4  0  0  0  0
 11 52  4  0  0  0  0
 22 52  4  0  0  0  0
 12 53  4  0  0  0  0
 23 53  4  0  0  0  0
 13 54  4  0  0  0  0
 24 54  4  0  0  0  0
 14 55  1  0  0  0  0
 25 55  4  0  0  0  0
 15 56  1  0  0  0  0
 26 56  4  0  0  0  0
 16 57  4  0  0  0  0
 27 57  4  0  0  0  0
 17 58  4  0  0  0  0
 28 58  4  0  0  0  0
 18 59  4  0  0  0  0
 29 59  4  0  0  0  0
 19 60  4  0  0  0  0
 30 60  4  0  0  0  0
 31 61  4  0  0  0  0
 51 61  4  0  0  0  0
 32 62  4  0  0  0  0
 52 62  4  0  0  0  0
 33 63  4  0  0  0  0
 53 63  4  0  0  0  0
 34 64  4  0  0  0  0
 54 64  4  0  0  0  0
 35 65  4  0  0  0  0
 55 65  4  0  0  0  0
 36 66  4  0  0  0  0
 56 66  4  0  0  0  0
 37 67  4  0  0  0  0
 57 67  4  0  0  0  0
 38 68  4  0  0  0  0
 58 68  4  0  0  0  0
 39 69  4  0  0  0  0
 59 69  4  0  0  0  0
 40 70  4  0  0  0  0
 60 70  4  0  0  0  0
 41 71  4  0  0  0  0
 42 72  4  0  0  0  0
 43 73  4  0  0  0  0
 44 74  4  0  0  0  0
 45 75  4  0  0  0  0
 46 76  4  0  0  0  0
 47 77  4  0  0  0  0
 48 78  4  0  0  0  0
 49 79  4  0  0  0  0
 50 80  4  0  0  0  0
 20 81  4  0  0  0  0
 61 81  4  0  0  0  0
 41 82  4  0  0  0  0
 62 82  4  0  0  0  0
 42 83  4  0  0  0  0
 63 83  4  0  0  0  0
 43 84  4  0  0  0  0
 64 84  4  0  0  0  0
 44 85  1  0  0  0  0
 65 85  4  0  0  0  0
 45 86  4  0  0  0  0
 66 86  4  0  0  0  0
 46 87  4  0  0  0  0
 67 87  4  0  0  0  0
 47 88  4  0  0  0  0
 68 88  4  0  0  0  0
 48 89  4  0  0  0  0
 69 89  4  0  0  0  0
 49 90  4  0  0  0  0
 70 90  4  0  0  0  0
 71 91  2  0  0  0  0
 81 91  4  0  0  0  0
 72 92  2  0  0  0  0
 82 92  4  0  0  0  0
 73 93  2  0  0  0  0
 83 93  4  0  0  0  0
 74 94  2  0  0  0  0
 84 94  4  0  0  0  0
 75 95  2  0  0  0  0
 85 95  4  0  0  0  0
 76 96  2  0  0  0  0
 86 96  4  0  0  0  0
 77 97  2  0  0  0  0
 87 97  4  0  0  0  0
 78 98  2  0  0  0  0
 88 98  4  0  0  0  0
 79 99  2  0  0  0  0
 89 99  4  0  0  0  0
 80100  2  0  0  0  0
 90100  4  0  0  0  0
  1101  1  0  0  0  0
  2102  1  0  0  0  0
  3103  1  0  0  0  0
  4104  1  0  0  0  0
  5105  1  0  0  0  0
  6106  1  0  0  0  0
  7107  1  0  0  0  0
  8108  1  0  0  0  0
  9109  1  0  0  0  0
 10110  1  0  0  0  0
 21111  1  0  0  0  0
 22112  1  0  0  0  0
 23113  1  0  0  0  0
 24114  1  0  0  0  0
 25115  1  0  0  0  0
 26116  1  0  0  0  0
 27117  1  0  0  0  0
 28118  1  0  0  0  0
 29119  1  0  0  0  0
 30120  1  0  0  0  0
 71121  1  0  0  0  0
 72122  1  0  0  0  0
 73123  1  0  0  0  0
 74124  1  0  0  0  0
 75125  1  0  0  0  0
 76126  1  0  0  0  0
 77127  1  0  0  0  0
 78128  1  0  0  0  0
 79129  1  0  0  0  0
 80130  1  0  0  0  0
 91131  1  0  0  0  0
 92132  1  0  0  0  0
 93133  1  0  0  0  0
 94134  1  0  0  0  0
 95135  1  0  0  0  0
 96136  1  0  0  0  0
 97137  1  0  0  0  0
 98138  1  0  0  0  0
 99139  1  0  0  0  0
100140  1  0  0  0  0
M  END

Here is the charge file:

   -0.03722231
   -0.03646360
   -0.03466408
   -0.03460579
   -0.03700567
   -0.03830432
   -0.03743637
   -0.03678821
   -0.03708334
   -0.03759946
    0.00341706
    0.00262820
    0.00029768
    0.00086030
    0.00393716
    0.00505315
    0.00341478
    0.00243039
    0.00241051
    0.00266387
   -0.03697613
   -0.03683137
   -0.03764684
   -0.03827265
   -0.03653021
   -0.03436292
   -0.03497639
   -0.03671793
   -0.03724731
   -0.03728009
    0.00104757
    0.00049263
    0.00207651
    0.00321830
    0.00222174
    0.00127540
    0.00206366
    0.00229686
    0.00224290
    0.00189821
    0.00330899
    0.00455347
    0.00472102
    0.00365930
    0.00259012
    0.00170297
    0.00134970
    0.00213949
    0.00282399
    0.00313627
    0.00237572
    0.00250757
    0.00375430
    0.00511583
    0.00341053
    0.00041637
    0.00067468
    0.00294210
    0.00339482
    0.00307549
    0.00225484
    0.00229451
    0.00190616
    0.00130541
    0.00249185
    0.00319625
    0.00168094
    0.00045411
    0.00125032
    0.00200113
   -0.03773413
   -0.03747374
   -0.03777553
   -0.03792015
   -0.03639454
   -0.03541961
   -0.03566344
   -0.03655314
   -0.03719833
   -0.03727186
    0.00273925
    0.00195800
    0.00134150
    0.00181929
    0.00281034
    0.00384329
    0.00486636
    0.00431232
    0.00314034
    0.00260470
   -0.03713453
   -0.03636143
   -0.03555836
   -0.03549570
   -0.03669229
   -0.03802718
   -0.03766679
   -0.03750089
   -0.03776054
   -0.03752020
    0.03161620
    0.03281056
    0.03326035
    0.03226115
    0.03226474
    0.03351993
    0.03406948
    0.03286813
    0.03183449
    0.03171993
    0.03197441
    0.03313788
    0.03413108
    0.03325210
    0.03214467
    0.03243500
    0.03333614
    0.03256787
    0.03146893
    0.03150533
    0.03233615
    0.03409028
    0.03608529
    0.03407825
    0.03155533
    0.03339691
    0.03529538
    0.03388412
    0.03228017
    0.03141505
    0.03254266
    0.03420700
    0.03527684
    0.03276537
    0.03177783
    0.03467319
    0.03596630
    0.03361589
    0.03217072
    0.03167577
$\endgroup$
5
  • 1
    $\begingroup$ +1. Do you have a small example of the data that you could include so that I can see if a merging technique works? $\endgroup$ Aug 10, 2022 at 20:12
  • $\begingroup$ hmm, out of the box no, but iodata could read in the XYZ, and then a simple python one liner could probably fetch the charges, and add them to the iodata object created for the XYZ, and then it is just a click of a button to output a mol2 file $\endgroup$
    – B. Kelly
    Aug 11, 2022 at 13:49
  • $\begingroup$ Hi @NikeDattani, I added the MOL and charges data. $\endgroup$
    – Camps
    Aug 11, 2022 at 14:17
  • $\begingroup$ Just to be clear, you would like the column in file.charge to be added as the last column in file.MOL, and you want to do this for 100s of files? $\endgroup$ Aug 11, 2022 at 20:37
  • $\begingroup$ Not as the last column, but in compliance with the file format definition. For example, for MOL v2000, the charges should be in the first column whereas for v3000, are in the third (the reference for the columns is after the atom type). The MOL2 format also accept the charges, but in the last column of atom data. $\endgroup$
    – Camps
    Aug 12, 2022 at 11:09

2 Answers 2

1
$\begingroup$

I used to really like the mol2 format because it was relatively well-supported and included partial charges.

The main problem is that support is really variable, so it's hard to rely on.

As it turns out, the sdf version of the MOL format, allows you to include properties.

For example, here's a file from PubChem:

19681234
  -OEChem-08122223273D

 32 32  0     0  0  0  0  0  0999 V2000
    1.4401    1.9561   -2.1702 Cl  0  0  0  0  0  0  0  0  0  0  0  0
    2.9365   -2.5423    1.8946 Cl  0  0  0  0  0  0  0  0  0  0  0  0
    4.2090   -2.4867   -1.0788 Cl  0  0  0  0  0  0  0  0  0  0  0  0
    0.1431    1.9226    0.8003 S   0  0  0  0  0  0  0  0  0  0  0  0
   -0.1372    1.6756    2.2019 O   0  0  0  0  0  0  0  0  0  0  0  0
    0.6636    3.2080    0.3757 O   0  0  0  0  0  0  0  0  0  0  0  0
   -1.2354    1.5538   -0.1239 N   0  0  0  0  0  0  0  0  0  0  0  0
   -3.3697    0.3545   -0.2414 C   0  0  0  0  0  0  0  0  0  0  0  0
   -4.0707   -0.9995   -0.1299 C   0  0  0  0  0  0  0  0  0  0  0  0
   -1.8701    0.2233   -0.0046 C   0  0  0  0  0  0  0  0  0  0  0  0
   -5.5689   -0.8747   -0.4053 C   0  0  0  0  0  0  0  0  0  0  0  0
[.. omitted ..]
    3.1687   -0.2515   -2.4240 H   0  0  0  0  0  0  0  0  0  0  0  0
  1 14  1  0  0  0  0
  2 16  1  0  0  0  0
  3 18  1  0  0  0  0
  4  5  2  0  0  0  0
  4  6  2  0  0  0  0
  4  7  1  0  0  0  0
  4 12  1  0  0  0  0
[ .. omitted .. ]
 16 18  2  0  0  0  0
 17 18  1  0  0  0  0
 17 32  1  0  0  0  0
M  END
> <PUBCHEM_COMPOUND_CID>
19681234

> <PUBCHEM_MMFF94_PARTIAL_CHARGES>
17
1 -0.18
10 0.36
12 -0.01
14 0.18
15 -0.15
16 0.18
17 -0.15
18 0.18
2 -0.18
27 0.42
3 -0.18
31 0.15

What I want to note is that the calculated partial charges are stored in a property. (The PubChem files store MMFF94 charges that are non-zero and for some reason list by alphabetically-sorted atom numbers, thus 1-10-12...)

It would be really easy to merge your files, e.g.;

for molfile in *.mol; do
  sdfile=${molfile%%.mol}.sdf # remove the .mol extension and add a .sdf
  cat ${molfile} >${sdfile}
  echo '> <PARTIAL_CHARGES>' >>${sdfile}
  cat charges >>${sdfile}
  echo >>${sdfile} # add an extra blank line
  echo '$$$$' >>${sdfile}
done

The resulting files will be readable by anything that reads .mol or .sdf files and the partial charges will be saved and/or processed later.

I'm using this scheme in Avogadro2 - it will look for "PARTIAL_CHARGES" fields in SDF files.

$\endgroup$
1
  • 1
    $\begingroup$ It's not hard to write a Python script with openbabel to read the charges from the file and save a mol2 but I'd generally recommend this approach. $\endgroup$ Aug 13, 2022 at 3:44
1
$\begingroup$

I have managed to make files called charge_MOL and MOL_charge.

charge_MOL has the charges added as the first column, as in the MOL_v2000 format (as explained in your comment). Here's the first few lines:

-0.03722231      2.6154    6.4064    0.9956 C   0  0  0  0  0  0  0  0  0  0  0  0
-0.03646360      4.8578    2.7738    1.5382 C   0  0  0  0  0  0  0  0  0  0  0  0
-0.03466408      8.7755    1.6888    2.8422 C   0  0  0  0  0  0  0  0  0  0  0  0
-0.03460579     12.3803    4.0139    3.6724 C   0  0  0  0  0  0  0  0  0  0  0  0
-0.03700567     14.4811    8.0604    3.5495 C   0  0  0  0  0  0  0  0  0  0  0  0
-0.03830432     14.7628   12.5956    3.8804 C   0  0  0  0  0  0  0  0  0  0  0  0
-0.03743637     12.2314   15.9121    5.2439 C   0  0  0  0  0  0  0  0  0  0  0  0
-0.03678821      8.0491   16.1020    6.2971 C   0  0  0  0  0  0  0  0  0  0  0  0
-0.03708334      4.3849   13.8269    6.4268 C   0  0  0  0  0  0  0  0  0  0  0  0
-0.03759946      1.9317   10.3116    6.0240 C   0  0  0  0  0  0  0  0  0  0  0  0

MOL_charge has them added as the last column, as your same comment describes for the MOL2 format. Here's the first few lines:

 2.6154    6.4064    0.9956 C   0  0  0  0  0  0  0  0  0  0  0  0      -0.03722231
 4.8578    2.7738    1.5382 C   0  0  0  0  0  0  0  0  0  0  0  0      -0.03646360
 8.7755    1.6888    2.8422 C   0  0  0  0  0  0  0  0  0  0  0  0      -0.03466408
12.3803    4.0139    3.6724 C   0  0  0  0  0  0  0  0  0  0  0  0      -0.03460579
14.4811    8.0604    3.5495 C   0  0  0  0  0  0  0  0  0  0  0  0      -0.03700567
14.7628   12.5956    3.8804 C   0  0  0  0  0  0  0  0  0  0  0  0      -0.03830432
12.2314   15.9121    5.2439 C   0  0  0  0  0  0  0  0  0  0  0  0      -0.03743637

In this GitHub repository there's a folder called "original" which has three MOL files and three charge files. I did the following:

cp -r original demonstration    # So the original files are saved (just in case)
sed -i '1,4d' MOL*              # Remove lines 1-4 in all files strating with "MOL"
paste charge1 MOL1 > charge_MOL # Creates file with charges in 1st column, then MOL
paste MOL1 charge1 > MOL_charge # Creates file with MOL, then charges in last col.

You can then modify this to do the last two lines in a loop, using the following resources:

For the horizontal concatenation, I used the paste command as it was the most highly upvoted answer to: Horizontal file concatenation (Unix/Linux Stack Exchange). The other answer recommends to use join but doesn't tell us how to use it.

For the removal of the first 4 lines, I slightly modified the second most highly upvoted answer from here: How can I remove the first line of a text file using bash/sed script? (StackOverflow). The most highly upvoted answer uses tail instead of sed, but I chose to use sed since I use it frequently for this type of thing (especially the -i option which allows us to avoid using > output.txt to output the file to output.txt).

$\endgroup$
1
  • $\begingroup$ Please don't do this. The resulting files won't be readable by any normal software because they don't adhere to the MDL Molfile (SDF) spec. $\endgroup$ Aug 13, 2022 at 3:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .