Play with proteins

1

Starting code

This is the PHP code used by this example.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
  * Here is some samples of how to use the functions
  * @param ProteinInterface $proteinManager
  * @return Response
  * @throws \Exception
  */
public function playwithproteins(ProteinInterface $proteinManager)
{
   $sProtein = "ARNDCEQGHARNDCEQGHILKMFPSTWYVXARNDKMFPSTWYVXARNDKMFPSTWYVXARNDCEQGHARNDCEQGHHARNDCEQGHILKMFPSTW";
   $sProtein .= "YVXARNDKMFPSTHARNDCEQGHILKMFPSTWYVXARNDKMFPSTHARNDCEQGHILKMFPSTWYVXARNDKMFPSTHARNDCEQGHILKMFPSTWY";
   $sProtein .= "VXARNDKMFPSTHARNDCEQGHILKMFPSTWYVXARNDKMFPST";
 
   $oProtein = new Protein();
   $oProtein->setName("toto");
   $oProtein->setSequence($sProtein);
   $proteinManager->setProtein($oProtein);
 
   $iLength = $proteinManager->seqlen();
   $iMolwt = $proteinManager->molwt();
 
   // New in biophp 1.1: the protein as a validated, immutable value object
   $oAminoSeq = new AminoAcidSequence($sProtein);
   $iVoLength = $oAminoSeq->getLength();
   $bVoHasStop = $oAminoSeq->hasStop();
   $bVoHasUnknownResidue = $oAminoSeq->hasUnknownResidue();
   $iVoCountX = $oAminoSeq->countSymbol('X');
 
   return $this->render('default/playwithproteins.html.twig',
       [
           'length'              => $iLength,
           'molwt'               => $iMolwt,
           'voLength'            => $iVoLength,
           'voHasStop'           => $bVoHasStop,
           'voHasUnknownResidue' => $bVoHasUnknownResidue,
           'voCountX'            => $iVoCountX
       ]
   );
}
2

Result

Result returned by BioPHP for the demonstration data.

Returns the length of a protein :
236
Returns the molweight of a protein :
  • 0 : 27394.955
  • 1 : 28428.155
3

New in biophp 1.1: the protein as a value object


Length, computed by the AminoAcidSequence value object
236
Does the chain hold a stop codon ("*") ?
No
Does the chain hold an unknown residue ("X") ?
Yes
Number of "X" residues in the chain
8

The code above is the one actually executed by this page. Find the other examples in the left-hand column, or the tools in BioTools.