This repository has been archived by the owner on May 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfromGenomeToPalindrome.php
73 lines (64 loc) · 2.41 KB
/
fromGenomeToPalindrome.php
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
###################################################################
# découpe un fichier contenant des génome en plusieur sous fichier ou les génome sont réunis par groupe et les met dans le dossier allGenomes/
# @path chemin vers le fichier
###################################################################
function fromArrayToFiles($path)
{
$file ="";
$handle = fopen($path , "r") or die("Couldn't get handle");
if ($handle)
{
while (!feof($handle))
{
$buffer = fgets($handle, 4096);
if (strpos($buffer , ">") !== FALSE)
{
$arrayTmp = explode(" ", $buffer);
$file = fopen("allGenomes/".$arrayTmp[1].".fasta", "a+") ;
}
fputs($file,$buffer);
}
fclose($handle);
}
} #fin de fonction fromArrayToFiles
###################################################################
# découpe un fichier contenant des génome en plusieur sous fichier qui contient une seul et unique chaine fasta
# @path chemin vers le fichier
###################################################################
function fromAllGenomeToPalindromeFile($path)
{
$file ="";
$filleAllGenomes = fopen($path , "r") or die("File not found");
if ($filleAllGenomes)
{
while (!feof($filleAllGenomes))
{
$buffer = fgets($filleAllGenomes, 4096);
if (strpos($buffer , ">") !== FALSE)
{
$arrayTmp = explode(" ", $buffer);
$arrayTmp2 = explode(">", $arrayTmp[0]);
$nameFile = $arrayTmp[1];
for ($i=2; $i < count($arrayTmp) ; $i++)
{
$nameFile .= " ".$arrayTmp[$i];
}
$nameFile = substr($nameFile, 0 , strlen($nameFile)-1);
$nameFile = $nameFile.".fasta" ;
echo $nameFile;
echo "\n";
$nameFile = mb_ereg_replace("([^\w\s\d\-_~,;\[\]\(\).])", '', $nameFile);
$file = fopen("allGenomes/".$nameFile, "a+") ;
}
fputs($file,$buffer);
if($file === false)
{
echo "probleme false ;";
}
}
fclose($filleAllGenomes);
}
} # fin de fonction fromAllGenomeToPalindromeFile
fromAllGenomeToPalindromeFile($argv[1]);
?>