Re: [Rdkit-discuss] edge matrix

2018-01-18 Thread Jan Halborg Jensen
Dear Guillaume

I understand that the adjacency matrix, together with the atom list, holds all 
the necessary information once bond orders are included, to define the molecule 
object, but do you know if there is an RDKit function that does this: something 
like  mol = Chem.MolFromAdjacencyMatrix(adj)?

Best regard, Jan
On 18 Jan 2018, at 11:07, Guillaume GODIN 
<guillaume.go...@firmenich.com<mailto:guillaume.go...@firmenich.com>> wrote:

Dear Jan,

Adjacency matrix is a molecule object encoder.

To do reverse process:

You will need atoms list.

And, you will need to have bond encoding in the Adjacency matrix as well to 
have an exact structure i.e. Double bonds => 2, triple bonds =>3, aromatic 
bonds =>1.5.

But in principal it’s only what you need.

BR,

Guillaume

De : Jan Halborg Jensen
Date : jeudi, 18 janvier 2018 à 10:59
À : GVALMTGG
Cc : Mario Lovrić, RDKit Discuss
Objet : Re: [Rdkit-discuss] edge matrix

Is there a function for the reverse process, i.e. getting a molecule object 
from an adjacency matrix?

Best regards, Jan

On 17 Jan 2018, at 17:19, Guillaume GODIN 
<guillaume.go...@firmenich.com<mailto:guillaume.go...@firmenich.com>> wrote:

Dear Mario,

There is a adjacency matrix available:

from rdkit import Chem
mol = Chem.MolFromSmiles('CC(C)CC')
adj = Chem.GetAdjacencyMatrix(mol)
print adj

[[0 1 0 0 0]
 [1 0 1 1 0]
 [0 1 0 0 0]
 [0 1 0 0 1]
 [0 0 0 1 0]]

But this is not what you want…

Can you explain your output generation process please ?

BR,

Guillaume


De : Mario Lovrić
Date : mercredi, 17 janvier 2018 à 16:31
À : RDKit Discuss
Objet : [Rdkit-discuss] edge matrix

Dear all,

Does any one have an idea how to get an edge matrix (graph theory) out of 
Rdkit, I digged deep but didnt find anything.

F.example for:

'CC(C)CC'


it would be:

array([[0, 1, 1, 0],
   [1, 0, 1, 0],
   [1, 1, 0, 1],
   [0, 0, 1, 0]])

Thanks.


--
Mario Lovrić
***
DISCLAIMER
This email and any files transmitted with it, including replies and forwarded 
copies (which may contain alterations) subsequently transmitted from Firmenich, 
are confidential and solely for the use of the intended recipient. The contents 
do not represent the opinion of Firmenich except to the extent that it relates 
to their official business.
***
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org<http://slashdot.org/>! 
http://sdm.link/slashdot___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net<mailto:Rdkit-discuss@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

***
DISCLAIMER
This email and any files transmitted with it, including replies and forwarded 
copies (which may contain alterations) subsequently transmitted from Firmenich, 
are confidential and solely for the use of the intended recipient. The contents 
do not represent the opinion of Firmenich except to the extent that it relates 
to their official business.
***

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] edge matrix

2018-01-18 Thread Guillaume GODIN
Dear Jan,

There is not such kind of function in RDKit.

BR,

Guillaume

De : Jan Halborg Jensen
Date : jeudi, 18 janvier 2018 à 11:17
À : GVALMTGG
Cc : Mario Lovrić, RDKit Discuss
Objet : Re: [Rdkit-discuss] edge matrix

Dear Guillaume

I understand that the adjacency matrix, together with the atom list, holds all 
the necessary information once bond orders are included, to define the molecule 
object, but do you know if there is an RDKit function that does this: something 
like  mol = Chem.MolFromAdjacencyMatrix(adj)?

Best regard, Jan
On 18 Jan 2018, at 11:07, Guillaume GODIN 
<guillaume.go...@firmenich.com<mailto:guillaume.go...@firmenich.com>> wrote:

Dear Jan,

Adjacency matrix is a molecule object encoder.

To do reverse process:

You will need atoms list.

And, you will need to have bond encoding in the Adjacency matrix as well to 
have an exact structure i.e. Double bonds => 2, triple bonds =>3, aromatic 
bonds =>1.5.

But in principal it’s only what you need.

BR,

Guillaume

De : Jan Halborg Jensen
Date : jeudi, 18 janvier 2018 à 10:59
À : GVALMTGG
Cc : Mario Lovrić, RDKit Discuss
Objet : Re: [Rdkit-discuss] edge matrix

Is there a function for the reverse process, i.e. getting a molecule object 
from an adjacency matrix?

Best regards, Jan

On 17 Jan 2018, at 17:19, Guillaume GODIN 
<guillaume.go...@firmenich.com<mailto:guillaume.go...@firmenich.com>> wrote:

Dear Mario,

There is a adjacency matrix available:

from rdkit import Chem
mol = Chem.MolFromSmiles('CC(C)CC')
adj = Chem.GetAdjacencyMatrix(mol)
print adj

[[0 1 0 0 0]
 [1 0 1 1 0]
 [0 1 0 0 0]
 [0 1 0 0 1]
 [0 0 0 1 0]]

But this is not what you want…

Can you explain your output generation process please ?

BR,

Guillaume


De : Mario Lovrić
Date : mercredi, 17 janvier 2018 à 16:31
À : RDKit Discuss
Objet : [Rdkit-discuss] edge matrix

Dear all,

Does any one have an idea how to get an edge matrix (graph theory) out of 
Rdkit, I digged deep but didnt find anything.

F.example for:

'CC(C)CC'


it would be:

array([[0, 1, 1, 0],
   [1, 0, 1, 0],
   [1, 1, 0, 1],
   [0, 0, 1, 0]])

Thanks.


--
Mario Lovrić
***
DISCLAIMER
This email and any files transmitted with it, including replies and forwarded 
copies (which may contain alterations) subsequently transmitted from Firmenich, 
are confidential and solely for the use of the intended recipient. The contents 
do not represent the opinion of Firmenich except to the extent that it relates 
to their official business.
***
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org<http://slashdot.org/>! 
http://sdm.link/slashdot___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net<mailto:Rdkit-discuss@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

***
DISCLAIMER
This email and any files transmitted with it, including replies and forwarded 
copies (which may contain alterations) subsequently transmitted from Firmenich, 
are confidential and solely for the use of the intended recipient. The contents 
do not represent the opinion of Firmenich except to the extent that it relates 
to their official business.
***


***
DISCLAIMER  
This email and any files transmitted with it, including replies and forwarded 
copies (which may contain alterations) subsequently transmitted from Firmenich, 
are confidential and solely for the use of the intended recipient. The contents 
do not represent the opinion of Firmenich except to the extent that it relates 
to their official business.  
***
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] edge matrix

2018-01-18 Thread Jan Halborg Jensen
Is there a function for the reverse process, i.e. getting a molecule object 
from an adjacency matrix?

Best regards, Jan

On 17 Jan 2018, at 17:19, Guillaume GODIN 
> wrote:

Dear Mario,

There is a adjacency matrix available:

from rdkit import Chem
mol = Chem.MolFromSmiles('CC(C)CC')
adj = Chem.GetAdjacencyMatrix(mol)
print adj

[[0 1 0 0 0]
 [1 0 1 1 0]
 [0 1 0 0 0]
 [0 1 0 0 1]
 [0 0 0 1 0]]

But this is not what you want…

Can you explain your output generation process please ?

BR,

Guillaume


De : Mario Lovrić
Date : mercredi, 17 janvier 2018 à 16:31
À : RDKit Discuss
Objet : [Rdkit-discuss] edge matrix

Dear all,

Does any one have an idea how to get an edge matrix (graph theory) out of 
Rdkit, I digged deep but didnt find anything.

F.example for:

'CC(C)CC'


it would be:

array([[0, 1, 1, 0],
   [1, 0, 1, 0],
   [1, 1, 0, 1],
   [0, 0, 1, 0]])

Thanks.


--
Mario Lovrić
***
DISCLAIMER
This email and any files transmitted with it, including replies and forwarded 
copies (which may contain alterations) subsequently transmitted from Firmenich, 
are confidential and solely for the use of the intended recipient. The contents 
do not represent the opinion of Firmenich except to the extent that it relates 
to their official business.
***
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! 
http://sdm.link/slashdot___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] edge matrix

2018-01-18 Thread Guillaume GODIN
Dear Jan,

Adjacency matrix is a molecule object encoder.

To do reverse process:

You will need atoms list.

And, you will need to have bond encoding in the Adjacency matrix as well to 
have an exact structure i.e. Double bonds => 2, triple bonds =>3, aromatic 
bonds =>1.5.

But in principal it’s only what you need.

BR,

Guillaume

De : Jan Halborg Jensen
Date : jeudi, 18 janvier 2018 à 10:59
À : GVALMTGG
Cc : Mario Lovrić, RDKit Discuss
Objet : Re: [Rdkit-discuss] edge matrix

Is there a function for the reverse process, i.e. getting a molecule object 
from an adjacency matrix?

Best regards, Jan

On 17 Jan 2018, at 17:19, Guillaume GODIN 
<guillaume.go...@firmenich.com<mailto:guillaume.go...@firmenich.com>> wrote:

Dear Mario,

There is a adjacency matrix available:

from rdkit import Chem
mol = Chem.MolFromSmiles('CC(C)CC')
adj = Chem.GetAdjacencyMatrix(mol)
print adj

[[0 1 0 0 0]
 [1 0 1 1 0]
 [0 1 0 0 0]
 [0 1 0 0 1]
 [0 0 0 1 0]]

But this is not what you want…

Can you explain your output generation process please ?

BR,

Guillaume


De : Mario Lovrić
Date : mercredi, 17 janvier 2018 à 16:31
À : RDKit Discuss
Objet : [Rdkit-discuss] edge matrix

Dear all,

Does any one have an idea how to get an edge matrix (graph theory) out of 
Rdkit, I digged deep but didnt find anything.

F.example for:

'CC(C)CC'


it would be:

array([[0, 1, 1, 0],
   [1, 0, 1, 0],
   [1, 1, 0, 1],
   [0, 0, 1, 0]])

Thanks.


--
Mario Lovrić
***
DISCLAIMER
This email and any files transmitted with it, including replies and forwarded 
copies (which may contain alterations) subsequently transmitted from Firmenich, 
are confidential and solely for the use of the intended recipient. The contents 
do not represent the opinion of Firmenich except to the extent that it relates 
to their official business.
***
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org<http://slashdot.org>! 
http://sdm.link/slashdot___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net<mailto:Rdkit-discuss@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


***
DISCLAIMER  
This email and any files transmitted with it, including replies and forwarded 
copies (which may contain alterations) subsequently transmitted from Firmenich, 
are confidential and solely for the use of the intended recipient. The contents 
do not represent the opinion of Firmenich except to the extent that it relates 
to their official business.  
***
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] edge matrix

2018-01-18 Thread Mario Lovrić
Dear Chris,

Thanks, thats it :)



On Wed, Jan 17, 2018 at 6:25 PM, Chris Earnshaw 
wrote:

> I don't think there's a way to do this using RDKit itself, but it appears
> to be straightforward using Python with numpy and networkx, e.g.
>
> import numpy as np
> import networkx as nx
> a = np.matrix([[0, 1, 0, 0, 0],[1, 0, 1, 1, 0],[0, 1, 0, 0, 0],[0, 1, 0,
> 0, 1],[0, 0, 0, 1, 0]])
> b = nx.from_numpy_matrix(a)
> lg = nx.line_graph(b)
> ea = nx.adjacency_matrix(lg)
> ea
>
> matrix([[ 0.,  1.,  1.,  0.],
> [ 1.,  0.,  1.,  0.],
> [ 1.,  1.,  0.,  1.],
> [ 0.,  0.,  1.,  0.]])
>
> Hope this helps - but I'm way out of my depth here!
>
> Best regards,
> Chris
>
>
> On 17 January 2018 at 16:57, Mario Lovrić 
> wrote:
>
>> Correct, I am looking for a rdkit-hidden-option to do it :D
>>
>> On Wed, Jan 17, 2018 at 5:56 PM, Jason Biggs 
>> wrote:
>>
>>> I am a novice when it comes to graph theory, but it seems like what is
>>> wanted here is the adjacency matrix of the corresponding line graph (
>>> http://mathworld.wolfram.com/LineGraph.html).
>>>
>>> I don't know how to do this in python, but if I use mathematica, it goes
>>> like this
>>>
>>> adjacencyMatrix = {{0, 1, 0, 0, 0}, {1, 0, 1, 1, 0}, {0, 1, 0, 0,
>>> 0}, {0, 1, 0, 0, 1}, {0, 0, 0, 1, 0}};
>>>
>>> graph = AdjacencyGraph[adjacencyMatrix];
>>> lineGraph = LineGraph[graph];
>>> AdjacencyMatrix[lineGraph] // MatrixForm
>>>
>>> [image: Inline image 1]
>>>
>>>
>>> Jason Biggs
>>>
>>>
>>> On Wed, Jan 17, 2018 at 10:21 AM, Marta Stępniewska-Dziubińska via
>>> Rdkit-discuss  wrote:
>>>
 Hi Mario,

 What exactly do you mean by 'edge matrix'? Are you sure you provided a
 correct example? If you want to get an adjacency matrix of a molecular
 graph you can iterate over bonds to get it:

 from rdkit.Chem import MolFromSmiles
 import numpy as np
 m = MolFromSmiles('CC(C)CC')
 n = m.GetNumAtoms()
 E = np.zeros((n, n))
 for b in m.GetBonds():
 i = b.GetBeginAtomIdx()
 j = b.GetEndAtomIdx()
 E[[i,j], [j,i]] = 1


 Hope this helps,
 Marta SD



 2018-01-17 16:31 GMT+01:00 Mario Lovrić :

> Dear all,
>
> Does any one have an idea how to get an edge matrix (graph theory) out
> of Rdkit, I digged deep but didnt find anything.
>
> F.example for:
>
> 'CC(C)CC'
>
>
> it would be:
>
> array([[0, 1, 1, 0],
>[1, 0, 1, 0],
>[1, 1, 0, 1],
>[0, 0, 1, 0]])
>
> Thanks.
>
>
> --
> Mario Lovrić
>
> 
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Rdkit-discuss mailing list
> Rdkit-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
>

 
 --
 Check out the vibrant tech community on one of the world's most
 engaging tech sites, Slashdot.org! http://sdm.link/slashdot
 ___
 Rdkit-discuss mailing list
 Rdkit-discuss@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


>>>
>>
>>
>> --
>> Mario Lovrić
>>
>> 
>> --
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> ___
>> Rdkit-discuss mailing list
>> Rdkit-discuss@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>>
>>
>


-- 
Mario Lovrić
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] edge matrix

2018-01-17 Thread Chris Earnshaw
I don't think there's a way to do this using RDKit itself, but it appears
to be straightforward using Python with numpy and networkx, e.g.

import numpy as np
import networkx as nx
a = np.matrix([[0, 1, 0, 0, 0],[1, 0, 1, 1, 0],[0, 1, 0, 0, 0],[0, 1, 0, 0,
1],[0, 0, 0, 1, 0]])
b = nx.from_numpy_matrix(a)
lg = nx.line_graph(b)
ea = nx.adjacency_matrix(lg)
ea

matrix([[ 0.,  1.,  1.,  0.],
[ 1.,  0.,  1.,  0.],
[ 1.,  1.,  0.,  1.],
[ 0.,  0.,  1.,  0.]])

Hope this helps - but I'm way out of my depth here!

Best regards,
Chris


On 17 January 2018 at 16:57, Mario Lovrić  wrote:

> Correct, I am looking for a rdkit-hidden-option to do it :D
>
> On Wed, Jan 17, 2018 at 5:56 PM, Jason Biggs 
> wrote:
>
>> I am a novice when it comes to graph theory, but it seems like what is
>> wanted here is the adjacency matrix of the corresponding line graph (
>> http://mathworld.wolfram.com/LineGraph.html).
>>
>> I don't know how to do this in python, but if I use mathematica, it goes
>> like this
>>
>> adjacencyMatrix = {{0, 1, 0, 0, 0}, {1, 0, 1, 1, 0}, {0, 1, 0, 0,
>> 0}, {0, 1, 0, 0, 1}, {0, 0, 0, 1, 0}};
>>
>> graph = AdjacencyGraph[adjacencyMatrix];
>> lineGraph = LineGraph[graph];
>> AdjacencyMatrix[lineGraph] // MatrixForm
>>
>> [image: Inline image 1]
>>
>>
>> Jason Biggs
>>
>>
>> On Wed, Jan 17, 2018 at 10:21 AM, Marta Stępniewska-Dziubińska via
>> Rdkit-discuss  wrote:
>>
>>> Hi Mario,
>>>
>>> What exactly do you mean by 'edge matrix'? Are you sure you provided a
>>> correct example? If you want to get an adjacency matrix of a molecular
>>> graph you can iterate over bonds to get it:
>>>
>>> from rdkit.Chem import MolFromSmiles
>>> import numpy as np
>>> m = MolFromSmiles('CC(C)CC')
>>> n = m.GetNumAtoms()
>>> E = np.zeros((n, n))
>>> for b in m.GetBonds():
>>> i = b.GetBeginAtomIdx()
>>> j = b.GetEndAtomIdx()
>>> E[[i,j], [j,i]] = 1
>>>
>>>
>>> Hope this helps,
>>> Marta SD
>>>
>>>
>>>
>>> 2018-01-17 16:31 GMT+01:00 Mario Lovrić :
>>>
 Dear all,

 Does any one have an idea how to get an edge matrix (graph theory) out
 of Rdkit, I digged deep but didnt find anything.

 F.example for:

 'CC(C)CC'


 it would be:

 array([[0, 1, 1, 0],
[1, 0, 1, 0],
[1, 1, 0, 1],
[0, 0, 1, 0]])

 Thanks.


 --
 Mario Lovrić

 
 --
 Check out the vibrant tech community on one of the world's most
 engaging tech sites, Slashdot.org! http://sdm.link/slashdot
 ___
 Rdkit-discuss mailing list
 Rdkit-discuss@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


>>>
>>> 
>>> --
>>> Check out the vibrant tech community on one of the world's most
>>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>>> ___
>>> Rdkit-discuss mailing list
>>> Rdkit-discuss@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>>>
>>>
>>
>
>
> --
> Mario Lovrić
>
> 
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Rdkit-discuss mailing list
> Rdkit-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
>
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] edge matrix

2018-01-17 Thread Mario Lovrić
Correct, I am looking for a rdkit-hidden-option to do it :D

On Wed, Jan 17, 2018 at 5:56 PM, Jason Biggs  wrote:

> I am a novice when it comes to graph theory, but it seems like what is
> wanted here is the adjacency matrix of the corresponding line graph (
> http://mathworld.wolfram.com/LineGraph.html).
>
> I don't know how to do this in python, but if I use mathematica, it goes
> like this
>
> adjacencyMatrix = {{0, 1, 0, 0, 0}, {1, 0, 1, 1, 0}, {0, 1, 0, 0,
> 0}, {0, 1, 0, 0, 1}, {0, 0, 0, 1, 0}};
>
> graph = AdjacencyGraph[adjacencyMatrix];
> lineGraph = LineGraph[graph];
> AdjacencyMatrix[lineGraph] // MatrixForm
>
> [image: Inline image 1]
>
>
> Jason Biggs
>
>
> On Wed, Jan 17, 2018 at 10:21 AM, Marta Stępniewska-Dziubińska via
> Rdkit-discuss  wrote:
>
>> Hi Mario,
>>
>> What exactly do you mean by 'edge matrix'? Are you sure you provided a
>> correct example? If you want to get an adjacency matrix of a molecular
>> graph you can iterate over bonds to get it:
>>
>> from rdkit.Chem import MolFromSmiles
>> import numpy as np
>> m = MolFromSmiles('CC(C)CC')
>> n = m.GetNumAtoms()
>> E = np.zeros((n, n))
>> for b in m.GetBonds():
>> i = b.GetBeginAtomIdx()
>> j = b.GetEndAtomIdx()
>> E[[i,j], [j,i]] = 1
>>
>>
>> Hope this helps,
>> Marta SD
>>
>>
>>
>> 2018-01-17 16:31 GMT+01:00 Mario Lovrić :
>>
>>> Dear all,
>>>
>>> Does any one have an idea how to get an edge matrix (graph theory) out
>>> of Rdkit, I digged deep but didnt find anything.
>>>
>>> F.example for:
>>>
>>> 'CC(C)CC'
>>>
>>>
>>> it would be:
>>>
>>> array([[0, 1, 1, 0],
>>>[1, 0, 1, 0],
>>>[1, 1, 0, 1],
>>>[0, 0, 1, 0]])
>>>
>>> Thanks.
>>>
>>>
>>> --
>>> Mario Lovrić
>>>
>>> 
>>> --
>>> Check out the vibrant tech community on one of the world's most
>>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>>> ___
>>> Rdkit-discuss mailing list
>>> Rdkit-discuss@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>>>
>>>
>>
>> 
>> --
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> ___
>> Rdkit-discuss mailing list
>> Rdkit-discuss@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>>
>>
>


-- 
Mario Lovrić
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] edge matrix

2018-01-17 Thread Jason Biggs
I am a novice when it comes to graph theory, but it seems like what is
wanted here is the adjacency matrix of the corresponding line graph (
http://mathworld.wolfram.com/LineGraph.html).

I don't know how to do this in python, but if I use mathematica, it goes
like this

adjacencyMatrix = {{0, 1, 0, 0, 0}, {1, 0, 1, 1, 0}, {0, 1, 0, 0,
0}, {0, 1, 0, 0, 1}, {0, 0, 0, 1, 0}};

graph = AdjacencyGraph[adjacencyMatrix];
lineGraph = LineGraph[graph];
AdjacencyMatrix[lineGraph] // MatrixForm

[image: Inline image 1]


Jason Biggs


On Wed, Jan 17, 2018 at 10:21 AM, Marta Stępniewska-Dziubińska via
Rdkit-discuss  wrote:

> Hi Mario,
>
> What exactly do you mean by 'edge matrix'? Are you sure you provided a
> correct example? If you want to get an adjacency matrix of a molecular
> graph you can iterate over bonds to get it:
>
> from rdkit.Chem import MolFromSmiles
> import numpy as np
> m = MolFromSmiles('CC(C)CC')
> n = m.GetNumAtoms()
> E = np.zeros((n, n))
> for b in m.GetBonds():
> i = b.GetBeginAtomIdx()
> j = b.GetEndAtomIdx()
> E[[i,j], [j,i]] = 1
>
>
> Hope this helps,
> Marta SD
>
>
>
> 2018-01-17 16:31 GMT+01:00 Mario Lovrić :
>
>> Dear all,
>>
>> Does any one have an idea how to get an edge matrix (graph theory) out of
>> Rdkit, I digged deep but didnt find anything.
>>
>> F.example for:
>>
>> 'CC(C)CC'
>>
>>
>> it would be:
>>
>> array([[0, 1, 1, 0],
>>[1, 0, 1, 0],
>>[1, 1, 0, 1],
>>[0, 0, 1, 0]])
>>
>> Thanks.
>>
>>
>> --
>> Mario Lovrić
>>
>> 
>> --
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> ___
>> Rdkit-discuss mailing list
>> Rdkit-discuss@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>>
>>
>
> 
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Rdkit-discuss mailing list
> Rdkit-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
>
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] edge matrix

2018-01-17 Thread Mario Lovrić
Dear Marta and Guillaume,

Thank you both.
Your solutions are giving the same output, which is the vertices-adjacency
matrix.
There is something called the edge-adjaceny matrix. Its defined in several
papers by Trinajstic to calculate the M2 Zagreb indices, eg. "The Zagreb
Indices 30 Years After"
The matrix I wrote is manually written, it returns adjacent bonds instead
of atoms.


KR


On Wed, Jan 17, 2018 at 5:21 PM, Marta Stępniewska-Dziubińska <
mart...@ibb.waw.pl> wrote:

> Hi Mario,
>
> What exactly do you mean by 'edge matrix'? Are you sure you provided a
> correct example? If you want to get an adjacency matrix of a molecular
> graph you can iterate over bonds to get it:
>
> from rdkit.Chem import MolFromSmiles
> import numpy as np
> m = MolFromSmiles('CC(C)CC')
> n = m.GetNumAtoms()
> E = np.zeros((n, n))
> for b in m.GetBonds():
> i = b.GetBeginAtomIdx()
> j = b.GetEndAtomIdx()
> E[[i,j], [j,i]] = 1
>
>
> Hope this helps,
> Marta SD
>
>
>
> 2018-01-17 16:31 GMT+01:00 Mario Lovrić :
>
>> Dear all,
>>
>> Does any one have an idea how to get an edge matrix (graph theory) out of
>> Rdkit, I digged deep but didnt find anything.
>>
>> F.example for:
>>
>> 'CC(C)CC'
>>
>>
>> it would be:
>>
>> array([[0, 1, 1, 0],
>>[1, 0, 1, 0],
>>[1, 1, 0, 1],
>>[0, 0, 1, 0]])
>>
>> Thanks.
>>
>>
>> --
>> Mario Lovrić
>>
>> 
>> --
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> ___
>> Rdkit-discuss mailing list
>> Rdkit-discuss@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>>
>>
>


-- 
Mario Lovrić
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] edge matrix

2018-01-17 Thread Marta Stępniewska-Dziubińska via Rdkit-discuss
Hi Mario,

What exactly do you mean by 'edge matrix'? Are you sure you provided a
correct example? If you want to get an adjacency matrix of a molecular
graph you can iterate over bonds to get it:

from rdkit.Chem import MolFromSmiles
import numpy as np
m = MolFromSmiles('CC(C)CC')
n = m.GetNumAtoms()
E = np.zeros((n, n))
for b in m.GetBonds():
i = b.GetBeginAtomIdx()
j = b.GetEndAtomIdx()
E[[i,j], [j,i]] = 1


Hope this helps,
Marta SD



2018-01-17 16:31 GMT+01:00 Mario Lovrić :

> Dear all,
>
> Does any one have an idea how to get an edge matrix (graph theory) out of
> Rdkit, I digged deep but didnt find anything.
>
> F.example for:
>
> 'CC(C)CC'
>
>
> it would be:
>
> array([[0, 1, 1, 0],
>[1, 0, 1, 0],
>[1, 1, 0, 1],
>[0, 0, 1, 0]])
>
> Thanks.
>
>
> --
> Mario Lovrić
>
> 
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Rdkit-discuss mailing list
> Rdkit-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
>
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] edge matrix

2018-01-17 Thread Guillaume GODIN
Dear Mario,

There is a adjacency matrix available:

from rdkit import Chem
mol = Chem.MolFromSmiles('CC(C)CC')
adj = Chem.GetAdjacencyMatrix(mol)
print adj


[[0 1 0 0 0]

 [1 0 1 1 0]

 [0 1 0 0 0]

 [0 1 0 0 1]

 [0 0 0 1 0]]

But this is not what you want…

Can you explain your output generation process please ?

BR,

Guillaume


De : Mario Lovrić
Date : mercredi, 17 janvier 2018 à 16:31
À : RDKit Discuss
Objet : [Rdkit-discuss] edge matrix

Dear all,

Does any one have an idea how to get an edge matrix (graph theory) out of 
Rdkit, I digged deep but didnt find anything.

F.example for:

'CC(C)CC'


it would be:

array([[0, 1, 1, 0],
   [1, 0, 1, 0],
   [1, 1, 0, 1],
   [0, 0, 1, 0]])

Thanks.


--
Mario Lovrić

***
DISCLAIMER  
This email and any files transmitted with it, including replies and forwarded 
copies (which may contain alterations) subsequently transmitted from Firmenich, 
are confidential and solely for the use of the intended recipient. The contents 
do not represent the opinion of Firmenich except to the extent that it relates 
to their official business.  
***
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss