Advertisement
icarussiano

Es estrazione gi,pdb da fasta

Dec 6th, 2022 (edited)
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.71 KB | None | 0 0
  1. <?php
  2. $s=file_get_contents("actin-human.fasta");
  3. $righe=explode("\n",$s);
  4. $string1="gaattg";
  5. $gi_regexp="/^>gi\|(\d{5,12})\|/";
  6. $pdb_regexp="/\|pdb\|(\w+)\|/";
  7. $array_gi=array();
  8. $array_pdb=array();
  9. $i=0;
  10. $j=0;
  11.  
  12. foreach($righe as $riga){
  13.   $riga=trim($riga);
  14.   if(preg_match($gi_regexp,$riga,$matches)){
  15.       array_push($array_gi,$matches[1]);
  16.       $i++;
  17. }
  18.   if(preg_match($pdb_regexp,$riga,$matches)){
  19.       array_push($array_pdb,$matches[1]);
  20.       $j++;
  21. }
  22. }
  23. echo "<p>trovati $i gi</p><p>";
  24. echo "trovati $j pdb</p><p>";
  25. echo "i gi trovati sono:</p><p>";
  26. foreach($array_gi as $gi){
  27.   echo $gi."<br>";
  28. }
  29. echo "i pdb trovati sono:</p><p>";
  30. foreach($array_pdb as $pdb){
  31.   echo $pdb."<br>";
  32. }
  33. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement