Answers.Body: <p>You can choose between a <code>window_size</code> of 20 for sequences longer than 20 AAs, and the length of the sequence for those shorter::</p>
  
  <pre><code>seq = "CYGTGAVYLLGLGIGGFS"
  window_length = min(len(seq), 20)
  
  full_sequence_analysis = ProteinAnalysis(seq)
  kyte_window = full_sequence_analysis.protein_scale(kyte, window_length, edge)
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-25T06:58:13.700Z
Answers.LastActivityDate: 2019-09-25T06:58:13.700Z
Answers.UserDisplayName: xbello
Body: <p>I am using Biopython to examine protein sequences including the Kyte and Doolittle hydrophobicity. However, for short sequences, this returns an empty value; the value is not allowed if the window does not have 20 values.</p>
  
  <pre><code>from Bio.SeqUtils.ProtParam import ProteinAnalysis
  
  window_length=20
  edge=1
  kyte = {'A': 1.8, 'R': -4.5, 'N': -3.5, 'D': -3.5, 'C': 2.5, 'Q': -3.5, 'E': -3.5, 'G': -0.4, 'H': -3.2, 'I': 4.5,
          'L': 3.8, 'K': -3.9, 'M': 1.9, 'F': 2.8, 'P': -1.6, 'S': -0.8, 'T': -0.7, 'W': -0.9, 'Y': -1.3, 'V': 4.2}
  
  full_sequence_analysis = ProteinAnalysis("CYGTGAVYLLGLGIGGFS")
  kyte_window = full_sequence_analysis.protein_scale(kyte, window_length, edge)
  </code></pre>
  
  <p>Is there are a built in Biopython option in this for "allow half windows/short windows" for incomplete windows? There is nothing I can see to suggest so in <a href="http://biopython.org/DIST/docs/api/Bio.SeqUtils.ProtParam-pysrc.html#ProteinAnalysis.protein_scale" rel="nofollow noreferrer">the docs</a>.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-04-05T15:35:05.193Z
Comments.Text: @Chris_Rands This would fix the error. However, it would change the absolute values. Ideally, I would like to keep the window length at ±10 residues (up to 20 residues) if possible.
Comments.UserDisplayName: James
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-04-08T12:58:58.437Z
Comments.Text: Have you tried odd values for window_length? https://web.expasy.org/protscale/ allows 3 5 7 ... 21
Comments.UserDisplayName: nicolallias
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-04-09T09:37:20.453Z
Comments.Text: @nicolallias The issue would still remain. Even if I had 3 residue window length when I sample the final residue in the sequence, there are only 2 residues available for the window (the final residue, and the preceding residue), so no value is generated because 3 residues are needed for the windowed value.
Comments.UserDisplayName: James
Tags: <phylogenetics><proteins><python><sequence-analysis><phylogeny>
Title: How to allow "half windows" in biopython?
ThreadText: # How to allow "half windows" in biopython?
  
  (Asked by: username_0 on 2019-04-05)
  
  I am using Biopython to examine protein sequences including the Kyte and Doolittle hydrophobicity. However, for short sequences, this returns an empty value; the value is not allowed if the window does not have 20 values.
  
  ```
  from Bio.SeqUtils.ProtParam import ProteinAnalysis
  
  window_length=20
  edge=1
  kyte = {'A': 1.8, 'R': -4.5, 'N': -3.5, 'D': -3.5, 'C': 2.5, 'Q': -3.5, 'E': -3.5, 'G': -0.4, 'H': -3.2, 'I': 4.5,
          'L': 3.8, 'K': -3.9, 'M': 1.9, 'F': 2.8, 'P': -1.6, 'S': -0.8, 'T': -0.7, 'W': -0.9, 'Y': -1.3, 'V': 4.2}
  
  full_sequence_analysis = ProteinAnalysis("CYGTGAVYLLGLGIGGFS")
  kyte_window = full_sequence_analysis.protein_scale(kyte, window_length, edge)
  
  ```
  
  Is there are a built in Biopython option in this for "allow half windows/short windows" for incomplete windows? There is nothing I can see to suggest so in [the docs](http://biopython.org/DIST/docs/api/Bio.SeqUtils.ProtParam-pysrc.html#ProteinAnalysis.protein_scale).
  
  **Tags:** phylogenetics, proteins, python, sequence-analysis, phylogeny
  
  > **Comments:**
  > **username_0**: @Chris_Rands This would fix the error. However, it would change the absolute values. Ideally, I would like to keep the window length at ±10 residues (up to 20 residues) if possible.  
  > **username_1**: Have you tried odd values for window_length? https://web.expasy.org/protscale/ allows 3 5 7 ... 21  
  > **username_0**: @username_1 The issue would still remain. Even if I had 3 residue window length when I sample the final residue in the sequence, there are only 2 residues available for the window (the final residue, and the preceding residue), so no value is generated because 3 residues are needed for the windowed value.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2019-09-25. Score: 3
  
  You can choose between a `window_size` of 20 for sequences longer than 20 AAs, and the length of the sequence for those shorter::
  
  ```
  seq = "CYGTGAVYLLGLGIGGFS"
  window_length = min(len(seq), 20)
  
  full_sequence_analysis = ProteinAnalysis(seq)
  kyte_window = full_sequence_analysis.protein_scale(kyte, window_length, edge)
  
  ```
  
  
  ---
  
  