Play with sequencies


Sample code :


/**
  * Here is some samples of how to use the functions
  * @param SequenceAlignmentInterface $sequenceAlignmentManager
  * @param SequenceInterface $sequenceManager
  * @return Response
  * @throws \Exception
  */
public function playwithsequencies(
    SequenceAlignmentInterface $sequenceAlignmentManager,
    SequenceInterface $sequenceManager
) {
    $sequenceAlignmentManager->setFilename("data/fasta-2.txt");
    $sequenceAlignmentManager->setFormat("FASTA");
    $sequenceAlignmentManager->parseFile();
 
    // We take this sequence as example
    $oSequence = $sequenceAlignmentManager->getSeqSet()->offsetGet(0);
    $oSequence->setMolType("DNA");
    $sequenceManager->setSequence($oSequence);
 
    // Complement of the demo sequence
    $aComplement = $sequenceManager->complement("DNA");
 
    // Shows halfstring for pattern "GATTAG"
    $sHalfStr = $sequenceManager->halfSequence(0, "GATTAG");
 
     // Returns the sequence located between two palindromic halves of a palindromic string
     //$sBridge = $sequenceManager->getBridge("ATGcacgtcCAT");
     //dump($sBridge);
 
     // Returns the expansion of a nucleic acid sequence
     $sExpandNa = $sequenceManager->expandNa("GATTAGSW");
 
     // Computes the molecular weight of a particular sequence.
     $sMolWt = $sequenceManager->molwt();
 
     // Creates a new sequence object with a sequence that is a substring of another.
     $sCoupe = $sequenceManager->subSeq(2,100);
 
     // Array where each key is a substring matching a given pattern
     $aPatpos = $sequenceManager->patPos("TTT");
 
     // Similar to patPos() except that this allows for overlapping patterns.
     $aPatPoso = $sequenceManager->patPoso("TTT");
 
     // Returns the frequency of a given symbol in the sequence property string
     $iSymfreq = $sequenceManager->symFreq("A");
 
     // Returns the n-th codon in a sequence, with numbering starting at 0
     $sCodon = $sequenceManager->getCodon(3);
 
     // Translates a particular DNA sequence into its protein product sequence
     $sTranslate = $sequenceManager->translate();
 
     // Translates an amino acid sequence into its equivalent "charge sequence".
     $sCharge = $sequenceManager->charge("GAVLIFYWKRH");
 
     // Returns a string of symbols from an 8-letter alphabet: A, L, M, R, C, H, I, S.
     $sChemicalGroup = $sequenceManager->chemicalGroup("GAVLIFYWKRH");
 
     // Returns a two-dimensional array containing palindromic substrings found in a sequence
     $aTestPalindrome = $sequenceManager->findPalindrome(null, 2, 2);
 
     return $this->render('default/playwithsequencies.html.twig',
        [
            'complement'        => $aComplement,
            'halfStr'           => $sHalfStr,
            'expandNa'          => $sExpandNa,
            'molWt'             => $sMolWt,
            'coupe'             => $sCoupe,
            'patpos'            => $aPatpos,
            'patposo'           => $aPatPoso,
            'symfreq'           => $iSymfreq,
            'codon'             => $sCodon,
            'translate'         => $sTranslate,
            'charge'            => $sCharge,
            'chemicalGroup'     => $sChemicalGroup,
            'testPalindrome1'   => $aTestPalindrome
        ]
     );
}

Result :

DNA Complement :

"CCGTCTAAGGGGGATCTGGGCGGGCGTGGTACCAGTCCGTACGGGGAGGAGTAGCGACCCGTGTCGGGTCTCCCATATTTGTCACGACCTCCGACCGCCCCGTCCGGTCGACTCAGGACTCGTCGTCGGGTCGCGTCGGTGGCTCTGTGGTACTCTCGGGAGTGTGAGGAGCGGGATAACCGGGACCGGCGTGAAACGTAGCGACCGGTCCGTCCACTCACGGGGGTGGAGGGGAGTCCGGCGTAACGTCACCCCCGACTCTCCTCCTTCGTGGTACCGGGTGGAGAAGAGTGGGGAAACCGACCGTCAGGGAAACGTCAGATTGGTGGAACAACGTCCGAGTTAGGTAAACGGGGTCGAGACGGGAACGTCTCCCTCTCCTCCCTTCTCGTTCGACGGGCTCTGCGTCCCCTTCCTCCTACTCCCGGGACCCCTACTCGACCCCACTTGGTCCGAGGGAAAGGAAACGTCCACGCTTCGGGTCGCCACGTCTCAGGTCGTTTCCACGTCCATACTCCTACCTGGACTACCCAAGGACCTGGGAGGGGAGAGTGGGACCAGGGAGTCAGAGTAAGGGGGTGAGGACGGTGGAGGACAGACCGGTAGTCCTTCCGGTCGGACGAGGGGTGGACTAGGAGGGTTTGGGTCTCGGTGGACTACGGACGGGGAGACGAGGTGTCGGAAACACAGGTTCGTCCTCCCGTCGCTCCATCACTTCTCTGGGTCCGCGATGGACATAGTTACCGACCCCACTCTCTTTTCCGTCTCGACCCGGTTCCGGGACGGAGAGGCCCTACCAGACACCCCCTCGACGTCGTCCCTCACCGGAGAGACCCAACACCACCCCCATGTCCGTCGGACGGGACCACCCGTGGGACCTCGGGGTACACATCCCTCTCCTCCCTACCCGTAAAACGTGCCCCCGACTACGGTGGTGCAGCCCACAGAGTCTCGGGGTCAGGGGATGGGCCTAGGGGACCTCGGGTCCTCCCTCCACACACTCGAGTTAGGCCTGACACTGCTCAACCGACTGGTGTAGCCGAAAGTCCTCCGGATAGCCGCGAAGATGCCGGGCCAGATCCCACAGCGAGACGACCGGACCGGCCGTTGGGGTCAAGACGAGGAGAGGTCCGTGGGAAGAAAGGAGAAGGGGAACGGGAACGGGACTGGAGGGTCGGGATACCTACACCCCAGGGGTAGTAGGGTCGACGAGGGTTTATTTGAGGTCTTC"

Returns the expansion of a nucleic acid sequence ("GATTAGSW")

"GATTAG[GC][AT]"

Shows halfstring for pattern "GATTAG"

"GAT"

Computes the molecular weight of a particular sequence.

379669.7

Creates a new sequence object with a sequence that is a substring of another

"CAGATTCCCCCTAGACCCGCCCGCACCATGGTCAGGCATGCCCCTCCTCATCGCTGGGCACAGCCCAGAGGGTATAAACAGTGCTGGAGGCTGGCGGGGC"

Array where each key is a substring matching a given pattern ("TTT")

array:1 [
  "TTT" => array:10 [
    0 => 193
    1 => 296
    2 => 312
    3 => 348
    4 => 459
    5 => 464
    6 => 682
    7 => 911
    8 => 1042
    9 => 1140
  ]
]

Similar to patPos() except that this allows for overlapping patterns. ("TTT")

array:11 [
  0 => 193
  1 => 296
  2 => 312
  3 => 348
  4 => 459
  5 => 464
  6 => 682
  7 => 911
  8 => 912
  9 => 1042
  10 => 1140
]

Returns the frequency of a given symbol in the sequence property string ("A")

217

Returns the 3rd codon in a sequence, with numbering starting at 0

"CCC"

Translates a particular DNA sequence into its protein product sequence

"GRFPLDPPAPWSGMPLLIAGHSPEGINSAGGWRGRPAES*AAAQRSHRDTMRALTLLALLALAALCIAGQAGECPHLPSGRIAVGAERRKHHGPPLLTPLAGSPFAV*PPCCRLNPFAPALPLQRERREEQAARDAGEGG*GPWG*AGVNQAPFPLQVRSPAVQSPAKVQV*GWT*WVPGPSPLTLVPQSHSPTPATSCLAIRKASLLPT*SSQTQSHLMPAPLLHSLCVQAGGQRGSEETQALPVSMAGVREKAELGQGPASPGWSVGELQQGVASLGCGGGTGSLPWWAPWSPMCRERRDGHFARGLMPPRRVSQSPSPLPGSPGAQEGGV*AQSGL*RVG*PHRLSGGLSALLRPGLGCRSAGLAGNPSSAPLQAPFFPLPLALALTSQPYGCGVPIIPAAPK*TPEX"

Translates an amino acid sequence ("GAVLIFYWKRH") into its equivalent "charge sequence"

"NNNNNNNNCCC"

Returns a string of symbols from an 8-letter alphabet: A, L, M, R, C, H, I, S

"LLLLLRRRCCC"

Returns a two-dimensional array containing palindromic substrings found in a sequence

array:198 [
  0 => array:2 [
    0 => "GC"
    1 => 1
  ]
  1 => array:2 [
    0 => "AT"
    1 => 5
  ]
  2 => array:2 [
    0 => "TA"
    1 => 13
  ]
  3 => array:2 [
    0 => "CG"
    1 => 19
  ]
  4 => array:2 [
    0 => "GC"
    1 => 20
  ]
  5 => array:2 [
    0 => "CG"
    1 => 23
  ]
  6 => array:2 [
    0 => "GC"
    1 => 24
  ]
  7 => array:2 [
    0 => "AT"
    1 => 29
  ]
  8 => array:2 [
    0 => "GC"
    1 => 37
  ]
  9 => array:2 [
    0 => "AT"
    1 => 39
  ]
  10 => array:2 [
    0 => "GC"
    1 => 41
  ]
  11 => array:2 [
    0 => "AT"
    1 => 51
  ]
  12 => array:2 [
    0 => "CG"
    1 => 53
  ]
  13 => array:2 [
    0 => "GC"
    1 => 54
  ]
  14 => array:2 [
    0 => "GC"
    1 => 59
  ]
  15 => array:2 [
    0 => "GC"
    1 => 64
  ]
  16 => array:2 [
    0 => "TA"
    1 => 74
  ]
  17 => array:2 [
    0 => "AT"
    1 => 75
  ]
  18 => array:2 [
    0 => "TA"
    1 => 76
  ]
  19 => array:2 [
    0 => "GC"
    1 => 84
  ]
  20 => array:2 [
    0 => "GC"
    1 => 91
  ]
  21 => array:2 [
    0 => "GC"
    1 => 95
  ]
  22 => array:2 [
    0 => "CG"
    1 => 96
  ]
  23 => array:2 [
    0 => "GC"
    1 => 100
  ]
  24 => array:2 [
    0 => "GC"
    1 => 104
  ]
  25 => array:2 [
    0 => "GC"
    1 => 108
  ]
  26 => array:2 [
    0 => "GC"
    1 => 120
  ]
  27 => array:2 [
    0 => "GC"
    1 => 123
  ]
  28 => array:2 [
    0 => "GC"
    1 => 126
  ]
  29 => array:2 [
    0 => "GC"
    1 => 131
  ]
  30 => array:2 [
    0 => "CG"
    1 => 132
  ]
  31 => array:2 [
    0 => "GC"
    1 => 133
  ]
  32 => array:2 [
    0 => "GC"
    1 => 136
  ]
  33 => array:2 [
    0 => "CG"
    1 => 141
  ]
  34 => array:2 [
    0 => "AT"
    1 => 150
  ]
  35 => array:2 [
    0 => "GC"
    1 => 156
  ]
  36 => array:2 [
    0 => "CG"
    1 => 170
  ]
  37 => array:2 [
    0 => "GC"
    1 => 171
  ]
  38 => array:2 [
    0 => "TA"
    1 => 175
  ]
  39 => array:2 [
    0 => "AT"
    1 => 176
  ]
  40 => array:2 [
    0 => "GC"
    1 => 180
  ]
  41 => array:2 [
    0 => "GC"
    1 => 186
  ]
  42 => array:2 [
    0 => "CG"
    1 => 188
  ]
  43 => array:2 [
    0 => "GC"
    1 => 189
  ]
  44 => array:2 [
    0 => "GC"
    1 => 196
  ]
  45 => array:2 [
    0 => "AT"
    1 => 198
  ]
  46 => array:2 [
    0 => "CG"
    1 => 200
  ]
  47 => array:2 [
    0 => "GC"
    1 => 201
  ]
  48 => array:2 [
    0 => "GC"
    1 => 205
  ]
  49 => array:2 [
    0 => "GC"
    1 => 210
  ]
  50 => array:2 [
    0 => "GC"
    1 => 220
  ]
  51 => array:2 [
    0 => "GC"
    1 => 238
  ]
  52 => array:2 [
    0 => "CG"
    1 => 240
  ]
  53 => array:2 [
    0 => "GC"
    1 => 241
  ]
  54 => array:2 [
    0 => "AT"
    1 => 243
  ]
  55 => array:2 [
    0 => "GC"
    1 => 246
  ]
  56 => array:2 [
    0 => "GC"
    1 => 255
  ]
  57 => array:2 [
    0 => "GC"
    1 => 269
  ]
  58 => array:2 [
    0 => "AT"
    1 => 274
  ]
  59 => array:2 [
    0 => "GC"
    1 => 277
  ]
  60 => array:2 [
    0 => "GC"
    1 => 300
  ]
  61 => array:2 [
    0 => "GC"
    1 => 304
  ]
  62 => array:2 [
    0 => "GC"
    1 => 315
  ]
  63 => array:2 [
    0 => "TA"
    1 => 321
  ]
  64 => array:2 [
    0 => "GC"
    1 => 334
  ]
  65 => array:2 [
    0 => "GC"
    1 => 338
  ]
  66 => array:2 [
    0 => "AT"
    1 => 343
  ]
  67 => array:2 [
    0 => "AT"
    1 => 347
  ]
  68 => array:2 [
    0 => "GC"
    1 => 351
  ]
  69 => array:2 [
    0 => "GC"
    1 => 357
  ]
  70 => array:2 [
    0 => "GC"
    1 => 362
  ]
  71 => array:2 [
    0 => "GC"
    1 => 368
  ]
  72 => array:2 [
    0 => "GC"
    1 => 389
  ]
  73 => array:2 [
    0 => "GC"
    1 => 393
  ]
  74 => array:2 [
    0 => "GC"
    1 => 396
  ]
  75 => array:2 [
    0 => "CG"
    1 => 399
  ]
  76 => array:2 [
    0 => "CG"
    1 => 404
  ]
  77 => array:2 [
    0 => "GC"
    1 => 405
  ]
  78 => array:2 [
    0 => "AT"
    1 => 419
  ]
  79 => array:2 [
    0 => "GC"
    1 => 425
  ]
  80 => array:2 [
    0 => "AT"
    1 => 434
  ]
  81 => array:2 [
    0 => "GC"
    1 => 438
  ]
  82 => array:2 [
    0 => "GC"
    1 => 453
  ]
  83 => array:2 [
    0 => "GC"
    1 => 467
  ]
  84 => array:2 [
    0 => "GC"
    1 => 473
  ]
  85 => array:2 [
    0 => "CG"
    1 => 474
  ]
  86 => array:2 [
    0 => "GC"
    1 => 478
  ]
  87 => array:2 [
    0 => "GC"
    1 => 483
  ]
  88 => array:2 [
    0 => "CG"
    1 => 484
  ]
  89 => array:2 [
    0 => "GC"
    1 => 488
  ]
  90 => array:2 [
    0 => "GC"
    1 => 498
  ]
  91 => array:2 [
    0 => "GC"
    1 => 506
  ]
  92 => array:2 [
    0 => "TA"
    1 => 511
  ]
  93 => array:2 [
    0 => "AT"
    1 => 512
  ]
  94 => array:2 [
    0 => "AT"
    1 => 518
  ]
  95 => array:2 [
    0 => "AT"
    1 => 527
  ]
  96 => array:2 [
    0 => "AT"
    1 => 571
  ]
  97 => array:2 [
    0 => "GC"
    1 => 585
  ]
  98 => array:2 [
    0 => "GC"
    1 => 600
  ]
  99 => array:2 [
    0 => "AT"
    1 => 603
  ]
  100 => array:2 [
    0 => "GC"
    1 => 612
  ]
  101 => array:2 [
    0 => "GC"
    1 => 616
  ]
  102 => array:2 [
    0 => "GC"
    1 => 620
  ]
  103 => array:2 [
    0 => "AT"
    1 => 632
  ]
  104 => array:2 [
    0 => "GC"
    1 => 649
  ]
  105 => array:2 [
    0 => "AT"
    1 => 657
  ]
  106 => array:2 [
    0 => "GC"
    1 => 659
  ]
  107 => array:2 [
    0 => "GC"
    1 => 663
  ]
  108 => array:2 [
    0 => "GC"
    1 => 671
  ]
  109 => array:2 [
    0 => "GC"
    1 => 679
  ]
  110 => array:2 [
    0 => "GC"
    1 => 693
  ]
  111 => array:2 [
    0 => "GC"
    1 => 701
  ]
  112 => array:2 [
    0 => "GC"
    1 => 704
  ]
  113 => array:2 [
    0 => "CG"
    1 => 705
  ]
  114 => array:2 [
    0 => "TA"
    1 => 710
  ]
  115 => array:2 [
    0 => "GC"
    1 => 726
  ]
  116 => array:2 [
    0 => "CG"
    1 => 727
  ]
  117 => array:2 [
    0 => "GC"
    1 => 728
  ]
  118 => array:2 [
    0 => "TA"
    1 => 730
  ]
  119 => array:2 [
    0 => "TA"
    1 => 736
  ]
  120 => array:2 [
    0 => "AT"
    1 => 737
  ]
  121 => array:2 [
    0 => "AT"
    1 => 741
  ]
  122 => array:2 [
    0 => "GC"
    1 => 744
  ]
  123 => array:2 [
    0 => "GC"
    1 => 762
  ]
  124 => array:2 [
    0 => "GC"
    1 => 767
  ]
  125 => array:2 [
    0 => "GC"
    1 => 772
  ]
  126 => array:2 [
    0 => "GC"
    1 => 778
  ]
  127 => array:2 [
    0 => "GC"
    1 => 783
  ]
  128 => array:2 [
    0 => "CG"
    1 => 790
  ]
  129 => array:2 [
    0 => "AT"
    1 => 794
  ]
  130 => array:2 [
    0 => "GC"
    1 => 809
  ]
  131 => array:2 [
    0 => "GC"
    1 => 812
  ]
  132 => array:2 [
    0 => "GC"
    1 => 815
  ]
  133 => array:2 [
    0 => "GC"
    1 => 825
  ]
  134 => array:2 [
    0 => "TA"
    1 => 848
  ]
  135 => array:2 [
    0 => "GC"
    1 => 853
  ]
  136 => array:2 [
    0 => "GC"
    1 => 856
  ]
  137 => array:2 [
    0 => "GC"
    1 => 860
  ]
  138 => array:2 [
    0 => "GC"
    1 => 870
  ]
  139 => array:2 [
    0 => "GC"
    1 => 880
  ]
  140 => array:2 [
    0 => "AT"
    1 => 885
  ]
  141 => array:2 [
    0 => "TA"
    1 => 890
  ]
  142 => array:2 [
    0 => "AT"
    1 => 904
  ]
  143 => array:2 [
    0 => "GC"
    1 => 908
  ]
  144 => array:2 [
    0 => "AT"
    1 => 910
  ]
  145 => array:2 [
    0 => "GC"
    1 => 915
  ]
  146 => array:2 [
    0 => "CG"
    1 => 918
  ]
  147 => array:2 [
    0 => "GC"
    1 => 923
  ]
  148 => array:2 [
    0 => "AT"
    1 => 927
  ]
  149 => array:2 [
    0 => "GC"
    1 => 929
  ]
  150 => array:2 [
    0 => "CG"
    1 => 936
  ]
  151 => array:2 [
    0 => "CG"
    1 => 939
  ]
  152 => array:2 [
    0 => "GC"
    1 => 952
  ]
  153 => array:2 [
    0 => "TA"
    1 => 964
  ]
  154 => array:2 [
    0 => "CG"
    1 => 968
  ]
  155 => array:2 [
    0 => "AT"
    1 => 971
  ]
  156 => array:2 [
    0 => "GC"
    1 => 981
  ]
  157 => array:2 [
    0 => "GC"
    1 => 1002
  ]
  158 => array:2 [
    0 => "AT"
    1 => 1007
  ]
  159 => array:2 [
    0 => "CG"
    1 => 1010
  ]
  160 => array:2 [
    0 => "CG"
    1 => 1020
  ]
  161 => array:2 [
    0 => "GC"
    1 => 1027
  ]
  162 => array:2 [
    0 => "AT"
    1 => 1036
  ]
  163 => array:2 [
    0 => "CG"
    1 => 1038
  ]
  164 => array:2 [
    0 => "GC"
    1 => 1040
  ]
  165 => array:2 [
    0 => "GC"
    1 => 1051
  ]
  166 => array:2 [
    0 => "TA"
    1 => 1054
  ]
  167 => array:2 [
    0 => "AT"
    1 => 1055
  ]
  168 => array:2 [
    0 => "CG"
    1 => 1057
  ]
  169 => array:2 [
    0 => "GC"
    1 => 1059
  ]
  170 => array:2 [
    0 => "CG"
    1 => 1060
  ]
  171 => array:2 [
    0 => "GC"
    1 => 1061
  ]
  172 => array:2 [
    0 => "TA"
    1 => 1066
  ]
  173 => array:2 [
    0 => "CG"
    1 => 1068
  ]
  174 => array:2 [
    0 => "GC"
    1 => 1070
  ]
  175 => array:2 [
    0 => "CG"
    1 => 1073
  ]
  176 => array:2 [
    0 => "TA"
    1 => 1078
  ]
  177 => array:2 [
    0 => "CG"
    1 => 1086
  ]
  178 => array:2 [
    0 => "GC"
    1 => 1087
  ]
  179 => array:2 [
    0 => "GC"
    1 => 1092
  ]
  180 => array:2 [
    0 => "GC"
    1 => 1096
  ]
  181 => array:2 [
    0 => "GC"
    1 => 1101
  ]
  182 => array:2 [
    0 => "CG"
    1 => 1103
  ]
  183 => array:2 [
    0 => "GC"
    1 => 1105
  ]
  184 => array:2 [
    0 => "GC"
    1 => 1119
  ]
  185 => array:2 [
    0 => "GC"
    1 => 1131
  ]
  186 => array:2 [
    0 => "GC"
    1 => 1155
  ]
  187 => array:2 [
    0 => "GC"
    1 => 1161
  ]
  188 => array:2 [
    0 => "GC"
    1 => 1175
  ]
  189 => array:2 [
    0 => "TA"
    1 => 1179
  ]
  190 => array:2 [
    0 => "AT"
    1 => 1180
  ]
  191 => array:2 [
    0 => "AT"
    1 => 1184
  ]
  192 => array:2 [
    0 => "AT"
    1 => 1197
  ]
  193 => array:2 [
    0 => "AT"
    1 => 1200
  ]
  194 => array:2 [
    0 => "GC"
    1 => 1206
  ]
  195 => array:2 [
    0 => "GC"
    1 => 1209
  ]
  196 => array:2 [
    0 => "AT"
    1 => 1217
  ]
  197 => array:2 [
    0 => "TA"
    1 => 1218
  ]
]