Enguerran Vanquelef Scripts



In construction, try later...





R.E.DD.B icon
























Find below the script named 0make_links_last.tcsh which creat for yous links needed by R.E.D. program i.e. Mol_red$i.p2n and Mol_red$i.log links. You must indiquate in the script before run it the pattern of the files you want to be linked in last by modifying the "squelette" variable. You can donwload the script 0make_links_last.tcsh here.
Some commentaries and messages are written in french, you can easily translate them into your own langage with any online translator of your choice. I will upgrade these script in english as soon as possible, but it will take some time..

      #!/bin/tcsh
      #
      echo "\n\t*********************************************************"
      echo "\t           script written by Enguerran Vanquelef"
      echo "\t              Faculté de Pharmacie d'Amiens"
      echo "\t        enguerran.vanquelef@q4md-forcefieldtools.org"
      echo "\t             http://q4md-forcefieldtools.org"
      echo "\t*********************************************************\n"
      
      #here, write a part of the name of the molecule you want have the last number
      # i.e. : in general it is this molecule which gonna be fusionned by ligands
      set squelette = calix
      #echo "\nLast files linked :" $squelette"*.p2n" "and" $squelette"*.log"
      
      #how many .p2n et .log files
      touch temp_p2n.txt
      touch temp_log.txt
      ls -fv *.p2n > temp_p2n.txt
      ls -fv *.log > temp_log.txt
      
      #echo "\n Control of temp_p2n.txt and temp_log.txt"
      #echo "\n temp_p2n.txt :"
      #more temp_p2n.txt
      #echo "\n temp_log.txt"
      #more temp_log.txt
      
      touch first_p2n.txt
      touch first_log.txt
      touch last_p2n.txt
      touch last_log.txt
      grep -v $squelette temp_p2n.txt > first_p2n.txt
      grep -v $squelette temp_log.txt > first_log.txt
      grep  $squelette temp_p2n.txt > last_p2n.txt
      grep  $squelette temp_log.txt > last_log.txt
      
      #echo "\n Control of first*.txt and last*.txt"
      #echo "\n first_p2n.txt :"
      #more first_p2n.txt
      #echo "\n first_log.txt :"
      #more first_log.txt
      #echo "\n last_p2n.txt :"
      #more last_p2n.txt
      #echo "\n last_log.txt :"
      #more last_log.txt
      
      # The char ` allows to allocate to a variable the result of a command
      set  first_p2n = `more first_p2n.txt`
      set  first_log = `more first_log.txt`
      set  last_p2n = `more last_p2n.txt`
      set  last_log = `more last_log.txt`
      
      # Compteur de liens
      set z = 0
      
      
      #echo "\nLinks creation"
      set i = `wc -l first_p2n.txt`
      set j = `wc -l first_log.txt`
      set k = $i[1] #because wc render line number AND name of the file
      set l = $j[1] #because wc render line number AND name of the file
      #echo "\n\tnbre p2n first = $k\n\tnbre log first = $l"
      
      # Verification wether number of .p2n = number of .log
      if ($k != $l) then
        rm temp_p2n.txt temp_log.txt first_p2n.txt first_log.txt last_p2n.txt last_log.txt
        echo "\n*** First files:\n  Error : number of .p2n files is different of number of .log files"
        else
        echo "\n*** First files:\n  Warning : OK, number of .p2n files equal number of .log files\n"
      endif
      
      # linking of first files
      set n = 1
      while ($n <= $k)
        ln -s $first_p2n[$n] Mol_red$n.p2n
        ln -s $first_log[$n] Mol_red$n.log
        echo "Mol_red$n.p2n  -->  $first_p2n[$n]\nMol_red$n.log  -->  $first_log[$n]"
        @ n++
        @ z++
        @ z++
      end
      #echo "\n\tn = $n"
      
      
      # Determination of the number of elements within $liste_p2n and $liste_log
      #echo "\nControl of the number of elements of the two variables liste_p2n and liste_log"
      #wc -l first_p2n.txt
      #wc -l first_log.txt
      set o = `wc -l last_p2n.txt`
      set p = `wc -l last_log.txt`
      set q = $o[1] #because wc render line number AND name of the file
      set r = $p[1] #because wc render line number AND name of the file
      #echo "\n\tnbre p2n last = $q\n\tnbre log last = $r"
      
      # Verification wether number of .p2n = number of .log
      if ($q != $r) then
        rm temp_p2n.txt temp_log.txt first_p2n.txt first_log.txt last_p2n.txt last_log.txt
        echo "\n*** Last files:\n  Error : number of .p2n files is different of number of .log files"
        else
        echo "\n*** Last files:\n  Warning : OK, number of .p2n files equal number of .log files\n"
      endif
      
      
      # ligands will start with number 2
      set x = 1
      set y = $n
      #echo "\n x=$x\n y=$y"
      while ($x <= $q)
        ln -s $last_p2n[$x] Mol_red$y.p2n
        ln -s $last_log[$x] Mol_red$y.log
        echo "Mol_red$y.p2n  -->  $last_p2n[$x]\nMol_red$y.log  -->  $last_log[$x]"
        @ x++
        @ y++
        @ z++
        @ z++
      end
      
      rm temp_p2n.txt temp_log.txt first_p2n.txt first_log.txt last_p2n.txt last_log.txt
      #ls -v
      #echo "\n C'est fini mon petit...\n"
      
      echo "\n\n*** $z links created"
      echo "\a\n\n\tWork done...\n"
    

Find below the script named 0supercharge.tcl, written in Tcl which compute for you global charge of leaving groups involved in INTRA- or INTER-MCC, if they are name with V, W, X, Y or Z letter as explaine in first lines of the code. You can donwload 0supercharge.tcl here.
Some commentaries and messages are written in french, you can easily translate them into your own langage with any online translator of your choice. I will upgrade these script in english as soon as possible, but it will take some time.


      #!/usr/bin/tclsh
      
      #*********************************************************
      #         script written by Enguerran Vanquelef
      #             Faculté de Pharmacie d'Amiens
      #       enguerran.vanquelef@q4md-forcefieldtools.org
      #           http://q4md-forcefieldtools.org
      #*********************************************************
      
      
      # This script compute global charge of "leaving" groups 
      # Leaving groups are composed by V, W, X, Y or Z letter
      # Easy modifications can be made to define more leaving groups
      # Add letters you want in the first switch command
      
      #Le _&& $typeGPref!=""_ dans _if {$nom_grp!="" && $typeGPref!=""} {_ est une "rustine"
      #sinon, il affiche le premier GP normalement, puis une 2ème fois, avec un typGPref=""
      
      set path [pwd]
      puts $path
      
      proc GP {chaine} {
        set composition [split $chaine {}]
        set n_car [llength $composition] ;# nombre de caractère dans le nom de l'atome
        for {set i 0} {$i<$n_car} {incr i} {
          set car_crt [lindex $composition $i]
            switch $car_crt {
              V {return [set resultat "oui V"]}
              W {return [set resultat "oui W"]}
              X {return [set resultat "oui X"]}
              Y {return [set resultat "oui Y"]}
              Z {return [set resultat "oui Z"]}
              default {set resultat "non C"} ;# pas return sinon la proc s'arrête dès qu'elle ne recontre pas un VWXYZ.
            } ;# fin switch
        } ;# fin for
      } ;# fin proc
      
      set fichier2 [open $path/0resultats_supercharge.txt w]
      set liste_mol2 [lsort -dictionary [glob $path/*.mol2]]
      set nombre_mol2 [llength $liste_mol2]
      puts $fichier2 $path
      for {set n 0} {$n<$nombre_mol2} {incr n} {
        set nom_fich_mol2 [lindex $liste_mol2 $n]
        #puts $fichier2 "\n[file tail $nom_fich_mol2]"
        #puts "\n[file tail $nom_fich_mol2]"
        set fichier1 [open $nom_fich_mol2 r]
        set ligne [gets $fichier1]
        set nom_molecule [lindex [set ligne [gets $fichier1]] 0]
        puts $fichier2 "\n[file tail $nom_fich_mol2] = $nom_molecule"
        puts "\n[file tail $nom_fich_mol2] = $nom_molecule"
        set car1 [lindex $ligne 0]
        while {$car1!="@ATOM"} {
          set ligne [gets $fichier1]
          set car1 [lindex $ligne 0]
        }
        # The cursor is now at the beginning of the coordinate and charge block. The file and the screen display "file name = residue name"
      
        # Initialisation
        set charge_totale 0
        set charge_grp 0
        set nom_grp ""
        set ligne [gets $fichier1] ;# puts "charge total initiale [format %+5.4f $charge_totale]"
        set typeGPref [lindex [GP [lindex $ligne 1]] 1]
        #puts "Initialisation: $charge_totale,$charge_grp,$nom_grp,$typeGPref."
      
        while {[lindex $ligne 0]!="@BOND"} {
          set num_atome [lindex $ligne 0]
          set nom_atome [lindex $ligne 1]
          set charge_atome [lindex $ligne 8]
          set charge_totale [expr $charge_totale + $charge_atome]
          set presenceGP [lindex [GP $nom_atome] 0]
          set typeGP [lindex [GP $nom_atome] 1] ; #puts "$num_atome typeGP while: $typeGP"
      
          if {$presenceGP=="oui"} {
            if {$typeGP==$typeGPref} {
              set nom_grp $nom_grp[lindex [split $nom_atome {}] 0]
              set charge_grp [expr $charge_grp+$charge_atome]
              set typeGPref $typeGP
            } else { ;#cad un nouveau type de GP
              if {$nom_grp!="" && $typeGPref!=""} { ;#sauvegarde des résultats, raz et extraction des données
                puts $fichier2 "$typeGPref $nom_grp[format %10s [format %5.4f $charge_grp]]"
                puts "$typeGPref $nom_grp[format %10s [format %5.4f $charge_grp]]"
                set nom_grp ""
                set charge_grp 0
                set nom_grp $nom_grp[lindex [split $nom_atome {}] 0]
                set charge_grp [expr $charge_grp+$charge_atome]
                set typeGPref $typeGP
              } else { ;#il n'y avait pas de donnée à sauvegarder, raz et extraction des données
                set nom_grp ""
                set charge_grp 0
                set nom_grp $nom_grp[lindex [split $nom_atome {}] 0]
                set charge_grp [expr $charge_grp+$charge_atome]
                set typeGPref $typeGP
              }
            } ;# fin du si(non) $typeGP==$typeGPref
          } else { ;# il n'y a pas de GP
            if {$nom_grp!="" && $typeGPref!=""} { ;# affichage du GP si il y en a un
              puts $fichier2 "$typeGPref $nom_grp[format %10s [format %5.4f $charge_grp]]"
              puts "$typeGPref $nom_grp[format %10s [format %5.4f $charge_grp]]"
            } ;# fin de l'affichage du GP si il y en a un juste au dessus
            set typeGPref $typeGP
          } ;# fin du si il y a un GP
          set ligne [gets $fichier1] ;# lecture de la ligne suivante
        } ;# fin du while
        # sauvegarde du dernier GP si il y en a un
        if {$nom_grp!="" && $typeGPref!=""} {
          puts $fichier2 "$typeGPref $nom_grp[format %10s [format %5.4f $charge_grp]]"
          puts "$typeGPref $nom_grp[format %10s [format %5.4f $charge_grp]]"
        }
        puts $fichier2 "charge totale =[format %10s [format %5.4f $charge_totale]]"
        puts "charge totale =[format %10s [format %5.4f $charge_totale]]"
        set charge_totale 0
      } ;# fin du for
      close $fichier2
      puts "\nLes résultats sont regroupés dans le fichier 0resultats_supercharge.txt"
      puts "les GP sont affichés par ordre d'apparition dans le fichier .mol2"
    


Last update of this web page: June, 23th 2010