Hi Markus,

Concatenating SMILES strings may not be the best way to solve this problem.
I would just create a bond between the two atoms from Python and set the
charges to zero, and adjust hydrogens (if necessary).

But since you asked...:-)

$ obabel -:"O=C1CCC(=O)[N-]1" -xf 7 -osmi
[N-]1C(=O)CCC1=O

$ obabel -:"C1=C2CCCN3CCC(=C23)C=C1[CH+]C1=CC2=C3C(=C1)CCCN3CC2" -xl 13
-osmi
c1c2CCCN3CCc(c23)cc1[C+](c1cc2c3c(c1)CCCN3CC2)

With Python's string replace(), replace [N-] with N, and [C+] with C
(assuming only a single instance of each in the strings), then concatenate:

c1c2CCCN3CCc(c23)cc1C(c1cc2c3c(c1)CCCN3CC2)N1C(=O)CCC1=O

You might be wondering where I got the numbers 7 and 13 from. Well, I just
counted atoms in the SMILES string from the left starting at 1. If using
Python, just get the Idx() of the atom that is a nitrogen and has a
positive charge (and similarly for the C+).

Regards,
- Noel



On Sun, 17 Nov 2019 at 16:58, Markus Grimm via OpenBabel-discuss <
openbabel-discuss@lists.sourceforge.net> wrote:

> Hello everyone,
>
> I'm trying to concatenate two smiles to get the product of some reactions.
> In general, it is mostly clear where the bond is formed. An example:
>
> Nucleophile: O=C1CCC(=O)[N-]1
> Substrate: C1=C2CCCN3CCC(=C23)C=C1[CH+]C1=CC2=C3C(=C1)CCCN3CC2
> I want to rearrange the smiles always under some conditions. In this
> example depending on where the charge is located respectively. So the bond
> is formed between the [N-] and the [CH+]. I know openbabel can reorder the
> smiles based on the atom number. But I'm clueless about how to use it. Is
> there any way how to implement my problem in pybel?
>
> Best regards,
> Markus
> _______________________________________________
> OpenBabel-discuss mailing list
> OpenBabel-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
>
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to