-2
$\begingroup$

I have the sequence of a protein from Chain A and Chain B and I want to use Manipulate to show what parts of sequence are identical.

This is what I have:

With[{Length = Length[seqAlign]}, Manipulate[ Grid[{If[ListQ[#], Column[#, Frame -> All, Spacings -> 1], #] & /@ seqAlign[[x ;; x + shownSize]]}, Frame -> All], {x, 1, seqLength - shownSize, 1}] ]

How do I make the whole thing visible? The function receives as parameter the sequence alignment of 2 proteins.

$\endgroup$
  • 1
    $\begingroup$ All of your questions (so far) don't show any effort on your part to provide any Mathematica code. While I might be able to help with Manipulate issues, I don't know a protein from a rock. If you showed the code to create Chains A and B, then maybe you'd have a lot more folks that could help. $\endgroup$ – JimB Jun 26 at 18:50
  • $\begingroup$ Well, this is what I have, With[{Length = Length[seqAlign]}, Manipulate[ Grid[{If[ListQ[#], Column[#, Frame -> All, Spacings -> 1], #] & /@ seqAlign[[x ;; x + shownSize]]}, Frame -> All], {x, 1, seqLength - shownSize, 1}] ] now how do I make the whole thing visible. The function receives as parameter the sequence alignment of 2 proteins. $\endgroup$ – Las des Nestor Jun 26 at 19:01
  • $\begingroup$ Length = Length[seqAlign]? Redefining Length is not a good idea. $\endgroup$ – Rohit Namjoshi Jun 26 at 19:15
  • $\begingroup$ ohh, ok will do now. $\endgroup$ – Las des Nestor Jun 26 at 20:41
  • 1
    $\begingroup$ The tag curated-data suggests your examples are from ProteinData[] or some other built-in curated data source. Can you not update your question with examples for A and B? $\endgroup$ – Michael E2 Jun 26 at 22:02
8
$\begingroup$

I'm using as examples the mouse and human sequences for Rhodopsin (the protein in retinal rod cells that detects photons).

mouse = "MNGTEGPNFYVPFSNVTGVVRSPFEQPQYYLAEPWQFSMLAAYMFLLIVLGFPINFLTLYV\
TVQHKKLRTPLNYILLNLAVADLFMVFGGFTTTLYTSLHGYFVFGPTGCNLEGFFATLGGEIALWSLVVL\
AIERYVVVCKPMSNFRFGENHAIMGVVFTWIMALACAAPPLVGWSRYIPEGMQCSCGIDYYTLKPEVNNE\
SFVIYMFVVHFTIPMIVIFFCYGQLVFTVKEAAAQQQESATTQKAEKEVTRMVIIMVIFFLICWLPYASV\
AFYIFTHQGSNFGPIFMTLPAFFAKSSSIYNPVIYIMLNKQFRNCMLTTLCCGKNPLGDDDASATASKTE\
TSQVAPA";
human = "MNGTEGPNFYVPFSNATGVVRSPFEYPQYYLAEPWQFSMLAAYMFLLIVLGFPINFLTLYV\
TVQHKKLRTPLNYILLNLAVADLFMVLGGFTSTLYTSLHGYFVFGPTGCNLEGFFATLGGEIALWSLVVL\
AIERYVVVCKPMSNFRFGENHAIMGVAFTWVMALACAAPPLAGWSRYIPEGLQCSCGIDYYTLKPEVNNE\
SFVIYMFVVHFTIPMIIIFFCYGQLVFTVKEAAAQQQESATTQKAEKEVTRMVIIMVIAFLICWVPYASV\
AFYIFTHQGSNFGPIFMTIPAFFAKSAAIYNPVIYIMMNKQFRNCMLTTICCGKNPLGDDEASATVSKTE\
TSQVAPA";

s = SequenceAlignment[mouse, human]

(* {MNGTEGPNFYVPFSN,{V,A},TGVVRSPFE,{Q,Y},
PQYYLAEPWQFSMLAAYMFLLIVLGFPINFLTLYVTVQHKKLRTPLNYILLNLAVADLFMV,
{F,L},GGFT,{T,S},TLYTSLHGYFVFGPTGCNLEGFFATLGGEIALWSLVVLAIERYVVVCKPMSNFRFGENHAIMGV,
{V,A},FTW,{I,V},MALACAAPPL,{V,A},GWSRYIPEG,{M,L},
QCSCGIDYYTLKPEVNNESFVIYMFVVHFTIPMI,{V,I},
IFFCYGQLVFTVKEAAAQQQESATTQKAEKEVTRMVIIMVI,{F,A},
FLICW,{L,V},PYASVAFYIFTHQGSNFGPIFMT,{L,I},PAFFAKS,
{SS,AA},IYNPVIYIM,{L,M},NKQFRNCMLTT,{L,I},CCGKNPLGDD,{D,E},ASAT,{A,V},SKTETSQVAPA} *)

Your method works to scroll through the alignment:

Manipulate[
 seqLength = Length[s];
 shownSize = 5;
 Grid[{If[ListQ[#], Column[#, Frame -> All, Spacings -> 1], #] & /@ 
    s[[x ;; x + shownSize]]}, Frame -> All], {x, 1, 
  seqLength - shownSize, 1}]

enter image description here

Or for a more traditional representation:

aln1 = "";
aln2 = "";
ident = "";
Do[{
  If[Length[n] == 0,
   {
    aln1 = aln1 <> n,
    aln2 = aln2 <> n,
    Do[ident = ident <> "*", {StringLength[n]}]
    },
   {
    While[StringLength[n[[1]]] != StringLength[n[[2]]], {
      If[StringLength[n[[1]]] < StringLength[n[[2]]], 
       n[[1]] = n[[1]] <> "-",
       n[[2]] = n[[2]] <> "-"]
      }],
    Do[ident = ident <> " ", {Max[Map[StringLength, n]]}],
    aln1 = aln1 <> n[[1]],
    aln2 = aln2 <> n[[2]]
    }
   ]
  }, {n, s}]

Manipulate[
 seqLength2 = StringLength[ident];
 shownSize2 = 40;
 Grid[Characters[{ident, aln1, aln2}][[All, n ;; n + shownSize2]]]
 , {n, 1, seqLength2 - shownSize2, 1}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.