text: user7150: The question says it all. I want to calculate lipophilicity of proteins to screen the compounds out for antigen-antibody interactions.
  
  user6322: Oligopeptide
  The lipophilicity of an oligopeptide or a small molecule can be calculated with RDKit, the classic compChem python toolkit. The measure is logP or partition coefficient, namely the magnitude of the ratio of the concentration in octanol over than in water, so the higher it is, the more it partitions in the octanol phase. However, with a compound of several dalton it may be good to see what the contribution of each atom to this score are. This measure is the Crippen contribution to logP, which can be handily plotted on the molecule. Note that these are may be at first glance look similar to Gastaiger partial changes, but are not.
  Okay, first the imports
  from rdkit import Chem
  from rdkit.Chem import AllChem, Descriptors
  from rdkit.Chem.Draw import SimilarityMaps
  
  Now let's make the molecules. Let's start with something we can simply use a SMILES string of the web: Bortezomib.
  name = 'Bortezomib'
  mol = Chem.MolFromSmiles('O=C(N[C@H](C(=O)N[C@H](B(O)O)CC(C)C)Cc1ccccc1)c2nccnc2')
  
  Now we can do all the relevant calculations on the mol object:
  print('logP', Descriptors.MolLogP(mol))
  AllChem.Compute2DCoords(mol)
  contribs = Chem.rdMolDescriptors._CalcCrippenContribs(mol)
  fig = SimilarityMaps.GetSimilarityMapFromWeights(mol, [x for x,y in contribs], colorMap='BuPu', contourLines=10)
  fig.savefig(name+'_crippen.png', bbox_inches='tight')
  
  LogP=0.3
  
  colorMap='BuPu' is the matplotlib colorscheme. I have no idea which work best, I have spent way too much time trying and I do not know. But with BuPu, white is hydrophilic, purple is hydrophobic.
  Say the oligopeptide does not have a SMILES or we don't want to do it that way. Let's take β-Casomorphins 1–3:
  name = 'β-Casomorphins 1–3'
  mol = Chem.MolFromFASTA('YPF')
  mol = AllChem.ReplaceSubstructs(mol,
                                  Chem.MolFromSmiles('N'),
                                  Chem.MolFromSmiles('[NH][OH]'),
                                  replacementConnectionPoint=0)[0]
  
  The result with the last block from before gives:
  logP=1
  
  Proteins
  With protein, it is a lot harder. Membrane affinity of protein is dependent on their structure. In PyMOL you can use the Adaptive Poisson-Boltzmann Solver (APBS) to show the surface by charge. For transmembrane protein there is clear ring of hydrophobicity —CHARMM-GUI membrane builder and a variety of tools for example can guess where it is. For a membrane associated protein only one side will be hydrophobic with a tell-tell charged ring around it (e.g. DHR1 domain) and there are no hard and tested methods for that.
  
original_text: 7150: <p>The question says it all. I want to calculate lipophilicity of proteins to screen the compounds out for antigen-antibody interactions.</p>
   6322: <h2>Oligopeptide</h2>
  
  <p>The lipophilicity of an oligopeptide or a small molecule can be calculated with RDKit, the classic compChem python toolkit. The measure is <a href="https://en.wikipedia.org/wiki/Partition_coefficient" rel="nofollow noreferrer">logP or partition coefficient</a>, namely the magnitude of the ratio of the concentration in octanol over than in water, so the higher it is, the more it partitions in the octanol phase. However, with a compound of several dalton it may be good to see what the contribution of each atom to this score are. This measure is the Crippen contribution to logP, which can be handily plotted on the molecule. Note that these are may be at first glance look similar to Gastaiger partial changes, but are not.</p>
  
  <p>Okay, first the imports</p>
  
  <pre><code>from rdkit import Chem
  from rdkit.Chem import AllChem, Descriptors
  from rdkit.Chem.Draw import SimilarityMaps
  </code></pre>
  
  <p>Now let's make the molecules. Let's start with something we can simply use a SMILES string of the web: <a href="https://en.wikipedia.org/wiki/Bortezomib" rel="nofollow noreferrer">Bortezomib</a>.</p>
  
  <pre><code>name = 'Bortezomib'
  mol = Chem.MolFromSmiles('O=C(N[C@H](C(=O)N[C@H](B(O)O)CC(C)C)Cc1ccccc1)c2nccnc2')
  </code></pre>
  
  <p>Now we can do all the relevant calculations on the <code>mol</code> object:</p>
  
  <pre><code>print('logP', Descriptors.MolLogP(mol))
  AllChem.Compute2DCoords(mol)
  contribs = Chem.rdMolDescriptors._CalcCrippenContribs(mol)
  fig = SimilarityMaps.GetSimilarityMapFromWeights(mol, [x for x,y in contribs], colorMap='BuPu', contourLines=10)
  fig.savefig(name+'_crippen.png', bbox_inches='tight')
  </code></pre>
  
  <p>LogP=0.3
  <a href="https://i.stack.imgur.com/M6qEH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/M6qEH.png" alt="Bortezomib"></a></p>
  
  <p><code>colorMap='BuPu'</code> is the matplotlib colorscheme. I have no idea which work best, I have spent way too much time trying and I do not know. But with BuPu, white is hydrophilic, purple is hydrophobic.</p>
  
  <p>Say the oligopeptide does not have a SMILES or we don't want to do it that way. Let's take <a href="https://en.wikipedia.org/wiki/Casomorphin" rel="nofollow noreferrer">β-Casomorphins 1–3</a>:</p>
  
  <pre><code>name = 'β-Casomorphins 1–3'
  mol = Chem.MolFromFASTA('YPF')
  mol = AllChem.ReplaceSubstructs(mol,
                                  Chem.MolFromSmiles('N'),
                                  Chem.MolFromSmiles('[NH][OH]'),
                                  replacementConnectionPoint=0)[0]
  </code></pre>
  
  <p>The result with the last block from before gives:</p>
  
  <p>logP=1
  <a href="https://i.stack.imgur.com/1JHCC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1JHCC.png" alt="casomorphin"></a></p>
  
  <h2>Proteins</h2>
  
  <p>With protein, it is a lot harder. Membrane affinity of protein is dependent on their structure. In PyMOL you can use the Adaptive Poisson-Boltzmann Solver (APBS) to show the surface by charge. For transmembrane protein there is clear ring of hydrophobicity —CHARMM-GUI membrane builder and a variety of tools for example can guess where it is. For a membrane associated protein only one side will be hydrophobic with a tell-tell charged ring around it (e.g. DHR1 domain) and there are no hard and tested methods for that.</p>
  