Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 writing in particular positions
#1
Dear friends,
I have a file with thousands of molecule coordinates. Everyone should have a name but unfortunately the names are missing. I have to put a name for everyone to start working. For example MOLECULE1, MOLECULE2, etc.
The file with five molecules is attached.
The names must be at the line just below @<TRIPOS>MOLECULE
Is there an easy way to do this?
Thank you very much.
Clara
Quote
#2
You can't do file attachments as a new poster. Please copy and past a few lines of the file into a post, perhaps in output tags (the button in the editor between the x and the []).
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures

Quote
#3
Thank you. I didn't know.

@<TRIPOS>MOLECULE

 49 52 0 0 0
SMALL
GASTEIGER

@<TRIPOS>ATOM
      1 C           3.2145    3.5607   -4.5647 C3      1  LIG1       -0.0308
      2 C           3.7870    4.4501   -3.4593 C3      1  LIG1        0.1352
      3 C           3.6398    3.7859   -2.1047 C2      1  LIG1        0.2511
      4 O           4.1284    2.7355   -1.7472 O2      1  LIG1       -0.2724
      5 N           2.8515    4.6051   -1.3810 Nam     1  LIG1       -0.2196
      6 C           2.4900    5.6869   -2.0803 C2      1  LIG1        0.3099
      7 O           1.7832    6.5716   -1.6389 O2      1  LIG1       -0.2522
      8 N           2.9962    5.6859   -3.3267 Nam     1  LIG1       -0.2813
      9 C           2.4456    4.3460    0.0026 C3      1  LIG1        0.0489
     10 C           1.1540    3.5697    0.0103 Car     1  LIG1       -0.0288
     11 C          -0.0555    4.2421    0.0255 Car     1  LIG1       -0.0570
     12 C          -1.2460    3.5373    0.0330 Car     1  LIG1       -0.0607
     13 C          -1.2346    2.1577    0.0196 Car     1  LIG1       -0.0478
     14 C          -0.0180    1.4730    0.0101 Car     1  LIG1        0.0593
     15 C           1.1799    2.1908    0.0026 Car     1  LIG1       -0.0431
     16 C           0.0021   -0.0041    0.0020 C2      1  LIG1        0.3389
     17 O           1.0621   -0.5970   -0.0113 O2      1  LIG1       -0.2450
     18 O          -1.1553   -0.6934    0.0094 O3      1  LIG1       -0.4645
     19 C          -1.0596   -2.1423    0.0007 C3      1  LIG1        0.0820
     20 C           5.2327    4.7730   -3.7362 Car     1  LIG1       -0.0118
     21 C           6.2282    3.9309   -3.2765 Car     1  LIG1       -0.0524
     22 C           7.5551    4.2237   -3.5282 Car     1  LIG1       -0.0159
     23 C           7.8917    5.3638   -4.2429 Car     1  LIG1        0.1621
     24 C           6.8910    6.2095   -4.7063 Car     1  LIG1        0.1624
     25 C           5.5609    5.9073   -4.4542 Car     1  LIG1       -0.0106
     26 O           7.1988    7.3311   -5.4133 O3      1  LIG1       -0.4849
     27 C           8.5508    7.7945   -5.3277 C3      1  LIG1        0.1237
     28 C           9.4839    6.5904   -5.5137 C3      1  LIG1        0.1237
     29 O           9.2030    5.6415   -4.4790 O3      1  LIG1       -0.4849
     30 H           3.2495    4.0938   -5.5148 1       1  LIG1        0.0258
     31 H           3.8049    2.6474   -4.6386 1       1  LIG1        0.0258
     32 H           2.1811    3.3071   -4.3283 1       1  LIG1        0.0258
     33 H           2.8663    6.3665   -4.0056 1       1  LIG1        0.1516
     34 H           2.3033    5.2932    0.5229 1       1  LIG1        0.0519
     35 H           3.2201    3.7676    0.5062 1       1  LIG1        0.0519
     36 H          -0.0702    5.3220    0.0311 1       1  LIG1        0.0621
     37 H          -2.1864    4.0682    0.0446 1       1  LIG1        0.0618
     38 H          -2.1646    1.6088    0.0206 1       1  LIG1        0.0626
     39 H           2.1245    1.6673   -0.0090 1       1  LIG1        0.0629
     40 H          -0.5315   -2.4661   -0.8961 1       1  LIG1        0.0661
     41 H          -0.5145   -2.4757    0.8837 1       1  LIG1        0.0661
     42 H          -2.0611   -2.5725    0.0079 1       1  LIG1        0.0661
     43 H           5.9684    3.0426   -2.7200 1       1  LIG1        0.0622
     44 H           8.3308    3.5644   -3.1678 1       1  LIG1        0.0655
     45 H           4.7812    6.5614   -4.8156 1       1  LIG1        0.0659
     46 H           8.7236    8.2460   -4.3508 1       1  LIG1        0.0731
     47 H           8.7384    8.5294   -6.1106 1       1  LIG1        0.0731
     48 H          10.5219    6.9152   -5.4427 1       1  LIG1        0.0731
     49 H           9.3073    6.1348   -6.4881 1       1  LIG1        0.0731
@<TRIPOS>BOND
     1     1     2    1
     2     1    30    1
     3     1    31    1
     4     1    32    1
     5     2     8    1
     6     2     3    1
     7     2    20    1
     8     3     4    2
     9     3     5   am
    10     5     6   am
    11     5     9    1
    12     6     7    2
    13     6     8   am
    14     8    33    1
    15     9    10    1
    16     9    34    1
    17     9    35    1
    18    10    15   ar
    19    10    11   ar
    20    11    12   ar
    21    11    36    1
    22    12    13   ar
    23    12    37    1
    24    13    14   ar
    25    13    38    1
    26    14    15   ar
    27    14    16    1
    28    15    39    1
    29    16    17    2
    30    16    18    1
    31    18    19    1
    32    19    40    1
    33    19    41    1
    34    19    42    1
    35    20    25   ar
    36    20    21   ar
    37    21    22   ar
    38    21    43    1
    39    22    23   ar
    40    22    44    1
    41    23    29    1
    42    23    24   ar
    43    24    25   ar
    44    24    26    1
    45    25    45    1
    46    26    27    1
    47    27    28    1
    48    27    46    1
    49    27    47    1
    50    28    29    1
    51    28    48    1
    52    28    49    1
@<TRIPOS>MOLECULE

 53 54 0 0 0
SMALL
GASTEIGER

@<TRIPOS>ATOM
      1 C           5.5013   -0.3856    1.7029 C3      1  LIG1       -0.0489
      2 C           5.0325   -0.3046    0.2487 C3      1  LIG1        0.0171
      3 N           3.6496   -0.7786    0.1542 Nam     1  LIG1       -0.2686
      4 C           2.5909    0.1335    0.2264 Car     1  LIG1        0.0364
      5 C           1.2897   -0.2907   -0.0094 Car     1  LIG1       -0.0403
      6 C           0.2470    0.6122    0.0622 Car     1  LIG1       -0.0600
      7 C           0.4976    1.9372    0.3682 Car     1  LIG1       -0.0616
      8 C           1.7921    2.3627    0.6034 Car     1  LIG1       -0.0600
      9 C           2.8392    1.4649    0.5335 Car     1  LIG1       -0.0403
     10 C           3.3970   -2.0932   -0.0021 C2      1  LIG1        0.2604
     11 O           2.2571   -2.4775   -0.1576 O2      1  LIG1       -0.2712
     12 C           4.5308   -3.0858    0.0162 C3      1  LIG1        0.1763
     13 H           5.2437   -2.8088    0.7928 1       1  LIG1        0.0830
     14 C           5.2320   -3.0842   -1.3437 C3      1  LIG1       -0.0189
     15 O           4.0165   -4.3916    0.2854 O3      1  LIG1       -0.4491
     16 C           4.8315   -5.2491    0.9344 C2      1  LIG1        0.3327
     17 O           5.9486   -4.8964    1.2623 O2      1  LIG1       -0.2456
     18 C           4.3858   -6.5612    1.2340 C2      1  LIG1        0.0231
     19 C           5.2018   -7.4198    1.8838 C2      1  LIG1       -0.0477
     20 C           4.7399   -8.7799    2.1944 Car     1  LIG1       -0.0211
     21 C           3.4549   -9.1879    1.8180 Car     1  LIG1       -0.0509
     22 C           3.0245  -10.4632    2.1105 Car     1  LIG1       -0.0157
     23 C           3.8624  -11.3468    2.7780 Car     1  LIG1        0.1615
     24 C           5.1440  -10.9479    3.1563 Car     1  LIG1        0.1620
     25 C           5.5857   -9.6731    2.8625 Car     1  LIG1       -0.0091
     26 O           5.9610  -11.8166    3.8102 O3      1  LIG1       -0.4914
     27 C           7.2603  -11.3412    4.1676 C3      1  LIG1        0.0790
     28 O           3.4327  -12.6033    3.0627 O3      1  LIG1       -0.4915
     29 C           2.1095  -12.9464    2.6463 C3      1  LIG1        0.0790
     30 H           4.8602    0.2375    2.3265 1       1  LIG1        0.0245
     31 H           5.4472   -1.4192    2.0450 1       1  LIG1        0.0245
     32 H           6.5302   -0.0330    1.7731 1       1  LIG1        0.0245
     33 H           5.6736   -0.9277   -0.3749 1       1  LIG1        0.0466
     34 H           5.0865    0.7289   -0.0934 1       1  LIG1        0.0466
     35 H           1.0934   -1.3254   -0.2488 1       1  LIG1        0.0636
     36 H          -0.7651    0.2830   -0.1214 1       1  LIG1        0.0618
     37 H          -0.3190    2.6422    0.4191 1       1  LIG1        0.0618
     38 H           1.9845    3.3983    0.8422 1       1  LIG1        0.0618
     39 H           3.8500    1.7978    0.7173 1       1  LIG1        0.0636
     40 H           5.7060   -2.1163   -1.5070 1       1  LIG1        0.0270
     41 H           5.9896   -3.8676   -1.3628 1       1  LIG1        0.0270
     42 H           4.4999   -3.2675   -2.1302 1       1  LIG1        0.0270
     43 H           3.3941   -6.8744    0.9429 1       1  LIG1        0.0689
     44 H           6.1935   -7.1067    2.1749 1       1  LIG1        0.0626
     45 H           2.8012   -8.5031    1.2982 1       1  LIG1        0.0625
     46 H           2.0328  -10.7769    1.8196 1       1  LIG1        0.0655
     47 H           6.5797   -9.3645    3.1510 1       1  LIG1        0.0661
     48 H           7.8074  -12.1312    4.6821 1       1  LIG1        0.0660
     49 H           7.8016  -11.0514    3.2670 1       1  LIG1        0.0660
     50 H           7.1629  -10.4783    4.8264 1       1  LIG1        0.0660
     51 H           1.3935  -12.2769    3.1231 1       1  LIG1        0.0660
     52 H           2.0326  -12.8489    1.5634 1       1  LIG1        0.0660
     53 H           1.8929  -13.9749    2.9349 1       1  LIG1        0.0660
@<TRIPOS>BOND
     1     1     2    1
     2     1    30    1
     3     1    31    1
     4     1    32    1
     5     2     3    1
     6     2    33    1
     7     2    34    1
     8     3     4    1
     9     3    10   am
    10     4     9   ar
    11     4     5   ar
    12     5     6   ar
    13     5    35    1
    14     6     7   ar
    15     6    36    1
    16     7     8   ar
    17     7    37    1
    18     8     9   ar
    19     8    38    1
    20     9    39    1
    21    10    11    2
    22    10    12    1
    23    12    13    1
    24    12    14    1
    25    12    15    1
    26    14    40    1
    27    14    41    1
    28    14    42    1
    29    15    16    1
    30    16    17    2
    31    16    18    1
    32    18    19    2
    33    18    43    1
    34    19    20    1
    35    19    44    1
    36    20    25   ar
    37    20    21   ar
    38    21    22   ar
    39    21    45    1
    40    22    23   ar
    41    22    46    1
    42    23    24   ar
    43    23    28    1
    44    24    25   ar
    45    24    26    1
    46    25    47    1
    47    26    27    1
    48    27    48    1
    49    27    49    1
    50    27    50    1
    51    28    29    1
    52    29    51    1
    53    29    52    1
    54    29    53    1
@<TRIPOS>MOLECULE

 37 38 0 0 0
SMALL
GASTEIGER

@<TRIPOS>ATOM
      1 C          -2.6291    2.3319    3.6320 C3      1  LIG1       -0.0608
      2 C          -1.9645    3.4514    2.8282 C3      1  LIG1       -0.0242
      3 C          -0.9863    2.8545    1.8495 Car     1  LIG1       -0.0099
      4 C          -1.2096    2.4593    0.5687 Car     1  LIG1       -0.0510
      5 C          -0.1738    1.9302   -0.1605 Car     1  LIG1       -0.0472
      6 C           1.0622    1.8436    0.4707 Car     1  LIG1        0.0144
      7 S           0.6970    2.5128    2.0837 S2      1  LIG1       -0.0937
      8 C           2.2887    1.3522   -0.0340 C2      1  LIG1       -0.0214
      9 C           3.3707    2.1771   -0.1176 C2      1  LIG1        0.0999
     10 C           4.7348    1.7914   -0.2256 C2      1  LIG1        0.2663
     11 O           5.1648    0.6524   -0.2606 O2      1  LIG1       -0.2682
     12 N           5.4619    2.9243   -0.2815 Nam     1  LIG1       -0.2512
     13 C           4.6439    3.9879   -0.2157 C2      1  LIG1        0.1468
     14 S           5.1517    5.6224   -0.2543 S2      1  LIG1       -0.0177
     15 N           3.3651    3.5779   -0.1207 Nam     1  LIG1       -0.2671
     16 C           2.1835    4.4395   -0.0332 C3      1  LIG1        0.1161
     17 C           1.9548    4.8339    1.4032 C2      1  LIG1        0.3248
     18 O           2.6935    4.4244    2.2671 O2      1  LIG1       -0.2491
     19 O           0.9303    5.6403    1.7228 O3      1  LIG1       -0.4668
     20 C           0.7705    5.9786    3.1257 C3      1  LIG1        0.0817
     21 C           6.9210    2.9867   -0.3970 C3      1  LIG1        0.0103
     22 H          -3.1570    1.6617    2.9536 1       1  LIG1        0.0233
     23 H          -1.8671    1.7729    4.1750 1       1  LIG1        0.0233
     24 H          -3.3366    2.7637    4.3399 1       1  LIG1        0.0233
     25 H          -1.4365    4.1216    3.5066 1       1  LIG1        0.0316
     26 H          -2.7265    4.0105    2.2851 1       1  LIG1        0.0316
     27 H          -2.1920    2.5565    0.1307 1       1  LIG1        0.0626
     28 H          -0.3116    1.6005   -1.1797 1       1  LIG1        0.0629
     29 H           2.3680    0.3235   -0.3532 1       1  LIG1        0.0649
     30 H           2.3411    5.3345   -0.6351 1       1  LIG1        0.0584
     31 H           1.3123    3.9003   -0.4051 1       1  LIG1        0.0584
     32 H          -0.0921    6.6341    3.2455 1       1  LIG1        0.0661
     33 H           0.6175    5.0674    3.7040 1       1  LIG1        0.0661
     34 H           1.6662    6.4882    3.4809 1       1  LIG1        0.0661
     35 H           7.3265    1.9755   -0.4301 1       1  LIG1        0.0433
     36 H           7.1909    3.5165   -1.3105 1       1  LIG1        0.0433
     37 H           7.3313    3.5147    0.4639 1       1  LIG1        0.0433
@<TRIPOS>BOND
     1     1     2    1
     2     1    22    1
     3     1    23    1
     4     1    24    1
     5     2     3    1
     6     2    25    1
     7     2    26    1
     8     3     7   ar
     9     3     4   ar
    10     4     5   ar
    11     4    27    1
    12     5     6   ar
    13     5    28    1
    14     6     7   ar
    15     6     8    1
    16     8     9    2
    17     8    29    1
    18     9    15    1
    19     9    10    1
    20    10    11    2
    21    10    12   am
    22    12    13    1
    23    12    21    1
    24    13    14    2
    25    13    15    1
    26    15    16    1
    27    16    17    1
    28    16    30    1
    29    16    31    1
    30    17    18    2
    31    17    19    1
    32    19    20    1
    33    20    32    1
    34    20    33    1
    35    20    34    1
    36    21    35    1
    37    21    36    1
    38    21    37    1
@<TRIPOS>MOLECULE

 55 56 0 0 0
SMALL
GASTEIGER

@<TRIPOS>ATOM
      1 C          -8.0720    0.6252   -7.9328 C3      1  LIG1       -0.0494
      2 C          -8.4613    1.9045   -7.1893 C3      1  LIG1        0.0093
      3 N          -9.1610    1.5555   -5.9504 Npl     1  LIG1       -0.3304
      4 C         -10.6181    1.4039   -5.9499 C3      1  LIG1        0.0093
      5 C         -11.2710    2.7519   -5.6374 C3      1  LIG1       -0.0494
      6 C          -8.4421    1.3682   -4.7750 Car     1  LIG1        0.0297
      7 C          -9.1085    1.0366   -3.5985 Car     1  LIG1       -0.0399
      8 C          -8.3999    0.8506   -2.4336 Car     1  LIG1       -0.0478
      9 C          -7.0094    0.9945   -2.4326 Car     1  LIG1        0.0383
     10 C          -6.3436    1.3322   -3.6145 Car     1  LIG1       -0.0478
     11 C          -7.0574    1.5122   -4.7772 Car     1  LIG1       -0.0399
     12 C          -6.2467    0.7962   -1.1855 C2      1  LIG1        0.2601
     13 O          -6.8276    0.5074   -0.1570 O2      1  LIG1       -0.2687
     14 N          -4.9062    0.9353   -1.1860 Nam     1  LIG1       -0.2328
     15 N          -4.1819    0.7470   -0.0016 Npl     1  LIG1       -0.2686
     16 C          -2.8148    0.9920    0.0229 C2      1  LIG1        0.0188
     17 C          -2.2255    1.2932   -1.1017 C2      1  LIG1       -0.0601
     18 C          -0.7599    1.5918   -1.2259 C3      1  LIG1       -0.0149
     19 C          -0.0129    1.0877    0.0108 C3      1  LIG1       -0.0414
     20 C          -0.7406    1.5927    1.2629 C3      1  LIG1       -0.0379
     21 H          -0.8866    2.6706    1.1920 1       1  LIG1        0.0302
     22 C          -2.1043    0.8947    1.3413 C3      1  LIG1       -0.0110
     23 C           0.0868    1.2625    2.5068 C3      1  LIG1       -0.0621
     24 C          -0.5595    3.1028   -1.3586 C3      1  LIG1       -0.0563
     25 C          -0.2048    0.8981   -2.4715 C3      1  LIG1       -0.0563
     26 H          -7.5514    0.8848   -8.8546 1       1  LIG1        0.0245
     27 H          -7.4170    0.0237   -7.3027 1       1  LIG1        0.0245
     28 H          -8.9704    0.0558   -8.1710 1       1  LIG1        0.0245
     29 H          -9.1163    2.5060   -7.8195 1       1  LIG1        0.0461
     30 H          -7.5629    2.4739   -6.9511 1       1  LIG1        0.0461
     31 H         -10.9479    1.0589   -6.9299 1       1  LIG1        0.0461
     32 H         -10.9074    0.6757   -5.1921 1       1  LIG1        0.0461
     33 H         -10.9818    3.4800   -6.3952 1       1  LIG1        0.0245
     34 H         -12.3552    2.6390   -5.6371 1       1  LIG1        0.0245
     35 H         -10.9413    3.0968   -4.6574 1       1  LIG1        0.0245
     36 H         -10.1828    0.9256   -3.6000 1       1  LIG1        0.0636
     37 H          -8.9175    0.5941   -1.5211 1       1  LIG1        0.0626
     38 H          -5.2699    1.4481   -3.6160 1       1  LIG1        0.0626
     39 H          -6.5433    1.7695   -5.6914 1       1  LIG1        0.0636
     40 H          -4.4428    1.1657   -2.0064 1       1  LIG1        0.1730
     41 H          -4.6351    0.4456    0.8013 1       1  LIG1        0.1696
     42 H          -2.8285    1.3296   -1.9969 1       1  LIG1        0.0593
     43 H           0.0024   -0.0022    0.0105 1       1  LIG1        0.0276
     44 H           1.0085    1.4683    0.0022 1       1  LIG1        0.0276
     45 H          -2.7091    1.3699    2.1136 1       1  LIG1        0.0328
     46 H          -1.9544   -0.1548    1.5944 1       1  LIG1        0.0328
     47 H           1.0608    1.7465    2.4344 1       1  LIG1        0.0233
     48 H          -0.4327    1.6225    3.3948 1       1  LIG1        0.0233
     49 H           0.2218    0.1832    2.5773 1       1  LIG1        0.0233
     50 H           0.5035    3.3207   -1.4611 1       1  LIG1        0.0238
     51 H          -1.0910    3.4638   -2.2391 1       1  LIG1        0.0238
     52 H          -0.9484    3.6002   -0.4701 1       1  LIG1        0.0238
     53 H          -0.3402   -0.1794   -2.3781 1       1  LIG1        0.0238
     54 H          -0.7357    1.2559   -3.3536 1       1  LIG1        0.0238
     55 H           0.8570    1.1236   -2.5702 1       1  LIG1        0.0238
@<TRIPOS>BOND
     1     1     2    1
     2     1    26    1
     3     1    27    1
     4     1    28    1
     5     2     3    1
     6     2    29    1
     7     2    30    1
     8     3     4    1
     9     3     6    1
    10     4     5    1
    11     4    31    1
    12     4    32    1
    13     5    33    1
    14     5    34    1
    15     5    35    1
    16     6    11   ar
    17     6     7   ar
    18     7     8   ar
    19     7    36    1
    20     8     9   ar
    21     8    37    1
    22     9    10   ar
    23     9    12    1
    24    10    11   ar
    25    10    38    1
    26    11    39    1
    27    12    13    2
    28    12    14   am
    29    14    15    1
    30    14    40    1
    31    15    16    1
    32    15    41    1
    33    16    22    1
    34    16    17    2
    35    17    18    1
    36    17    42    1
    37    18    19    1
    38    18    24    1
    39    18    25    1
    40    19    20    1
    41    19    43    1
    42    19    44    1
    43    20    21    1
    44    20    22    1
    45    20    23    1
    46    22    45    1
    47    22    46    1
    48    23    47    1
    49    23    48    1
    50    23    49    1
    51    24    50    1
    52    24    51    1
    53    24    52    1
    54    25    53    1
    55    25    54    1
    56    25    55    1
@<TRIPOS>MOLECULE

 39 40 0 0 0
SMALL
GASTEIGER

@<TRIPOS>ATOM
      1 C           0.0021   -0.0041    0.0020 C3      1  LIG1       -0.0455
      2 C          -0.0187    1.5258    0.0104 C3      1  LIG1        0.0387
      3 N          -0.7044    1.9982    1.2158 Nar     1  LIG1       -0.2707
      4 C          -0.1980    2.8468    2.1248 Car     1  LIG1        0.0379
      5 C          -1.1606    3.0341    3.0965 Car     1  LIG1        0.0773
      6 C          -2.2770    2.2471    2.7348 Car     1  LIG1        0.0721
      7 N          -1.9953    1.6365    1.6169 Nar     1  LIG1       -0.1757
      8 C          -3.5668    2.1327    3.5056 C3      1  LIG1       -0.0199
      9 C          -1.0433    3.8899    4.2911 C2      1  LIG1        0.2516
     10 O          -1.9672    3.9649    5.0785 O2      1  LIG1       -0.2697
     11 N           0.0877    4.5891    4.5107 Nam     1  LIG1       -0.2783
     12 C           0.1994    5.4036    5.6477 Car     1  LIG1        0.0841
     13 C          -0.7358    5.6009    6.6147 Car     1  LIG1        0.0475
     14 N          -0.1986    6.4599    7.5189 Nar     1  LIG1       -0.2692
     15 N           0.9870    6.7986    7.1592 Nar     1  LIG1       -0.1646
     16 C           1.3098    6.2005    6.0286 Car     1  LIG1        0.1679
     17 C           2.5846    6.3344    5.2987 C2      1  LIG1        0.2635
     18 O           2.7580    5.7246    4.2611 O2      1  LIG1       -0.2686
     19 N           3.5572    7.1325    5.7820 Nam     1  LIG1       -0.3240
     20 C          -0.8761    6.9365    8.7272 C3      1  LIG1        0.0388
     21 C          -0.0035    6.6454    9.9497 C3      1  LIG1       -0.0455
     22 H           0.5293   -0.3651    0.8851 1       1  LIG1        0.0247
     23 H          -1.0205   -0.3814    0.0098 1       1  LIG1        0.0247
     24 H           0.5123   -0.3556   -0.8948 1       1  LIG1        0.0247
     25 H           1.0039    1.9031    0.0027 1       1  LIG1        0.0506
     26 H          -0.5459    1.8868   -0.8726 1       1  LIG1        0.0506
     27 H           0.7814    3.3012    2.0993 1       1  LIG1        0.0834
     28 H          -3.4913    1.3136    4.2208 1       1  LIG1        0.0293
     29 H          -3.7552    3.0645    4.0390 1       1  LIG1        0.0293
     30 H          -4.3869    1.9373    2.8147 1       1  LIG1        0.0293
     31 H           0.8246    4.5292    3.8827 1       1  LIG1        0.1552
     32 H          -1.7191    5.1564    6.6571 1       1  LIG1        0.0845
     33 H           3.4189    7.6189    6.6097 1       1  LIG1        0.1453
     34 H           4.3955    7.2205    5.3020 1       1  LIG1        0.1453
     35 H          -1.0455    8.0105    8.6491 1       1  LIG1        0.0506
     36 H          -1.8326    6.4246    8.8333 1       1  LIG1        0.0506
     37 H           0.1659    5.5715   10.0278 1       1  LIG1        0.0247
     38 H           0.9530    7.1573    9.8436 1       1  LIG1        0.0247
     39 H          -0.5076    7.0001   10.8487 1       1  LIG1        0.0247
@<TRIPOS>BOND
     1     1     2    1
     2     1    22    1
     3     1    23    1
     4     1    24    1
     5     2     3    1
     6     2    25    1
     7     2    26    1
     8     3     7   ar
     9     3     4   ar
    10     4     5   ar
    11     4    27    1
    12     5     6   ar
    13     5     9    1
    14     6     7   ar
    15     6     8    1
    16     8    28    1
    17     8    29    1
    18     8    30    1
    19     9    10    2
    20     9    11   am
    21    11    12    1
    22    11    31    1
    23    12    16   ar
    24    12    13   ar
    25    13    14   ar
    26    13    32    1
    27    14    15   ar
    28    14    20    1
    29    15    16   ar
    30    16    17    1
    31    17    18    2
    32    17    19   am
    33    19    33    1
    34    19    34    1
    35    20    21    1
    36    20    35    1
    37    20    36    1
    38    21    37    1
    39    21    38    1
    40    21    39    1
Quote
#4
You would want something like this:

with open('old_file.txt') as in_file:
    with open('new_file.txt, 'w') as out_file:
        for line in old_file:
            new_file.write(line)
            if new_file.startswith('@<TRIPOS>MOLECULE'):
                new_file.write('MOLECULE NAME')
clarablanes likes this post
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures

Quote
#5
I like generators (tested code here)
import itertools as itt
import os
import sys

def gen_names():
    for cnt in itt.count(1):
        yield 'MOLECULE{}'.format(cnt)

def augmented_lines(line_seq, name_seq):
    name_seq = iter(name_seq)
    for line in line_seq:
        yield line
        if line.startswith('@<TRIPOS>MOLECULE'):
            yield next(name_seq) + '\n'

if __name__ == '__main__':
    src_fn = os.path.join(os.path.dirname(__file__), 'five-molecules.txt')
    with open(src_fn) as infile:
        sys.stdout.writelines(augmented_lines(infile, gen_names()))
clarablanes likes this post
Quote
#6
thank you
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Print different positions in loop from functions konsular 5 249 Oct-16-2019, 08:10 PM
Last Post: buran

Forum Jump:


Users browsing this thread: 1 Guest(s)