Listing du fichier genereXml.php
00001 <?php
00002 # (gH) -_- genereXml.php ; TimeStamp (unix) : 29 Septembre 2012 vers 18:04
00003
00004 error_reporting(E_ALL | E_NOTICE | E_STRICT) ;
00005
00006 header('Content-type: text/xml');
00007
00008 $pId = array() ;
00009 $pClass = array() ;
00010 $pLength = array() ;
00011 $pSeq = array() ;
00012
00013 $pn = 0 ;
00014
00015 # protéine 1
00016 $pn++ ;
00017 $pId[$pn] = "A2ZDX4" ;
00018 $pClass[$pn] = 1 ;
00019 $pSeq[$pn] = "MEYQGQHGGHASSRADEHGNPAVTTGNAPTGMGAGHIQEPAREDKKTDGVLRRSGSSSSSSSSEDDGMGGRRKKGIKEKIKEKLPGGNKGNNQQQQQEHTTTTTGGAYGPQGHDTKIATGAHGGTAATTADAGGEKKGIVDKIKEKLPGQH" ;
00020 $pLength[$pn] = strlen($pSeq[$pn]) ;
00021
00022 # protéine 2
00023
00024 $pn++ ;
00025 $pId[$pn] = "A2ZDX6" ;
00026 $pClass[$pn] = 1 ;
00027 $pSeq[$pn] = "MENYQGQHGYGADRVDVYGNPVAGQYGGGATAPGGGHGVMGMGGHHAGAGGQFQPVKEEHKTGGILHRSGSSSSSSSSEDDGMGGRRKKGIKEKIKEKLPGGNKGNNHQQQQMMGNTGGAYGQQGHAGMTGAGTGTGVHGAEYGNTGEKKGFMDKIKEKLPGQH" ;
00028 $pLength[$pn] = strlen($pSeq[$pn]) ;
00029
00030 # protéine 3
00031
00032 $pn++ ;
00033 $pId[$pn] = "AAA33480" ;
00034 $pClass[$pn] = 2 ;
00035 $pSeq[$pn] = "MEDERNTQQHQGGEQAQDQENEVKDRGLLDSLLGRNKHDDQEKKNQQEEEELATGMEKVTVAEPDHKEEGHEAAEKKDSLLAKLHRTSSSSSSSSDDEEEEVIDENGEIVKRKKKGLKEKVKEKSAAHKAHDEGDHHQPGVPAPAPAPPVAVDTHAHHQEGEHKPHFPAPAPPPHVETHHPVVVHKIEDDDTKTQTPPQAPEEEKKGLLDKIKEKLPGGHKKPEDAAAAAAAPAVHAPPPPAPHAEVDVSSPDGKKGLLGKIMDKIPGYHKSSGEEDRKDAAGEHKTSS" ;
00036 $pLength[$pn] = strlen($pSeq[$pn]) ;
00037
00038 # protéine 4
00039
00040 $pn++ ;
00041 $pId[$pn] = "AAB18201" ;
00042 $pClass[$pn] = 2 ;
00043 $pSeq[$pn] = "MEDERSTQSYQGGEAAEQVEVTDRGLLGNLLGKKKAEEDKEKKEEELVTGMEKVSVEEPEVKKEEHVDGEKKETLFSKLHRSSSSSSSSSDEEEEEVIDDNGEVIKRKKKKGLKEKLQEKLPGHKDTEGEHVTALPAPAAPASVQTHHDTDVVVEKIDGDVKTEATPAVPEEEKKGFLEKIKEKLPGGHKKPEDAAAVPVTHAAPAPVTHAAPAPVHAPAPAAEEVSSPDAKEKKGLLGKIMDKLPGYHKTGEEDKAAAATGEHKPSA" ;
00044 $pLength[$pn] = strlen($pSeq[$pn]) ;
00045
00046 # protéine 5
00047
00048 $pn++ ;
00049 $pId[$pn] = "AAB18202" ;
00050 $pClass[$pn] = 2 ;
00051 $pSeq[$pn] = "MEDERSTQSYQGGEAAEQVEVTDRGLLGNLLGKKKAEEDKEKQEELVTGMEKVSVEEPEVKKEEHEDGEKKETLFSKLHRSSSSSSSSSDEEEEEVIDDNGEVIKRKKKKGLKEKLKEKLPGHKDTEGEHVTGLPAPAAPASVQTHHDTDVVVEKIDGDVKTEAAPAVPEEEKKGFLEKIKEKLPGGHKKPEDAAPVPVTHAAPAPVHAPAPAAEEVSSPDAKEKKGLLGKIMDKLPGYHKTGEEDKAAAAAGEHKPSA" ;
00052 $pLength[$pn] = strlen($pSeq[$pn]) ;
00053
00054 $nbProt = $pn ;
00055
00056 $domtree = new DOMDocument('1.0', 'UTF-8');
00057 $rootElt = $domtree->createElement("proteins");
00058 $tmp = $domtree->appendChild($rootElt);
00059
00060 for ($idp=1;$idp<=$nbProt;$idp++) {
00061
00062 $prot = $domtree->createElement("protein"); # nouvel élément <protein>
00063
00064 if (isset($_GET["i"])) { # identifiant
00065 if ($_GET["i"]=="e") {
00066 $pi = $domtree->createElement("identifiant",$pId[$idp]) ; # nouvel élément <identifiant>
00067 $tmp = $prot->appendChild($pi);
00068 } else {
00069 $prot->setAttribute("identifiant",$pId[$idp]) ; # nouvel attribut identifiant
00070 } # fin si sur élément ou attribut
00071 } # fin si sur i
00072
00073 if (isset($_GET["c"])) { # classe
00074 if ($_GET["c"]=="e") {
00075 $pc = $domtree->createElement("class",$pClass[$idp]) ;
00076 $tmp = $prot->appendChild($pc);
00077 } else {
00078 $prot->setAttribute("class",$pClass[$idp]) ;
00079 } # fin si sur élément ou attribut
00080 } # fin si sur c
00081
00082 if (isset($_GET["l"])) { # longueur
00083 if ($_GET["l"]=="e") {
00084 $pl = $domtree->createElement("longueur",$pLength[$idp]) ;
00085 $tmp = $prot->appendChild($pl);
00086 } else {
00087 $prot->setAttribute("longueur",$pLength[$idp]) ;
00088 } # fin si sur élément ou attribut
00089 } # fin si sur c
00090
00091 if (isset($_GET["s"])) { # sequence
00092 if ($_GET["s"]=="e") {
00093 # une variante, sans doute moins lisible
00094 $tmp = $prot->appendChild( $domtree->createElement("sequence",$pSeq[$idp]) ) ;
00095 } else {
00096 $prot->setAttribute("sequence",$pSeq[$idp]) ;
00097 } # fin si sur élément ou attribut
00098 } # fin si sur s
00099
00100 # ajout de la nouvelle protéines
00101
00102 $tmp = $rootElt->appendChild($prot);
00103
00104 } ; # fin pour idp
00105
00106 echo $domtree->saveXML();
00107
00108
00109 ?>
Retour à la page principale de (gH)