#rR gscope_misc.tcl proc CompareLesARNs {K L} { set I 0 foreach Ligne [LesLignesDuFichier [Fiches "bornesdesarns"]] { if { ! [regexp {rRNA-16S} $Ligne]} { continue } incr I scan $Ligne "%s %d %d %s" N D F S if {$S=="R"} { incr D 198 ; incr F 198 } set Seq [BoutADN $D $F $S] set SeqDe($I) $Seq } set NbE 0 foreach A [split $SeqDe($K) ""] B [split $SeqDe($L) ""] { if {$A!=$B} { incr NbE } } Espionne $NbE return set P1 [string first aaagaggggga $SeqDe(1)] set P2 [string first aaagaggggga $SeqDe(2)] Espionne $P1 $P2 [expr $P1-$P2] Espionne [string range $SeqDe(1) 198 298] Espionne [string range $SeqDe(2) 0 100] return } proc TestCG {{Seq ""}} { set SeqPro [SeqNucToSeqPro [RandomAdnFromProteinSequence $Seq]] return $SeqPro } proc RandomAdnFromProteinSequence {{Seq ""}} { if {$Seq==""} { set Seq "NiceICanTranslateDna" } foreach A [split $Seq ""] { set MesCodons [CodonsDuAA $A] set M [expr [llength $MesCodons]-1] set N [expr $M+1] set Ra [expr rand()] set R [expr round($Ra*$M)] set Codon [lindex $MesCodons $R] #Espionne $A je prends le $R (0-$M) : $Codon parmi $N codons : $MesCodons random $Ra lappend LesNuc $Codon } set SeqNuc [join $LesNuc ""] return $SeqNuc } proc BeauCodeGenetique {} { foreach B2 [list A C G T] { foreach B3 [list A C G T] { set LaLigne {} foreach B1 [list A C G T] { set Codon "$B1$B2$B3" set AA [CodeGenetique $Codon] regsub "X" $AA "*" lappend LaLigne "$Codon $AA" lappend EnLong "$B2$B3$B1 [CodeGenetique $B2$B3$B1]" } set Ligne [join $LaLigne " "] lappend LesLignes $Ligne } lappend LesLignes "" } EspionneL $EnLong set Texte [join $LesLignes "\n"] return $Texte } proc CodeGenetique {{Qui ""} { Quoi ""}} { #rR CodeGenetique rend l'acide amine d'un codon, ou les codons d'un acide amine #rR ou le code a 3 lettres d'un code a 1 lettre et inversement #rR ou les listes de tout ca. #rR A signifie acide amine a 1 lettre (code par exemple M) #rR AAA signifie acide amine a 3 lettres (code par exemple Met) #rR Qui peut aussi etre ListOf #rR Quoi peut etre A AAA Codons global CodeGenetique #rR comportement par defaut if {$Qui==""} { set Qui "ListOf"; set Quoi "Codons" } if {$Quoi=="" && [regexp -nocase {^[ATGC][ATGC][ATGC]$} $Qui]} { set Quoi "A" } if {[regexp -nocase "Codon" $Quoi]} { set Quoi "Codons" } if {$Quoi==""} { set Quoi "Codons" } #rR on regle le cas de majuscules minuscules pour un aa a 1 lettre un codon ou un aa a 3 lettres if {[regexp -nocase {^[A-Z][A-Z][A-Z]$} $Qui]} { set Qui [string totitle $Qui] } if {[regexp -nocase {^[ATGC][ATGC][ATGC]$} $Qui]} { set Qui [string toupper $Qui] } if {[regexp -nocase {^[A-Z]$} $Qui]} { set Qui [string toupper $Qui] } if {[info exists CodeGenetique($Qui,$Quoi)]} { return $CodeGenetique($Qui,$Quoi) } if {[info exists CodeGenetique("EstCharge")]} { if {[regexp {^[ATGC][ATGC][ATGC]$} $Qui] && [info exists CodeGenetique($Qui,A)]} { #rR pour un codon on rend les codons qui codent pour le meme A set A $CodeGenetique($Qui,A) if {[info exists CodeGenetique($A,$Quoi)]} { return $CodeGenetique($A,$Quoi) } } return "" } set CodeGenetique("EstCharge") 1 #rR au premier appel on passe par ici pour charger le tout, puis plus jamais. set FichierCodeGenetique "[GscopeEtc]/gscope_codegenetique.txt" set AllCodons {} set CodeGenetique(ListOf,A) {} set CodeGenetique(ListOf,AAA) {} foreach Ligne [LesLignesDuFichier $FichierCodeGenetique] { regsub -all { +} $Ligne " " Ligne set Ligne [string trim $Ligne] if {$Ligne==""} { continue } set LesMots [LesMotsDeLaLigne $Ligne] set A [string toupper [lindex $LesMots 0]] set AAA [string totitle [lindex $LesMots 1]] if {$A=="*"} { set A "X" } set CodeGenetique($A,Codons) {} set CodeGenetique($AAA,Codons) {} set LesCodons {} foreach Codon [lrange $LesMots 2 end] { set Codon [string toupper $Codon] if { ! [regexp {^[ATGC][ATGC][ATGC]$} $Codon]} { continue } lappend AllCodons $Codon lappend LesCodons $Codon set CodeGenetique($Codon,A) $A set CodeGenetique($Codon,AAA) $AAA lappend CodeGenetique($A,Codons) $Codon lappend CodeGenetique($AAA,Codons) $Codon } if {$LesCodons=={}} { continue } lappend CodeGenetique(ListOf,A) $A lappend CodeGenetique(ListOf,AAA) $AAA set CodeGenetique($A,A) $A set CodeGenetique($AAA,A) $A set CodeGenetique($A,AAA) $AAA set CodeGenetique($AAA,AAA) $AAA } set CodeGenetique(ListOf,Codons) [lsort $AllCodons] #rR maintenant tout est charge. On rappelle recursivement la fonction return [CodeGenetique $Qui $Quoi] } proc TestonsExec {} { #rR voir dans [HomeRipp]/Werig/bugPgtclExec puts "First exec" puts [exec pwd] puts [package require Pgtcl] puts "Second exec" puts [exec pwd] return "return from TestonExec" # load /usr/local/ActiveTcl/lib/pgtcl2.0.0/libpgtcl2.0.0.so } proc CG {X} { set X [string toupper $X] foreach A {A T G C} { foreach B {A T G C} { foreach C {A T G C} { set Codon "$A$B$C" set AA [AAduCodon $Codon] lappend T($AA) $Codon lappend L "$Codon $AA" } } } if {[info exists T($X) ]} { return $T($X) } return $L } proc KillPython {} { set Qds [exec ps -ef | grep "python"] set LesQds [split $Qds "\n"] foreach Ligne $LesQds { Espionne $Ligne if { ! [regexp "python sv" $Ligne]} { continue } scan $Ligne "%s %d" moi Pid Espionne $Pid catch {exec kill -9 $Pid} } } proc KillQds {} { set Qds [exec ps -ef | grep "/cafedessciences/bin/qds"] set LesQds [split $Qds "\n"] foreach Ligne $LesQds { Espionne $Ligne if { ! [regexp "/usr/local/bin/tclsh .*/cafedessciences/bin/qds " $Ligne]} { continue } scan $Ligne "%s %d" moi Pid Espionne $Pid catch {exec kill -9 $Pid} } } proc CreateRandomTfa {{Fichier ""} {N ""}} { if {$Fichier==""} { set Fichier "/home/gioalt/arrayagilent_validation/SequenceList/014717_D_SequenceList_20080623.txt" } if {$N==""} { set N 5 } set LesTFAs {} foreach Ligne [ExtractRandomLinesFromFile $Fichier $N "" 3 "" "GetList"] { scan $Ligne "%s" Access set Seq [regsub "$Access " $Ligne ""] set Seq [regsub -all -nocase {[^ATGCN]} $Seq ""] set TFA [SequenceFormatTFA $Seq $Access "nucbrut"] lappend LesTFAs $TFA } return [join $LesTFAs "\n"] } proc ExtractRandomLinesFromFile {Fichier N {Seed ""} {Start ""} {Stop ""} {GetWhat ""}} { if {$GetWhat==""} { set GetWhat "GetText" } set LesLignes [LesLignesDuFichier $Fichier] if {$Stop!=""} { set LesLignes [lrange $LesLignes 0 $Stop] } if {$Start!=""} { set LesLignes [lrange $LesLignes $Start end] } set Size [llength $LesLignes] if {$Seed==""} { set Seed [expr round(1000 * rand())] expr srand($Seed) } set Selection {} while {1} { set I [expr round(rand()*$Size)] if {[info exists DejaVu($I)]} { continue } set DejaVu($I) 1 set Ligne [lindex $LesLignes $I] lappend Selection $Ligne if { ! [incr N -1] } { break } } if {$GetWhat=="GetText"} { return [join $Selection "\n"] } return $Selection } proc TestDecortiqueBlat {Fichier} { set LesHits [DecortiqueBlat $Fichier] foreach LeHit $LesHits { ScanLaListe $LeHit Query LongQuery BId Access Length Score Expect Identities Strand \ DebQuery FinQuery DebSbjct FinSbjct SeqQuery Barres SeqSbjct] Espionne "$Query $LongQuery $BId $Access $Length $Score $Expect $Identities $Strand" } } proc DecortiqueBlastCommeBlat TexteListeOuFichier { return [DecortiqueBlat $TexteListeOuFichier] } proc DecortiqueBlat TexteListeOuFichier { if {[regexp "\n" $TexteListeOuFichier]} { set LesLignes [split $TexteListeOuFichier "\n"] } elseif {[llength $TexteListeOuFichier]==1} { set LesLignes [LesLignesDuFichier $TexteListeOuFichier] } else { set LesLignes $TexteListeOuFichier } set LongQuery -1 set Query "QueryNotFoundInBlat" set StartBarrette -1 set LesHits {} set AHitNeedsToBeStored 0 set SeqQuery "" set Barres "" set SeqSbjct "" set DebQuery -1 set DebSbjct -1 set Strand "Plus/Plus" lappend LesLignes "EndOfFile" foreach Ligne $LesLignes { if {[regexp {^>} $Ligne] || [regexp { Score =} $Ligne] || [regexp "^EndOfFile$" $Ligne]} { if {$AHitNeedsToBeStored} { lappend LesHits [list $Query $LongQuery $BId $Access $Length $Score $Expect $Identities $Strand \ $DebQuery $FinQuery $DebSbjct $FinSbjct $SeqQuery $Barres $SeqSbjct] set SeqQuery "" set Barres "" set SeqSbjct "" set DebQuery -1 set DebSbjct -1 set AHitNeedsToBeStored 0 } } if {$StartBarrette>=0} { set Barrette [string range $Ligne $StartBarrette end] append Barres $Barrette set StartBarrette -1 continue } if {[regexp {^Query= } $Ligne]} { set Query [StringApres "Query=" dans $Ligne] continue } if {[regexp {\(([0-9]+) letters\)} $Ligne Match LongQuery]} { continue } if {[regexp {^>} $Ligne]} { set Access "" scan $Ligne "%s %s" BId Access regsub ">" $BId "" BId if {$Access==""} { set Access $BId } continue } if {[regexp { Score =} $Ligne]} { set Score [IntegerApres "Score =" dans $Ligne] set Expect [StringApres "Expect =" dans $Ligne] regsub {^[eE]} $Expect "1e" Expect continue } if {[regexp { Length =} $Ligne]} { set Length [IntegerApres "Length =" dans $Ligne] continue } if {[regexp { Identities =} $Ligne]} { set Identities [StringSuivant "Identities = " dans $Ligne] regsub { *\(.*} $Identities "" Identities continue } if {[regexp { Strand =} $Ligne]} { set Strand [StringSuivant "Strand =" dans $Ligne] regsub -all " " $Strand "" Strand continue } if {[regexp {^Query\: +([0-9]+) +} $Ligne Match DQ]} { if {$DebQuery==-1} { set DebQuery $DQ } set StartBarrette [string length $Match] regsub {^Query\: +([0-9]+) +} $Ligne "" SeqQ if {[regexp { +([0-9]+) *$} $SeqQ MQ FQ]} { regsub { +[0-9]+ *$} $SeqQ "" SeqQ set FinQuery $FQ } append SeqQuery $SeqQ continue } if {[regexp {^Sbjct\:? +([0-9]+) +} $Ligne Match DS]} { if {$DebSbjct==-1} { set DebSbjct $DS } regsub {^Sbjct\:? +([0-9]+) +} $Ligne "" SeqS if {[regexp { +([0-9]+) *$} $SeqS MS FS]} { regsub { +[0-9]+ *$} $SeqS "" SeqS set FinSbjct $FS } append SeqSbjct $SeqS set AHitNeedsToBeStored 1 continue } } return $LesHits } proc RemplaceAccessParPABPourTous {{Rep ""}} { while {$Rep==""} { set Rep [ChoixDuRepertoire "[RepertoireDuGenome]/"] if {$Rep!=""} { break } if {[OuiOuNon "Do I cancel ? "]} { return "" } } if { ! [regexp "/" $Rep]} { set Rep "[RepertoireDuGenome]/$Rep" } foreach Nom [ListeDesPABs] { set F "$Rep/$Nom" if {[FileAbsent $F]} { continue } set TFA [ContenuDuFichier $F] if { ! [regexp {^>} $TFA]} { continue } set B "" scan $TFA "%s %s" A B regsub ">" $A "" A if {$A==$Nom} { continue } if {$A==$B} { regsub ">$A " $TFA ">$Nom " NewTFA } else { regsub ">" $TFA ">$Nom " NewTFA } Espionne $F Sauve $NewTFA dans $F } } proc QueryDuBlast Fichier { set LeDebut [LesLignesIaJDuFichier $Fichier 1 10] set IndexQuery [lsearch -regexp $LeDebut "Query="] if {$IndexQuery==-1} { return "" } return [StringApres "Query=" dans [lindex $LeDebut $IndexQuery]] } proc BlastWithAllExpectsToZero {Fichier {Nouveau ""}} { if {$Nouveau==""} { set Nouveau "GetText" } set OnAttendPartieScore 1 set OnEstDansScore 0 set OnFinit 0 foreach Ligne [LesLignesDuFichier $Fichier] { if {$OnAttendPartieScore} { lappend LesBonnes $Ligne if {[regexp "Sequences producing" $Ligne]} { set OnAttendPartieScore 0 set OnEstDansScore 1 } continue } if {$OnEstDansScore} { if {[regexp ">" $Ligne]} { set OnEstDansScore 0 } else { if {[regexp { [\+\-\.0-9eE]+ *$} $Ligne]} { regsub { [\+\-\.0-9eE]+ *$} $Ligne " 0.0000" Ligne } } lappend LesBonnes $Ligne continue } if {[regexp -nocase {Expect = .+} $Ligne]} { regsub -nocase {Expect = .+} $Ligne "Expect = 0.0000" Ligne } lappend LesBonnes $Ligne } if {$Nouveau=="GetLines"} { return $LesBonnes } if {$Nouveau=="GetText"} { return [join $LesBonnes "\n"] } return [SauveLesLignes $LesBonnes dans $Nouveau] } proc VraiGNDeLaLigneGN Ligne { regsub "^GN *" $Ligne "" GN regsub {\;$} $GN "" GN if { ! [regexp -nocase "Name=" $GN NameEgal]} { return $GN } regsub -all "\;" $GN " " GN set Vrai [StringApres $NameEgal dans $GN] if {$Vrai==""} { return $GN } return $Vrai } proc VraiDEDeLaLigneDE Ligne { regsub "^DE *" $Ligne "" DE if { ! [regexp -nocase "RecName:" $DE]} { return $DE } Espionne $DE set Full ""; regexp {Full=([^\;]+)\;} $DE Match Full set Short ""; regexp {Short=([^\;]+)\;} $DE Match Short set EC ""; regexp {EC=([^\;]+)\;} $DE Match EC Espionne $EC set Vrai "$Full $Short EC=$EC" if {$Full=="" && $Short==""} { return $DE } return $Vrai } proc RenommeExtension {Avant Apres {Rep ""} {Ask ""}} { if {$Ask==""} { set Ask "Ask" } if {$Ask=="DontAsk"} { set Ask 0 } else { set Ask 1 } if {$Rep==""} { set Rep "." } set LesAvants [lsort [glob -nocomplain "$Rep/*$Avant"]] set n [llength $LesAvants] if {$n==0} { FaireLire "I found no file coresponding to $Rep/*$Avant" return "" } if { ! [OuiOuNon "Do I rename the $n files corresponding to \n$Rep/*$Avant"]} { return "" } set Ask 1 set LesAP {} foreach FicAv $LesAvants { set i [string last $Avant $FicAv] if {$i==-1} { continue } set FicAp [string replace $FicAv $i end $Apres] if {$Ask && [OuiOuNon "Do You want to verify what I'm doing ?"]} { if { ! [OuiOuNon "file rename -force \n$FicAv \n$FicAp\n\nOk ?"]} { return "" } set Ask [OuiOuNon "Do I continue asking for verification ?"] } else { set Ask 0 } file rename -force $FicAv $FicAp lappend LesAp $FicAp } return $LesAp } proc MetExtreme {Seq Depart } { Wup "numerotation commence a 0" regsub -all " " $Seq "" Seq set DernierBon $Depart foreach I [NombresEntre $Depart 1 -3] { set Codon [string range $Seq $I [expr $I+2]] # if {[CodonStartPossible $Codon]} { set DernierBon $I } if {[string equal -nocase $Codon "ATG"]} { set DernierBon $I } if {[CodonStopPossible $Codon]} { break } } return $DernierBon } proc StopProchain {Seq {Depart ""}} { Wup "numerotation commence a 0" if {$Depart==""} { set Depart 0 } regsub -all " " $Seq "" Seq set FinSeq [string length $Seq] set PremierBon -1 foreach I [NombresEntre $Depart $FinSeq 3] { set Codon [string range $Seq $I [expr $I+2]] if {[CodonStopPossible $Codon]} { set PremierBon $I ; break } } return $PremierBon } proc StopAvant {Seq {Depart ""}} { Wup "numerotation commence a 0" regsub -all " " $Seq "" Seq set FinSeq [string length $Seq] if {$Depart==""} { set Depart $FinSeq-1 } set PremierBon -1 foreach I [NombresEntre [expr $Depart-3] 0 -3] { set Codon [string range $Seq $I [expr $I+2]] if {[CodonStopPossible $Codon]} { set PremierBon $I ; break } } return $PremierBon } proc NucExtension5Prime {NucTotal Nuc3Prime} { if {$Nuc3Prime==""} { return "" } set NucTotal [string toupper $NucTotal] set Depart [string last [string toupper $Nuc3Prime] [string toupper $NucTotal]] if {$Depart<0} { return "" } set Debut [MetExtreme $NucTotal $Depart] set Fin [StopProchain $NucTotal $Depart] incr Fin -1 if {$Fin<0} { set Fin "end" } return [string range $NucTotal $Debut $Fin] } proc ProtDansNuc {TFA Pro} { set Seq [QueLaSequenceDuTexteTFA $TFA] set Sortie {} foreach Frame [list 0 1 2] { set BonSeq [string range $Seq $Frame end] set SeqPro [SeqNucToSeqPro $BonSeq] if {[regexp -indices -nocase $Pro $SeqPro Indices]} { lappend Sortie $Indices } } return $Sortie } proc VersPoubelle Nom { set Poubelle "[RepertoireDuGenome]/poubelle" if { ! [file exists $Poubelle]} { file mkdir $Poubelle } set LesFiPou {} foreach Fichier [glob -nocomplain "[RepertoireDuGenome]/*/$Nom"] { if { ! [file exists $Fichier]} { continue } set Rep [file tail [file dirname $Fichier]] if {[file type $Rep]=="link"} { continue } set Pou "${Rep}_$Nom" set FiPou "$Poubelle/$Pou" if {[file exists $FiPou]} { Garde $FiPou } file rename -force $Fichier $FiPou lappend LesFiPou $FiPou } foreach Fichier [glob -nocomplain "[RepertoireDuGenome]/*/$Nom"] { if { ! [file exists $Fichier]} { continue } set Rep [file tail [file dirname $Fichier]] if { ! [OuiOuNon "$Fichier\nis in a directory which is a link.\nDo I move to poubelle anyway ?"]} { continue } set Pou "${Rep}_$Nom" set FiPou "$Poubelle/$Pou" if {[file exists $FiPou]} { Garde $FiPou } file rename -force $Fichier $FiPou lappend LesFiPou $FiPou } return $LesFiPou } proc SeqToTfaPourTous {} { foreach S [glob *.seq] { regsub ".seq$" $S ".tfa" T Espionne [SeqToTfa $S "seqtotfa/$T"] } exit } proc SeqToTfa {FichierSeq {FichierTFA ""}} { if {$FichierTFA==""} { regsub ".seq$" $FichierSeq "" FichierTFA append FichierTFA ".tfa" } set EuNA 0 set EuTitre 0 set EuPP 0 set Titre "" set Seq "" foreach Ligne [LesLignesDuFichier $FichierSeq] { if { ! $EuNA && ! [regexp "!!NA_SEQUENCE" $Ligne]} { return "" } if { ! $EuNA} { set EuNA 1 ; continue } if { ! $EuTitre} { if { ! [regexp -nocase {[a-z0-9]+} $Ligne]} { set EuTitre 1 continue } append Titre $Ligne continue } if { ! $EuPP } { if { [regexp {\.\. *} $Ligne]} { set EuPP 1 } continue } regsub -all -nocase {[^a-z]} $Ligne "" BoutSeq append Seq $BoutSeq } set TFA [SequenceFormatTFA $Seq ">$Titre" "nucbrut"] return [Sauve $TFA dans $FichierTFA] } proc NormaliseTxlFieldName Field { regsub -all -nocase {[^a-z0-9\-_\.]} $Field "_" Good return $Good } proc TestRowsOfCells {} { set Texte [ContenuDuFichier "[HomeRipp]/GenoretWww/AmdConsortium/FamLevel2OK.csv"] EspionneL [RowsOfCells $Texte] exit } proc RowsOfCells {Texte {Separateur ""} {NewSep ""} {NewQQ ""} {NewRet ""}} { #rR attention j'ai rajoute le dernier caractere a Cell le 2009/01/22 if {$Separateur==""} { set Separateur ";" } if {$NewSep==""} { set NewSep "," } if {$NewQQ ==""} { set NewQQ "\"" } if {$NewRet==""} { set NewRet " " } if {$NewSep=="Keep"} { set NewSep $Separateur } set E 0 set Q "\"" set Ret "\n" set C "" set QQ 0 set InQ 0 set LesCell {} set LesRows {} set Cell "" foreach Suivant [split [string trim $Texte " \n\t\f\r\v"] ""] { if {$C==""} { set C $Suivant ; continue } if {$E} { Espionne $C } if {$C==$Q} { if {$QQ} { set QQ 0 append Cell $NewQQ if {$E} { Espionne "$C =$Cell= QQ 0" } set C $Suivant; continue } if {$InQ} { if {$Suivant==$Q} { set QQ 1 if {$E} { Espionne "$C =$Cell= InQ QQ 1" } set C $Suivant; continue } append Cell $Q set InQ 0 if {$E} { Espionne "$C =$Cell= InQ 0" } set C $Suivant ; continue } set InQ 1 append Cell $Q if {$E} { Espionne "$C =$Cell= InQ 1" } set C $Suivant; continue } if {$C==$Separateur} { if {$InQ} { append Cell $NewSep if {$E} { Espionne "$C =$Cell= S InQ" } set C $Suivant; continue } lappend LesCell $Cell set Cell "" if {$E} { Espionne "$C =$Cell= S OutQ" } set C $Suivant; continue } if {$C==$Ret} { if {$InQ} { append Cell $NewRet if {$E} { Espionne "$C =$Cell= R InQ" } set C $Suivant; continue } lappend LesCell $Cell set Cell "" lappend LesRows $LesCell if {$E} { Espionne [join $LesCell "/"] } set LesCell {} if {$E} { Espionne "$C =$Cell= R OutQ" } set C $Suivant; continue } append Cell $C if {$E} { Espionne "$C =$Cell=" } set C $Suivant; continue } #rR rajoute le 2009/01/22 if {$C!=$Ret && $C!=$Separateur && $C!=$Q} { append Cell $C } #rR rajoute le 2009/01/22 lappend LesCell $Cell lappend LesRows $LesCell return $LesRows } proc LoadTxlWithRowsOfCells {Fichier {aTxl ""} {MainIndex 0} {Sep ""} {CoLi ""} {WholeLine ""}} { set WholeLine [string equal -nocase "WholeLine" $WholeLine] if {$CoLi==""} { set CoLi "LiCo" } Wup "Normally the values are stored in Txl(Line,Column)" Wup " with CoLi==CoLi we have Txl(Column,Line)" if {$aTxl!=""} { upvar $aTxl Txl } else { global Txl ; set aTxl Txl } if {$Sep==""} { set Sep "\t" } set Queue [file tail $Fichier] regsub -nocase {\.[^\.]+$} $Queue "" Queue global LoadTxlForGenoret if {[info exists LoadTxlForGenoret] && $LoadTxlForGenoret} {set Queue [NormaliseTxlFieldName $Queue] } set Txl(Queue) $Queue if { ! [file exists $Fichier]} { set Txl(ListHeaderPlease,$Queue) {} set Txl(ListAllPlease,$Queue) {} return $aTxl } set Texte [ContenuDuFichier $Fichier] set NewSep "" set NewQQ "" set NewRet "" set LesRowsOfCells [RowsOfCells $Texte $Sep $NewSep $NewQQ $NewRet] set LesHLus [lindex $LesRowsOfCells 0] set LesRowsOfCells [lrange $LesRowsOfCells 1 end] set LesTetes {} foreach Tete $LesHLus { regsub -all {\'} $Tete "" Tete regsub -all {\?} $Tete "" Tete regsub -all {\(} $Tete "" Tete regsub -all {\)} $Tete "" Tete regsub -all {\"} $Tete "" Tete regsub -all {\,} $Tete "_" Tete while {[regexp " " $Tete]} { regsub -all { {2,}} $Tete " " Tete } set Tete [string trim $Tete] regsub -all { } $Tete "_" Tete #rR ca devrait enlever le degre regsub -all -nocase {\0260} $Tete "_" Tete set Original $Tete if {$Tete==""} { set Tete "_" } while {[info exists DejaVu($Tete)]} { append Tete "_2" } set DejaVu($Tete) $Original lappend LesTetes $Tete } set Txl(ListHeaderPlease,$Queue) $LesTetes set I 1 foreach LesMots $LesRowsOfCells { incr I if {$MainIndex<0} { set Nom $I } else { set Nom [lindex $LesMots $MainIndex] regsub -all {\"} $Nom "" Nom } set Nom [string trim $Nom] if {$Nom==""} { continue } if {[info exists DejaVu($Nom,$Queue)]} { FaireLire "I already saw $Nom , I'll skip it now" ; continue } set DejaVu($Nom,$Queue) 1 lappend Txl(ListAllPlease,$Queue) $Nom foreach Mot $LesMots Tete $LesTetes { regsub -all {\"} $Mot "" Mot if {$CoLi=="CoLi"} { set Txl($Tete,$Nom) $Mot } else { set Txl($Nom,$Tete) $Mot } } if {$WholeLine} { if {$CoLi=="CoLi"} { set Txl(WholeLine,$Nom) $LesMots } else { set Txl($Nom,WholeLine) $LesMots } } } set Txl(ListHeaderPlease,) $Txl(ListHeaderPlease,$Queue) set Txl(ListAllPlease,) $Txl(ListAllPlease,$Queue) return $aTxl } proc LoadTxl {Fichier {aTxl ""} {MainIndex 0} {Sep ""} {CoLi ""} {WholeLine ""}} { set WholeLine [string equal -nocase "WholeLine" $WholeLine] if {$CoLi==""} { set CoLi "LiCo" } Wup "Normally the values are stored in Txl(Line,Column)" Wup " with CoLi==CoLi we have Txl(Column,Line)" if {$aTxl!=""} { upvar $aTxl Txl } else { global Txl ; set aTxl Txl } if {$Sep==""} { set Sep "\t" } set Queue [file tail $Fichier] regsub -nocase {\.[^\.]+$} $Queue "" Queue global LoadTxlForGenoret if {[info exists LoadTxlForGenoret] && $LoadTxlForGenoret} {set Queue [NormaliseTxlFieldName $Queue] } if { ! [file exists $Fichier]} { Warne "$Fichier does not exist" set Txl(ListHeaderPlease,$Queue) {} set Txl(ListAllPlease,$Queue) {} return $aTxl } set LesLignes [LesLignesDuFichier $Fichier] set Entete [lindex $LesLignes 0] set LesLignes [lrange $LesLignes 1 end] set LesTetes {} foreach Tete [split $Entete $Sep] { regsub -all {\#} $Tete "" Tete regsub -all {\'} $Tete "" Tete regsub -all {\?} $Tete "" Tete regsub -all {\(} $Tete "" Tete regsub -all {\)} $Tete "" Tete regsub -all {\"} $Tete "" Tete while {[regexp " " $Tete]} { regsub -all { {2,}} $Tete " " Tete } set Tete [string trim $Tete] regsub -all { } $Tete "_" Tete # regsub -all -nocase {[\0260\$]} $Tete "_" Tete regsub -all -nocase {[\176\$]} $Tete "_" Tete set Original $Tete if {$Tete==""} { set Tete "_" } while {[info exists DejaVu($Tete)]} { append Tete "_2" } set DejaVu($Tete) $Original lappend LesTetes $Tete } set Txl(ListHeaderPlease,$Queue) $LesTetes set Txl(ListOf,Header) $LesTetes set I 1 foreach Ligne $LesLignes { if { ! [regexp -nocase {\S} $Ligne]} { continue } incr I set LesMots [split $Ligne $Sep] if {$MainIndex<0} { set Nom $I } else { set Nom [lindex $LesMots $MainIndex] regsub -all {\"} $Nom "" Nom } lappend Txl(ListAllPlease,$Queue) $Nom lappend Txl(ListOf,Index) $Nom foreach Mot $LesMots Tete $LesTetes { regsub -all {\"} $Mot "" Mot if {$CoLi=="CoLi"} { set Txl($Tete,$Nom) $Mot } else { set Txl($Nom,$Tete) $Mot } } if {$WholeLine} { if {$CoLi=="CoLi"} { set Txl(WholeLine,$Nom) $Ligne } else { set Txl($Nom,WholeLine) $Ligne } } } return $aTxl } proc DeleteJunkdir {{Qui ""}} { NousAllonsAuBoulot if {[OuiOuNon "Do I delete all files '$Qui*' in [pwd] ?"]} { if {[OuiOuNon "Sure that I delete all files '$Qui*'in [pwd] ?"]} { set Ask 1 foreach Fichier [glob "$Qui*"] { if {[file isdirectory $Fichier]} { continue } File delete $Fichier } } } OnRevientDuBoulot return } proc CorrigeValiGNSiPresenceName {} { set LesCorriges {} foreach Nom [ListeDesPABs] { set ValiGN [ValiGN $Nom] if { ! [regexp {^Name=([^;]+);} $ValiGN Match GN]} { continue } lappend LesCorriges "$Nom $GN $ValiGN" InformeSansDemander $Nom "=ValiGN: $GN" } return $LesCorriges } proc CorrigeLesOrganismesDansDisphy {} { global RepertoireDuGenome foreach Fichier [glob "$RepertoireDuGenome/disphy/[PreFixe]*"] { set Nom [file tail $Fichier] LeDescriptif PourQuIlSoitCharge $Nom set LesLignes [LesLignesDuFichier $Fichier] if { ! [regexp "ukno|uukn|xxxx|iinc" [join $LesLignes "\n"]]} { continue } set Nouveau {} foreach Ligne $LesLignes { scan $Ligne "%s %d %s" Orga Dist Access # set UnPrecis [regexp {^PAE[0-9]+} $Access] if {[regexp "ukno|uukn|xxxx|iinc" $Orga]} { set OldOrga $Orga set MeilleurOrga [OrgaDuAccess $Access Court] if {$MeilleurOrga!=""} { set Orga $MeilleurOrga } Espionne "$Nom $Access $OldOrga $Orga" } foreach O [SplitOrgas $Orga] { lappend Nouveau "$O $Dist $Access" } } Espionne [SauveLesLignes $Nouveau dans $Fichier] } CreeDistancesPhyloAvecLesMSFs } proc CreeToutesLesSynthetases {{QueLaListe ""}} { global RepertoireDuGenome global ListeDesPABs if {$QueLaListe==""} { set QueLaListe 0 } else { set QueLaListe 1 } if { ! [info exists ListeDesPABs]} { ChargeLesPABs } if { ! [file exists "$RepertoireDuGenome/coembl"]} { File mkdir "$RepertoireDuGenome/coembl" } foreach Nom $ListeDesPABs { set FichierMSF "$RepertoireDuGenome/clustalw/$Nom" set AA3 [string range [NomDeGene $Nom] 0 2] if {$QueLaListe} { lappend LesNomsAAs "$Nom $AA3" continue } set Destination "$RepertoireDuGenome/coembl/$Nom" if { ! [file exists $Destination]} { File mkdir $Destination } CreeLesSynthetases $FichierMSF $Destination $AA3 } if {$QueLaListe} { Espionne [SauveLesLignes $LesNomsAAs dans "$RepertoireDuGenome/fiches/lookup"] } } proc Lance {Aligneur Selection} { global LaFenetreDesMSF set Num [NomDe ""] switch -regexp $Aligneur { "All" { foreach a [Aligneurs] { if {[Aligneurs $a]} { set MSF [AlignePar $a $Selection "Batch" $Num] lappend ListeDesMSF $MSF } } set Fenetre [AfficheVariable [join $ListeDesMSF "\n"] \ "AvecShowAvecEtudeMSF" "Wait all be Highlighted ...\nThen reselect and press a function. "] BoutonneLaFenetre $Fenetre "Log" "AfficheLogDesMSF \[selection get\]" foreach Fichier $ListeDesMSF { set LaFenetreDesMSF($Fichier) $Fenetre } } "clustalw|dialign|pileup|prrp" { AlignePar $Aligneur $Selection "Batch" $Num } default { } } } proc AlignePar {Aligneur Selection Mode {NomOuNum ""} } { global Commandes if { $NomOuNum == ""} { set NomNum [pid].[NomDe ""] } if { [regexp {^[a-zA-Z]} $NomOuNum ] } { set NomNum ${NomOuNum}[NomDe ""] } if { [regexp {^[0-9]} $NomOuNum ] } { set NomNum $NomOuNum } if { [regexp {^\.[0-9]} $NomOuNum ] } { set NomNum $NomOuNum } set Tmp tmp.$NomNum if { $Mode == "Batch" } { set In $Tmp.$Aligneur.inp set Out $Tmp.$Aligneur.out set Log $Tmp.$Aligneur.log set FOF [FichierFOF $Selection $Tmp] SauveLesLignes [FOFtoTFAs $FOF] dans $In catch {set Canal [open "| [set Commandes($Aligneur)] $In $Out $Log"]} Message fconfigure $Canal -blocking false -buffering line fileevent $Canal readable "ClosCanalEtMontreMSF $Aligneur $Canal $Out.msf $Log" Warne "$Aligneur est lance en batch" return "$Out.msf" } if { $Mode == "Interactif" } { set In $Tmp.inp Sauve [ConcatLesTFAs $Selection] dans $In set LesFichiersCrees [list "$In"] foreach Ali [split $Aligneur "+"] { set Out $Tmp.$Ali.out set Log $Tmp.$Ali.log Warne "$Ali lance en interactif ... un peu de patience. Merci." eval exec "[set Commandes($Aligneur)] $In $Out $Log" Warne " ... j'ai fini." File delete -force $Out File delete -force $Log lappend LesFichiersCrees "$Out.msf" } if {[regexp "+" $Aligneur]} { return $LesFichierCrees } else { return "$Out.msf" } } } proc CocheAligneurs {} { global Aligneurs retourCoche AligneursCochons Gs "Rien" set w [NomDe coche] catch {destroy $w} toplevel $w wm title $w "Merci de cocher ..." wm iconname $w "Coche" frame $w.buttons pack $w.buttons -side bottom -fill x -pady 2m button $w.buttons.dismiss -text "Dismiss" -background red -foreground white \ -command "set retourCoche($w) Dismiss" pack $w.buttons.dismiss -side left -expand 1 button $w.buttons.defaut -text "Default" -background yellow -foreground black \ -command "set retourCoche($w) Defaut" pack $w.buttons.defaut -side left -expand 1 button $w.buttons.accept -text "Accept" -background green -foreground black \ -command "set retourCoche($w) Accept" pack $w.buttons.accept -side left -expand 1 set i 0 foreach a [Aligneurs] { set AligneursCochons($a) [Aligneurs $a] set b $w.b$a checkbutton $b -text "$a" -variable AligneursCochons($a) -relief flat pack $b -side top -pady 2 -anchor w } tkwait variable retourCoche($w) if { [set retourCoche($w)] == "Defaut" } { foreach a [Aligneurs] { set AligneursCochons($a) [Aligneurs $a "Defaut"] } while { [set retourCoche($w)] == "Defaut" } { unset retourCoche($w) tkwait variable retourCoche($w) } } if { [set retourCoche($w)] != "Dismiss" } { foreach a [Aligneurs] { set Aligneurs($a) [set AligneursCochons($a)] } } unset retourCoche($w) catch { unset $AligneursCoches } foreach a [Aligneurs] { if {[Aligneurs $a]} { set AligneursCoches($a) 1 } } destroy $w } proc Aligneurs {{LeQuel ""} {Defaut ""}} { Wup "Returns array Aligneurs, AligneursCoches or Aligneur($LeQuel)" global Aligneurs AligneursCoches AligneursDefaut if { ! [info exists Aligneurs]} { set Aligneurs(clustalw) 1 set Aligneurs(dialign) 0 set Aligneurs(pileup) 0 set Aligneurs(prrp) 0 foreach {a ValAligneurs} [array get Aligneurs] { set AligneursDefaut($a) $ValAligneurs if {$ValAligneurs} { set AligneursCoches($a) $ValAligneurs } } } if {$LeQuel==""} { return [array names Aligneurs] } if {$LeQuel=="Coches"} { return [array names AligneursCoches] } if { $Defaut == "" } { if {[info exists Aligneurs($LeQuel)]} { return [set Aligneurs($LeQuel)] } else { return 0 } } else { if {[info exists AligneursDefaut($LeQuel)]} { return [set AligneursDefaut($LeQuel)] } else { return 0 } } } proc DuGrec Fichier { foreach C [split [ContenuDuFichier $Fichier] ""] { if {$C > "z" || $C == "?"} { Espionne "Grec >$C< [string range $Nouveau end-10 end]" if { ! [info exists Remplace($C)]} { set Remplace($C) [Entre] } set C [set Remplace($C)] } lappend Nouveau $C } Espionne [Sauve [join $Nouveau ""] dans $Fichier.nouveau] exit } proc YaPABouTROUouTRNAouARNenDebutDe Texte { if {[YaPABenDebutDe $Texte]} { return 1 } if {[regexp {^TROU|^TRNA|^ARN} $Texte]} { return 1 } return 0 } proc EstPABouTROUouTRNAouARN Texte { if {[EstUnPAB $Texte]} { return 1 } #if {[regexp -nocase {^(TROU|TRNA|ARN)[0-9]+[nN]?} $Texte]} { return 1 } if {[regexp -nocase {^(TROU|TRNA|ARN|rRNA|ncRNA)} $Texte]} { return 1 } return 0 } proc YaPABouTROUouTRNAouARNdans Texte { if {[YaPABdans $Texte]} { return 1 } if {[regexp -nocase {TROU|TRNA|ARN} $Texte]} { return 1 } return 0 } proc YaPABenDebutDe Texte { if {[regexp "^[PreFixe]" $Texte]} { return 1 } return 0 } proc YaPABdans Texte { if {[OnTraite "REFUNI" "NonStrict"] && [regexp {^(AGAM|SCER|XTRO)[0-9\.]+} $Texte]} { return 1 } if {[regexp "[PreFixe]" $Texte]} { return 1 } return 0 } proc EstUnPAB Texte { if {[OnTraite "REFUNI" "NonStrict"] && [regexp {^(AGAM|SCER|XTRO)[0-9\.]+} $Texte]} { return 1 } return [regexp "^[ExpressionReguliereDesPABs]$" $Texte] } proc ExpressionReguliereDesPABs {} { global ConfigChargee if { ! [info exists ConfigChargee] || ! $ConfigChargee } { return "EXPRESSION_REGULIERE_DES_PABS_NON_VALIDE" } return "^[PreFixe]\[0-9\\.\]+" } proc PreFixe {{Nouveau ""}} { global PrefixeDesORFs if {$Nouveau!=""} { set PrefixeDesORFs $Nouveau } if { ! [info exists PrefixeDesORFs]} { set PrefixeDesORFs "ORF" } return $PrefixeDesORFs } proc NumeroDu Nom { if {[regexp {[^0-9]([0-9]+)$} $Nom Match Numero]} { return $Numero } return "" } proc MoyenneDesPourcentages {} { global RepertoireDuGenome foreach Ligne [LesLignesDuFichier "$RepertoireDuGenome/fiches/pourcentageidentite-orga"] { scan $Ligne "%s %s %d" Nom Orga PI if { [info exists Cumul($Orga)] } { incr Cumul($Orga) $PI incr Nombre($Orga) } else { set Cumul($Orga) 0 set Nombre($Orga) 0 } } foreach {Orga ValCumul} [array get Cumul] { lappend Liste "$Orga [expr $ValCumul/[set Nombre($Orga)]]" } set ListeTriee [lsort -decreasing -command CompareLesIntegers $Liste] foreach Texte $ListeTriee { puts "Moyenne des pourcentages d'identite pour $Texte" } } proc ListonsLesTrous {LongMotif Offset} { global RepertoireDuGenome global ListeDesTROUs if { ! [info exists ListeDesTROUs]} { ChargeLesTROUs } foreach Boite $ListeDesTROUs { set Nom [Box $Boite nom] set Debut [Box $Boite debut] set Fin [Box $Boite fin] set Orient [Box $Boite orient] set Long [expr $Fin-$Debut+1] if {[info exists Histo($Long)]} { incr Histo($Long) } else { set Histo($Long) 1 } set DF [Maxi $Debut [expr $Fin-$Offset-$LongMotif]] set FF [Mini $Fin [expr $Fin-$Offset+$LongMotif]] set SeqF [BoutADN $DF $FF "F"] set DR [Maxi $Debut [expr $Debut+$Offset-$LongMotif]] set FR [Mini $Fin [expr $Debut+$Offset+$LongMotif]] set SeqR [BoutADN $DR $FR "R"] set Entamme "f${SeqF}r${SeqR}" set Termine "f${SeqF}r${SeqR}" append Entammes $Entamme append Termines $Termine # lappend LesTrousDeLongueur($Long) "[BoutADN $Debut $Fin "F"] f $Nom" # lappend LesTrousDeLongueur($Long) "[BoutADN $Debut $Fin "R"] r $Nom" } regsub -all "A|T" $Entammes "-" Entammes regsub -all "C|G" $Entammes "O" Entammes regsub -all "A|T" $Termines "-" Termines regsub -all "C|G" $Termines "O" Termines for {set i 0} {$i<[string length $Entammes]-$LongMotif} {incr i} { set MotifE [string range $Entammes $i [expr $i+$LongMotif-1]] set MotifT [string range $Termines $i [expr $i+$LongMotif-1]] if { ! [regexp "f|r" $MotifE]} { if {[info exists HistoE($MotifE)]} { incr HistoE($MotifE) } else { set HistoE($MotifE) 1 } } if { ! [regexp "f|r" $MotifT]} { if {[info exists HistoT($MotifT)]} { incr HistoT($MotifT) } else { set HistoT($MotifT) 1 } } } foreach MotifE [array names HistoE] { lappend HME "[set HistoE($MotifE)] $MotifE" } foreach MotifT [array names HistoT] { lappend HMT "[set HistoT($MotifT)] $MotifT" } set E [lsort -command CompareLesIntegersEnDebut $HME] set T [lsort -command CompareLesIntegersEnDebut $HMT] foreach t $T { puts "$t" } return set Sortie {} foreach Long [lsort -decreasing -integer [array names Histo]] { puts "$Long [set Histo($Long)]" if {$D<=$Long && $Long<=$F} { set Sortie [concat $Sortie [set LesTrousDeLongueur($Long)]] } } puts [join [lsort $Sortie] "\n"] } proc HistogrammeDuTas {Fichier {LesTabs ""}} { if {$LesTabs==""} { set LesTabs {10 20 30 40 50 60 70 80 90 100} } set LesSCs {} foreach Ligne [lrange [LesLignesDuFichier $Fichier] 2 end] { if { ! [YaPABdans $Ligne]} { continue } scan $Ligne "%s %d %s %d" Nom FF SC PI if {$Fichier == "rr-phor.tas" || $Fichier == "rr-pfur.tas" } { set SC XX } if {[lsearch $LesSCs $SC] < 0 } { lappend LesSCs $SC } set OldTab -1 foreach Tab $LesTabs { if {$OldTab < $PI && $PI <= $Tab} { if {[info exists Histo($SC,$Tab)]} { incr Histo($SC,$Tab) } else { set Histo($SC,$Tab) 1 } break } set OldTab $Tab } } foreach SC $LesSCs { foreach Tab $LesTabs { if {[info exists Histo($SC,$Tab)]} { puts "$SC $Tab [set Histo($SC,$Tab)]" } else { puts "$SC $Tab 0" } } } } proc MontreTousCeuxQuiSont {CommeCa {Orga ""}} { global ListeDeBoites if { ! [info exists ListeDeBoites]} { ChargeListeDeBoites } Wup "OrgaPi n'existe plus ... le reecrire si necessaire." foreach Boite $ListeDeBoites { set Nom [Box $Boite nom] if { ! [regexp $CommeCa [Cas $Nom]]} { continue } # MontreNomSuperClassePI $Nom $Orga puts "$Nom [Cas $Nom] [FiabiliteFonction $Nom] [ClasseFonctionnelle $Nom] [NomDeGene $Nom] [Definition $Nom]" puts " [join [lrange [PhylonOrgaEtDistance $Nom] 0 16] " "]" puts " [join [lrange [OrgaPi $Nom] 0 16] " "]" } } proc MontreNomSuperClassePI {Nom Orga} { puts "$Nom [FiabiliteFonction $Nom] [SuperClasse [ClasseFonctionnelle $Nom]] [PourcentageIdentiteOrga $Nom $Orga]" } proc NomCompletDeLaSuperClasse SP { if {[regexp "Hy" $SP] } { return "Hypothtical protein" } if {[regexp "NC" $SP] } { return "Not Classified" } if {[regexp "CP" $SP] } { return "Cellular Processing" } if {[regexp "Tl" $SP] } { return "TransLation" } if {[regexp "RT" $SP] } { return "Replication and Transcription" } if {[regexp "CE" $SP] } { return "Cellular Envelope" } if {[regexp "Me" $SP] } { return "Metabolisme" } if {[regexp "tR" $SP] } { return "tRNAs tranfert RiboNucleic Acids" } if {[regexp "RR" $SP] } { return "rRNAs Ribosomal RiboNucleic Acids" } if {[regexp "IG" $SP] } { return "InterGenic region" } FaireLire "SuperClasse $SP inconnue ... I call it 'Unknown SuperClass" return "Unknown SuperClass" } proc SuperClasse Classe { if {[regexp {^00} $Classe]} { return "Hy" } if {[regexp {000} $Classe]} { return "Hy" } if {[regexp {161} $Classe]} { return "Hy" } if {[regexp {153} $Classe]} { return "NC" } if {[regexp {^14|^08|121|151} $Classe]} { return "CP" } if {[regexp {^11} $Classe]} { return "Tl" } if {[regexp {^09|^10} $Classe]} { return "RT" } if {[regexp {^13|^03} $Classe]} { return "CE" } if {[regexp {^01|^02|^04|^05|^06|^07} $Classe]} { return "Me" } if {[regexp {191} $Classe]} { return "tR" } if {[regexp {192} $Classe]} { return "RR" } if {[regexp {200} $Classe]} { return "IG" } FaireLire "Class $Classe unknown ... I call it 'UK'" return "UK" } proc CreePourcentageIdentite {{Banque "genomes"}} { global RepertoireDuGenome global ListeDeBoites if { ! [info exists ListeDeBoites]} { ChargeListeDeBoites } foreach Boite $ListeDeBoites { set Nom [Box $Boite nom] set Fichier "$RepertoireDuGenome/tblastn$Banque/$Nom" puts "$Nom $Fichier" if { ! [file exists $Fichier]} { continue } Wup "Commentariser ci-dessus (pour les paralogues par ex.) ou les 2 ci-dessous ou l'un" lappend Liste "$Nom [join [OuATapeTBlastN $Fichier $Banque ListeDesOrganismes] " "]" Wup "Je rappelle que je triche en cachant le pourcentage dans score" lappend Liste "$Nom [join [OuATapeTBlastN $Fichier $Banque ListeDesScores] " "]" } SauveLesLignes $Liste dans "$RepertoireDuGenome/fiches/pourcentageidentite.$Banque.arenommer" } proc ToggleCanva {K Tag} { global Action global CouleurDuFond if { ! [info exists Action]} { set Action "raise" } if { $Action == "raise" } { set Action "lower" set Couleur $CouleurDuFond } else { set Action "raise" set Couleur "black" } $K itemconfigure $Tag -fill $Couleur $K $Action $Tag } proc Cas Nom { global RepertoireDuGenome global LesCas if { ! [info exists LesCas]} { if {[file exists "$RepertoireDuGenome/fiches/lescas"]} { foreach Ligne [LesLignesDuFichier "$RepertoireDuGenome/fiches/lescas"] { scan $Ligne "%s %s" PAB Cas set LesCas($PAB) $Cas } } else { set LesCas Bidon } } if {[info exists LesCas($Nom)]} { return [set LesCas($Nom)] } else { return "CasNonConnu" } } proc ElimineLesEnterres {} { global RepertoireDuGenome ChargeLesPABs foreach Ligne [LesLignesDuFichier "$RepertoireDuGenome/fiches/bornesdespabs"] { scan $Ligne "%s" Nom if {[Enterre $Nom]} { lappend ListeDesEnterres $Ligne } else { lappend ListeDesBornesDesPABs $Ligne } } set ListeDesEnterres [lsort $ListeDesEnterres] set ListeDesBornesPABs [lsort -command CompareLesMilieux $ListeDesBornesDesPABs] Espionne [SauveLesLignes $ListeDesEnterres dans "$RepertoireDuGenome/fiches/bornesdesenterres.arenommer"] Espionne [SauveLesLignes $ListeDesBornesDesPABs dans "$RepertoireDuGenome/fiches/bornesdespabs.arenommer"] } proc Note Nom { global RepertoireDuGenome set FichierNote "$RepertoireDuGenome/notes/$Nom" if {[file exists $FichierNote]} { return [ContenuDuFichier $FichierNote] } return "" } proc CreeToutesLesNotesPourCollection {} { global RepertoireDuGenome set RepNotes "$RepertoireDuGenome/notes" if { ! [file exists $RepNotes]} { File mkdir $RepNotes } foreach Boite [ListeDeBoites] { set Note {} set Nom [Box $Boite nom] set Access [Narcisse $Nom] if {$Access==""} { set TexteAccess "This ORF couldn't yet be found in database." } else { set TexteAccess "$Access is its database accession number." } lappend Note "$Nom [NomDeGene $Nom]" lappend Note "[DefinitionApproximative $Nom]" set MD [MDScore $Nom] if {$MD > -9999.0} { lappend Note "MD score of multialignment $MD" } if {[set TexteNote [ExtraitInfo $Nom "Note"]]!=""} { lappend Note $TexteNote } lappend Note "" set Texte [RecapitulatifDesOrthologues $Nom "TPMA"] if { $Texte != "" } { lappend Note "$Texte" } SauveLesLignes $Note dans "$RepNotes/$Nom" } return "" } proc CreeToutesLesNotes {{Liste ""}} { global RepertoireDuGenome global Org1 Org2 if {[OnTraiteDesCDNAs]} { return [CreeToutesLesNotesPourCDNA] } if {[OnTraiteUneCollection]} { return [CreeToutesLesNotesPourCollection] } set RepNotes "$RepertoireDuGenome/notes" if { ! [file exists $RepNotes]} { File mkdir $RepNotes } if {$Liste==""} { set Liste [ListeDesPABs] } foreach Boite $Liste { set Note {} set Nom [Box $Boite nom] set Debut [Box $Boite debut] set Fin [Box $Boite fin] set Orient [Box $Boite orient] set Long [expr ($Fin - $Debut + 1)/3] set CF [ClasseFonctionnelle $Nom] if {$CF==000} { set $CF "" } set Access [Narcisse $Nom] if {$Access==""} { set TexteAccess "This ORF couldn't yet be found in database." } else { set TexteAccess "$Access" } lappend Note "$Nom" lappend Note "" set GN [NomDeGene $Nom] if {$GN!="" && $GN!=$Nom} { lappend Note "Gene Name : $GN" } lappend Note "Accession number : $TexteAccess" lappend Note "Function : [DefinitionApproximative $Nom]" set FF [FiabiliteFonction $Nom] set FDR "Unknown" if { $FF == 9 } { set FDR "Function definition reliability: High" } if { $FF == 7 } { set FDR "Function definition reliability: Good" } if { $FF == 5 } { set FDR "Function definition reliability: Low" } if { $FF == 3 } { set FDR "Function definition reliability: motif on small region" } if { $FF == 1 } { set FDR "Function definition reliability: any function detected" } if { $FF == 0 } { set FDR "Function definition reliability: no homology found" } # lappend Note $FDR lappend Note "" if {$Orient=="F"} { set Sens "+" } else { set Sens "-" } lappend Note "Genome localisation : $Debut $Fin $Sens $Long AA" lappend Note "" set Texte [ExtraitInfo $Nom "PMID"] if { $Texte != "" } { lappend Note "PMID : $Texte\n" } set CompoATGC [CompositionEn ATGC $Nom] if { $CompoATGC != "" } { scan $CompoATGC "%d %d %d %d %d %d" GC AT A T G C lappend Note "ATGC composition : GC=$GC % AT=$AT % A=$A % T=$T % G=$G % C=$C %" } set Texte [Overlap $Nom] if { $Texte != "" } { lappend Note "Overlap : $Texte" } set Texte [ShineDalgarno $Nom "Nice"] if { $Texte != "" } { lappend Note $Texte } lappend Note "" set Avant [TexteOMO $Nom Avant] set Apres [TexteOMO $Nom Apres] if {$Avant!="" || $Apres!=""} { lappend Note "Two genes cluster maintenance" } if {$Avant!=""} { lappend Note " with previous : [TexteOMO $Nom Long]" } if {$Apres!=""} { lappend Note " with next : [TexteOMO $Apres Long]" } set Texte [SignalDAutresHomologues $Nom] if { $Texte != "" } { lappend Note "Other homologs : $Texte" } lappend Note "" set nCops [NombreDeCopainsDansBlast $Nom] lappend Note "BlastP hits count : $nCops" if {0 && [info exists Org1] && [YaPABdans $Nom] && ! [ExisteOrthologueDans $Org1 $Nom]} { lappend Note "Ortholog not found in [Glossaire $Org1 Complet]" } if {0 && [info exists Org1] && [YaPABdans $Nom] && ! [ExisteOrthologueDans $Org2 $Nom]} { lappend Note "Ortholog not found in [Glossaire $Org2 Complet]" } set nParalogues [NombreDeParaloguesDe $Nom] if {$nParalogues==-1} { set Texte "" } elseif {$nParalogues==0} { set Texte "Paralogs : not found" } else { set Texte "Paralogs : $nParalogues were found" } if { $Texte != "" } { lappend Note $Texte } lappend Note "" set pTBN [PourcentageDeGenomesCompletsOrthologuesDansTBlastN $Nom] set pDBC [PourcentageDeGenomesCompletsOrthologuesDansDbClustal $Nom] set nGinTBN [PourcentageDeGenomesCompletsOrthologuesDansTBlastN "Count"] set nGinDBC [PourcentageDeGenomesCompletsOrthologuesDansDbClustal "Count"] lappend Note "Orthologuous organisms (within the $nGinDBC studied complete genomes)" lappend Note " percentage in TBlastN : $pTBN % of $nGinTBN" lappend Note " percentage in DbClustal : $pDBC % of $nGinDBC" lappend Note "" set Texte [RecapitulatifDesOrthologues $Nom "TPMA"] if { $Texte != "" } { lappend Note "$Texte" } lappend Note "" set MD [MDScore $Nom] if {$MD > -9999.0} { lappend Note "NormMD : score of multialignment $MD" } lappend Note "" set Start [StartCodonReport $Nom "Start"] set Texte $Start if {[regexp {[0-9]+} $Start Pos]} { set Summary [StartCodonSummary $Nom $Pos] if { ! [regexp "NoSummary" $Summary] } { scan $Summary "%d" iGGT set GGT "" if {$iGGT>0} { set GGT [string trim [string range $Summary 55 end]] append Texte " with ShineDalgarno at $iGGT $GGT" } } } Espionne "$Nom $Texte" lappend Note "Proposed start codon : $Texte" set Texte [CAI $Nom] if {$Texte!=""} { lappend Note "Codon Adaptation Index : $Texte" } set Hi [Hydrophobicity $Nom "Hydro"] set Hn [Hydrophobicity $Nom "nHelices"] if {$Hi!=-999} { lappend Note "Hydrophobicity : Index $Hi , $Hn predicted helices" } lappend Note "" lappend Note [ContenuDuFichier $RepertoireDuGenome/prottfa/$Nom] lappend Note "" lappend Note [ContenuDuFichier $RepertoireDuGenome/nuctfa/$Nom] set MaxD 0 foreach Ligne $Note { if {[regexp -indices { \: } $Ligne Indices]} { scan $Indices "%d" D set MaxD [Maxi $MaxD $D] } } incr MaxD 2 set LaBelleNote {} foreach Ligne $Note { if {[regexp -indices { \: } $Ligne Indices]} { scan $Indices "%d" D set nPoints [string repeat "." [expr $MaxD - $D]] regsub { \: } $Ligne " $nPoints : " Ligne } lappend LaBelleNote $Ligne } SauveLesLignes $LaBelleNote dans "$RepNotes/$Nom" } return $LaBelleNote } proc SignalDAutresHomologues Nom { set AutresHomologues [ExtraitInfo $Nom "AutresHomologues"] if { ! [regexp "signal" $AutresHomologues]} { return "" } return "$AutresHomologues" } proc NomDeGeneIssuDeDefinitionApproximativePourTous {{Ask ""}} { global InformeSansDemander if {[info exists InformeSansDemander]} { set Memo $InformeSansDemander } if {$Ask==""} { set Ask 1 } else { set Ask 0 } set InformeSansDemander [expr ! $Ask] foreach Nom [ListeDesPABs] { set GNDA [NomDeGeneIssuDeDefinitionApproximative $Nom] if {$GNDA==""} { continue } if {$Ask} { set OldGN [NomDeGene $Nom] if {$OldGN=="" || [YaPABdans $OldGN]} { set Message "use $GNDA " } else { set Message "replace $OldGN with $GNDA " } if { ! [OuiOuNon "Can I $Message as Gene Name for $Nom ?"]} { continue } } Informe $Nom "ValiGN: $GNDA" if {$Ask && [OuiOuNon "Do I stop asking ?"]} { set Ask 0 set InformeSansDemander 1 } } if {[info exists Memo]} { set InformeSansDemander $Memo } else { unset InformeSansDemander } } proc NomDeGeneIssuDeDefinitionApproximative Nom { set DA [DefinitionApproximative $Nom] regsub -nocase {\(taken from [a-z]*\)} $DA "" DA set DA [string trim $DA] if { ! [regexp -nocase {\([a-z_\-]+\)$} $DA Match]} { return "" } regsub -all {[\(\)]} $Match "" GNDA return $GNDA } proc NomDeGene Nom { set ValiGN [ExtraitInfo $Nom "ValiGN"] if {$ValiGN == ""} { return $Nom } else { return $ValiGN } } proc BestDefinitionOfDbClustalPourTous {} { foreach Nom [ListeDesPABs] { set DE [BestDefinitionOfDbClustal $Nom] Espionne "$Nom $DE" InformeSansDemander $Nom "DE_DbClustal: $DE" } } proc BestDefinitionOfDbClustal Nom { global NotreOS global NotreOrga foreach {Orga Dist Access} [LesOrgaDistAccessDesOrthologues $Nom] { if {$Orga==$NotreOrga} { continue } if {[EstUnAccessPDB $Access]} { set OS [OrganismeDuPDB $Access] set DE [TextePDB $Access "KEYWDS"] } else { set OS [OrgaDuAccess $Access] set DE [DefinitionDuAccess $Access] } if {$DE=="" || [regexp -nocase "hypothetical" $DE]} { continue } return "$DE (from $OS $Access dist=$Dist)" } return "" } proc BestDefinitionOfLeonPourTous {} { foreach Nom [ListeDesPABs] { set DE [BestDefinitionOfLeon $Nom] if {$DE==""} { continue } Espionne "$Nom $DE" InformeSansDemander $Nom "DE_Leon: $DE" } } proc BestDefinitionOfLeon Nom { set NotreOS [NotreOS] set NotreOrga [NotreOrga] set NotreTaxId [NotreTaxId] set FichierLeon "[RepertoireDuGenome]/leonLeo/$Nom" if { ! [file exists $FichierLeon]} { set FichierLeon "[RepertoireDuGenome]/leonLeo/$Nom.msf" } if { ! [file exists $FichierLeon]} { return "" } set n [DecortiqueUnMSF $FichierLeon LesNomsDeSequences] foreach NomSeq $LesNomsDeSequences] { set Dae [DaedalusHit $NomSeq $Nom] if {$Dae!=""} { set TaxId [ChampDaedalus TaxId $NomSeq $Nom] if {$TaxId==$NotreTaxId} { continue } } set Orga if {$Orga==$NotreOrga} { continue } if {[EstUnAccessPDB $Access]} { set OS [OrganismeDuPDB $Access] set DE [TextePDB $Access "KEYWDS"] } else { set OS [OrgaDuAccess $Access] set DE [DefinitionDuAccess $Access] } if {$DE=="" || [regexp -nocase "hypothetical" $DE]} { continue } return "$DE (from $OS $Access dist=$Dist)" } return "" } proc BestDefinitionOfBlastXPourTous {{SeuilExpect ""} {ForbidenWordInDE ""} {RepDuBlast ""} {UseFirstDE ""} {NoAccessInHit ""}} { foreach Nom [ListeDesPABs] { set DE [BestDefinitionOfBlastX $Nom $SeuilExpect $ForbidenWordInDE $RepDuBlast $UseFirstDE $NoAccessInHit] if {$DE==""} { continue } Espionne "$Nom $DE" InformeSansDemander $Nom "DE_BlastX: $DE" } } proc BestDefinitionOfBlastPPourTous {{SeuilExpect ""} {ForbidenWordInDE ""} {RepDuBlast ""} {UseFirstDE ""} {NoAccessInHit ""}} { foreach Nom [ListeDesPABs] { set DE [BestDefinitionOfBlastP $Nom $SeuilExpect $ForbidenWordInDE $RepDuBlast $UseFirstDE $NoAccessInHit] if {$DE==""} { continue } Espionne "$Nom $DE" InformeSansDemander $Nom "DE_BlastP: $DE" } } proc BestDefinitionOfBlastX {Nom {SeuilExpect ""} {ForbidenWordInDE ""} {RepDuBlast ""} {UseFirstDE ""} {NoAccessInHit ""}} { if {$RepDuBlast==""} { set RepDuBlast "blastx" } return [BestDefinitionOfBlastP $Nom $SeuilExpect $ForbidenWordInDE $RepDuBlast $UseFirstDE $NoAccessInHit] } proc BestDefinitionOfBlastP {Nom {SeuilExpect ""} {ForbidenWordInDE ""} {RepDuBlast ""} {UseFirstDE ""} {NoAccessInHit ""}} { global RepertoireDuGenome global NotreOS global NotreOrga Wup "Attention ca marche AUSSI pour BlastX avec RepDuBlast" if {$RepDuBlast==""} { set RepDuBlast "blastp" } if {$ForbidenWordInDE==""} { set ForbidenWordInDE "hypotheticalxxxxxxxxxxxxxxxxxxxx" } if {$SeuilExpect==""} { set SeuilExpect 0.001 } set FichierBlastP "$RepertoireDuGenome/$RepDuBlast/$Nom" if { ! [file exists $FichierBlastP]} { return "No blastp" } #rR depuis 2021/10/11 on peut dire qu'il n'y a pas d'access set lAccessOrNoAccessInHit lAccess if {[string equal -nocase $NoAccessInHit "NoAccessInHit"]} { set lAccessOrNoAccessInHit "NoAccessInHit" } DecortiqueBlast $FichierBlastP "SansSeuilExpect" "SansLimiteDeNombre" Query lBanqueId $lAccessOrNoAccessInHit lDE lProfil lPN if {[string equal -nocase $NoAccessInHit "NoAccessInHit"]} { set lAccess $lBanqueId } foreach BanqueId $lBanqueId Access $lAccess DE $lDE PN $lPN { Espionne $BanqueId $Access $DE if {$PN>$SeuilExpect} { continue } if {[regexp -nocase {^UniRef[0-9]+_(.+)} $BanqueId Match A]} { set Access $A } if {[regexp {\:} $BanqueId]} { set N [StringApres ":" dans $BanqueId] if {[EstUnPAB $N]} {continue} } if {$DE=="" || [regexp -nocase $ForbidenWordInDE $DE]} { continue } Espionne DE $DE if {[string equal -nocase $UseFirstDE "UseFirstDE"]} { return "$DE (from FirstHit WithDefinition $Access expect=$PN)" } if {[EstUnAccessPDB $BanqueId]} { set aPDB $BanqueId set OS [OrganismeDuPDB $aPDB] set DE [TextePDB $aPDB "KEYWDS"] } else { if {[regexp -nocase {^UniRef[0-9]+_(.+)*} $Access Match Acc]} { set Access $Acc } # set OS [QuestionDeScience QuidSeq "QuidOSOfAC $Access"] set OS "" set DE "" #rR j'ai interverti les DecortiqueLesLignesEMBL avec LesChampsInteressantsDuAccess if {1 || $OS==""} { set LEmbl [LaSequenceDesBanques $BanqueId $Access AOk "OnVeutEmbl"] if {$LEmbl=={}} { continue } DecortiqueLesLignesEMBL $LEmbl IDlu AClu DElu GNlu OSlu OClu OXlu set OS $OSlu set DE $DElu regsub -all {[ \n\t]+} $DE " " DE set DE [string trim $DE] } if {$DE==""} { ScanLaListe [LesChampsInteressantsDuAccess $Access $Access "OS" "DE" ] OS DE } regsub -all {[ \n\t]+} $DE " " DE set DE [string trim $DE] set OS [string trim $OS] Espionne $DE } if {$DE=="" || $OS==""} { continue } return "$DE (from $OS $Access expect=$PN)" return $DE } return "" } proc DefinitionRapide Nom { return [Definition $Nom "ApproxDansInfo"] } proc DefinitionApproximative Nom { return [Definition $Nom "Approx"] } proc Definition {Nom {Approx ""}} { set ValiDE [ExtraitInfo $Nom "ValiDE"] if {$ValiDE != ""} { return $ValiDE } if {[OnTraiteDesCDNAs]} { return "" } if {$Approx!=""} { set DE [ExtraitInfo $Nom "DEJ"] if {$DE!=""} { return "$DE"} set DE [ExtraitInfo $Nom "SpineDef"] if {$DE!=""} { return "$DE"} set DE [ExtraitInfo $Nom "DE_GenBank"] if {$DE!=""} { return "$DE (taken from Genbank)"} set DE [ExtraitInfo $Nom "DE_Narcisse"] if {$DE!=""} { return "$DE (taken from database)"} set DE [ExtraitInfo $Nom "DE_DbClustal"] if {$DE!=""} { return "DE_BestDbClustal: $DE" } set DE [ExtraitInfo $Nom "DE_BlastP"] if {$DE!=""} { return "DE_BlastP: $DE" } set DE [ExtraitInfo $Nom "DE_BlastX"] if {$DE!=""} { return "DE_BlastX: $DE" } if {[regexp "ApproxDansInfo" $Approx]} { return "DE not yet established" } set DE [BestDefinitionOfDbClustal $Nom] if {$DE!=""} { return "DE_BestDbClustal: $DE" } set DE [BestDefinitionOfBlastP $Nom] if {$DE!=""} { return "DE_BestBlastP: $DE" } set DE [BestDefinitionOfBlastX $Nom] if {$DE!=""} { return "DE_BestBlastX: $DE" } } return "Hypothetical protein or DE not known" } proc ClasseFonctionnelle Nom { global SourceClasseFonctionnelle global RepertoireDuGenome if {[info exists SourceClasseFonctionnelle]} { return [ClasseFonctionnelleDans$SourceClasseFonctionnelle $Nom] } set FichierFonctionsValidees "$RepertoireDuGenome/fiches/fonctionsvalidees" if {[regexp "casimir" $RepertoireDuGenome] || ! [file exists $FichierFonctionsValidees]} { set SourceClasseFonctionnelle "Info" } else { set SourceClasseFonctionnelle [ChoixParmiJoli {"Info" "FonctionsValidees"} {} \ {"Functional classes in Info files" "Functional classes in FonctionsValidees"}] } return [ClasseFonctionnelle $Nom] } proc ClasseFonctionnelleDansInfo Nom { if {[regexp "TROU" $Nom]} { return 200 } set ValiCF [ExtraitInfo $Nom "ValiCF"] set CF 00 if {[regexp "unknown" $ValiCF]} { set ValiCF 153 } scan $ValiCF "%d" CF return [format "%3.3d" $CF] } proc ClasseFonctionnelleDansFonctionsValidees Nom { global ClasseFonctionnelle global RepertoireDuGenome if {[info exists ClasseFonctionnelle($Nom)]} { return [set ClasseFonctionnelle($Nom)] } if {[info exists ClasseFonctionnelle("EstCharge")]} { if {[regexp "TROU" $Nom]} { return 200 } return 153 } set ClasseFonctionnelle("EstCharge") 1 set FichierFonctionsValidees "$RepertoireDuGenome/fiches/fonctionsvalidees" if {[file exists $FichierFonctionsValidees]} { foreach Ligne [LesLignesDuFichier $FichierFonctionsValidees] { if { ! [regexp {^[A-Z]} $Ligne]} { continue } scan $Ligne "%s %s %s" PAB FF CF set PABY $PAB if {[regexp {PAB[0-9]+} $PAB]} { regsub PAB $PAB [PreFixe] PABY } Espionne "set ClasseFonctionnelle($PABY) $CF" set ClasseFonctionnelle($PABY) $CF } } return [ClasseFonctionnelleDansFonctionsValidees $Nom] } proc CreeLesInfosDesTRNAs {} { global RepertoireDuGenome global ListeDeBoites global ListeDesTRNAs ChargeLesTRNAs foreach TRNA $ListeDesTRNAs { set AA [string range $TRNA 4 6] set Codon [string range $TRNA 7 9] set Info {} lappend Info "Nom: $TRNA" lappend Info "ValiDE: tRNA $AA $Codon" lappend Info "ValiGN: tRNA-$AA-$Codon" lappend Info "ValiCF: 191" Espionne [SauveLesLignes $Info dans "$RepertoireDuGenome/infos/$TRNA"] } } proc RenommeTousLesFichiersDesSousRepertoires {Ancien Nouveau} { global RepertoireDuGenome foreach Fichier [glob "$RepertoireDuGenome/*/$Ancien"] { if { ! [file isfile $Fichier]} { continue } set DirName [file dirname $Fichier] regsub -all $Ancien [ContenuDuFichier $Fichier] $Nouveau NouveauContenu Espionne [Sauve $NouveauContenu dans "$DirName/$Nouveau"] } } proc RenommageAFaire {} { global RepertoireDuGenome foreach Ligne [LesLignesDuFichier "renommage.afaire"] { scan $Ligne "%s %s" Nouveau Ancien RenommeTousLesFichiersDesSousRepertoires $Ancien $Nouveau lappend LesAnciens $Ancien lappend LesNouveaux $Nouveau } foreach Fichier [glob "$RepertoireDuGenome/fiches/*"] { if { ! [file isfile $Fichier]} { continue } set Contenu [ContenuDuFichier $Fichier] foreach Ancien $LesAnciens Nouveau $LesNouveaux { regsub -all $Ancien $Contenu $Nouveau Contenu } Espionne [Sauve $Contenu dans "$Fichier"] } } proc RepriseDesPABsCitesDans FOF { foreach Nom [LesLignesDuFichier $FOF] { ReprisePAB $Nom } } proc ReprisePAB Nom { global RepertoireDuGenome global ListeDeBoites global ListeDesTROUs global ADN TDN RAC if { ! [info exists ListeDeBoites]} { ChargeListeDeBoites } if { ! [info exists ADN]} { ChargeADNetTDNetRAC } set Debut [Box $Nom debut] set Fin [Box $Nom fin] set Orient [Box $Nom orient] set Reprises [ExtraitInfo $Nom "Fusion"] if {[llength $Reprises] == 0} { return "" } foreach Reprise [split $Reprises "/"] { set LesChamps [split [string trim $Reprise] " "] set SequenceLimite [lindex $LesChamps 0] set PABaCreer [lindex $LesChamps 2] set Commentaire $Reprise Espionne "$Commentaire" if {[file exists "$RepertoireDuGenome/prottfa/$PABaCreer"]} { if {[OuiOuNon "J'ecrase $PABaCreer, si non j'abandonne $PABaCreer."]} { continue } } switch -regexp -- $SequenceLimite { {^\-\-\-} { set Offset -2 } {^\-\-} { set Offset -1 } {^\-} { set Offset -0 } {\*$} { set Offset 1 } default { FaireLire "Ca merde pour $Nom $sequenceLimite"; continue} } regsub -all -- {[^A-Za-z]} $SequenceLimite "" SequenceLimite if {$Offset <=0} { if {$Orient == "F"} { set D [expr $Debut-3+$Offset] set F [expr $D + [string length $SequenceLimite]*3 - 1] set AntiSens -1 } else { set F [expr $Fin+3-$Offset] set D [expr $F - [string length $SequenceLimite]*3 + 1] set AntiSens 1 } set InsisteEncore 10000 while {$InsisteEncore} { set SeqNuc [BoutADN $D $F $Orient] set SeqPro [SeqNucToSeqPro $SeqNuc] if {$SequenceLimite == $SeqPro} { break } incr D $AntiSens incr F $AntiSens } if {$SequenceLimite != $SeqPro} { FaireLire "Je ne trouve pas $SequenceLimite devant $Nom. J'abandonne." return "" } if {$Orient == "F"} { set NouveauDebut $D set F [expr $NouveauDebut+2] while { [AAduCodon [BoutADN [incr F 1] [incr F 2] $Orient]] != "\*" } { } set NouvelleFin [incr F -3] } else { set NouvelleFin $F set D [expr $NouvelleFin] while { [AAduCodon [BoutADN [incr D -5] [incr D 2] $Orient]] != "\*" } { } set NouveauDebut [incr D 1] } Wup "Ici on a donc etendu la proteine en devant." } else { if {$Orient == "F"} { set D [expr $Debut+3] set F [expr $D + [string length $SequenceLimite]*3 - 1] set AntiSens +3 } else { set F [expr $Fin-3] set D [expr $F - [string length $SequenceLimite]*3 + 1] set AntiSens -3 } while {1} { set SeqNuc [BoutADN $D $F $Orient] set SeqPro [SeqNucToSeqPro $SeqNuc] if {[regexp {\*} $SeqPro]} { FaireLire "Je ne trouve pas $SeqenceLimite derriere $Nom." break } if {$SequenceLimite == $SeqPro} { break } incr D $AntiSens incr F $AntiSens } if {$Orient == "F"} { set NouvelleFin $F set NouveauDebut $Debut } else { set NouveauDebut $D set NouvelleFin $Fin } Wup "Ici on a donc etendu la proteine derriere." } set SeqNuc [BoutADN $NouveauDebut $NouvelleFin $Orient] set SeqPro [SeqNucToSeqPro $SeqNuc] Espionne "$PABaCreer $NouveauDebut $NouvelleFin $Orient" set NUC [SequenceFormatTFA $SeqNuc "$PABaCreer $NouveauDebut $NouvelleFin $Orient" "nucbrut"] Espionne [Sauve $NUC dans "$RepertoireDuGenome/nuctfa/$PABaCreer"] set TFA [SequenceFormatTFA $SeqPro "$PABaCreer $NouveauDebut $NouvelleFin $Orient" "protbrut"] Espionne [Sauve $TFA dans "$RepertoireDuGenome/prottfa/$PABaCreer"] Box $PABaCreer nom $PABaCreer Box $PABaCreer debut $NouveauDebut Box $PABaCreer fin $NouvelleFin Box $PABaCreer orient $Orient } } proc ExtraireDe {Ligne aNom aDebut aFin aOrient} { upvar $aNom Nom upvar $aDebut Debut upvar $aFin Fin upvar $aOrient Orient regsub ">" $Ligne "" Ligne set nChampsLus [scan $Ligne "%s %s %s %s" Nom Debut Fin Orient] if {$nChampsLus == 1} { if {[OuiOuNonMemo "I couldn't read 'Debut Fin Orient' reading fiches/bornesdespabs\n\ Do I use default values 0 999 F ?"]} { set Debut 0 set Fin 999 set Orient "F" } else { if {[OuiOuNon "Do I exit ?"]} { Boum } return } } if { $nChampsLus == 3 } { set Orient "F" if { [expr $Fin < $Debut] } { set Temp $Debut set Debut $Fin set Fin $Temp set Orient "R" } } return } proc DiagnostiquePhyloFolle Nom { global RepertoireDuGenome global PhylosFolles set ListeOrgas [Phylon $Nom] if {[llength $ListeOrgas] == 0} { return {} } foreach Orga $ListeOrgas { if {[PyroLike $Orga]} { continue } if {[ArkaeaLike $Orga]} { lappend Folie [string toupper $Orga] ; break } lappend Folie $Orga } return $Folie } proc DiagnostiqueLesPhylosFolles {} { global ListeDeBoites if { ! [info exists ListeDeBoites]} { ChargeListeDeBoites } foreach Boite $ListeDeBoites { set Nom [Box $Boite nom] if { ! [PhyloFolle $Nom] } { continue } set Folie [DiagnostiquePhyloFolle $Nom] if { $Folie == {} } { continue } puts "$Nom [join $Folie " "]" } } proc UsageDesCodonsEtCodeCirculaire {} { #rR on veut voir si le code circulaire préférencie l'ensemble X0 ci-dessous foreach Codon [list AAC AAT ACC ATC ATT CAG CTC CTG GAA GAC GAG GAT GCC GGC GGT GTA GTC GTT TAC TTC] { set X($Codon) 1 set Codon1 "[string range $Codon 1 end][string index $Codon 0]" set Codon2 "[string range $Codon1 1 end][string index $Codon1 0]" set X1($Codon1) 1 set X2($Codon2) 1 } set NbCodons 0 foreach Nom [ListeDesPABs] { set FiNuc [GscopeFile $Nom nuctfa] if {[FileAbsent $FiNuc]} { continue } set Seq [QueLaSequenceDuFichierTFA $FiNuc] set Seq [string toupper $Seq] foreach {A B C} [split $Seq ""] { set Codon "$A$B$C" if { ! [regexp {^[ATGC][ATGC][ATGC]$} $Codon]} { continue } lappend LesCodons $Codon incr Frame0($Codon) incr NbCodons } set Seq "[string range $Seq 1 end]X" foreach {A B C} [split $Seq ""] { set Codon "$A$B$C" if { ! [regexp {^[ATGC][ATGC][ATGC]$} $Codon]} { continue } lappend LesCodons $Codon incr Frame1($Codon) } set Seq "[string range $Seq 1 end]X" foreach {A B C} [split $Seq ""] { set Codon "$A$B$C" if { ! [regexp {^[ATGC][ATGC][ATGC]$} $Codon]} { continue } lappend LesCodons $Codon incr Frame2($Codon) } } set LesCodons [lsort -unique $LesCodons] set LesN0 {} set LesN1 {} set LesN2 {} foreach Codon $LesCodons { if { ! [info exists Frame0($Codon)]} { set N 0 } else { set N $Frame0($Codon) } lappend LesCodonsDe0($N) $Codon lappend LesN0 $N if { ! [info exists Frame1($Codon)]} { set N 0 } else { set N $Frame1($Codon) } lappend LesCodonsDe1($N) $Codon lappend LesN1 $N if { ! [info exists Frame2($Codon)]} { set N 0 } else { set N $Frame2($Codon) } lappend LesCodonsDe2($N) $Codon lappend LesN2 $N } set LesN0 [lsort -integer -unique -decreasing $LesN0] set LesN1 [lsort -integer -unique -decreasing $LesN1] set LesN2 [lsort -integer -unique -decreasing $LesN2] set LesCodonsTries0 {} foreach N $LesN0 { LConcat LesCodonsTries0 $LesCodonsDe0($N) } set LesCodonsTries1 {} foreach N $LesN1 { LConcat LesCodonsTries1 $LesCodonsDe1($N) } set LesCodonsTries2 {} foreach N $LesN2 { LConcat LesCodonsTries2 $LesCodonsDe2($N) } set LesCircu0 {} foreach Codon $LesCodonsTries0 { if {[info exists Frame0($Codon)]} { set F $Frame0($Codon) } else { set P 0 } if {[info exists X($Codon)]} { lappend LesCircu0 $Codon lappend LesPourCent0 [format "%3d" [expr ($F*10000)/$NbCodons]] } else { lappend LesCircu0 " " lappend LesPourCent0 [format "%3d" [expr ($F*10000)/$NbCodons]] } } set LesCircu1 {} foreach Codon $LesCodonsTries1 { if {[info exists Frame1($Codon)]} { set F $Frame1($Codon) } else { set P 0 } if {[info exists X1($Codon)]} { lappend LesCircu1 $Codon lappend LesPourCent1 [format "%3d" [expr ($F*10000)/$NbCodons]] } else { lappend LesCircu1 " " lappend LesPourCent1 [format "%3d" [expr ($F*10000)/$NbCodons]] } } set LesCircu2 {} foreach Codon $LesCodonsTries2 { if {[info exists Frame2($Codon)]} { set F $Frame2($Codon) } else { set P 0 } if {[info exists X2($Codon)]} { lappend LesCircu2 $Codon lappend LesPourCent2 [format "%3d" [expr ($F*10000)/$NbCodons]] } else { lappend LesCircu2 " " lappend LesPourCent2 [format "%3d" [expr ($F*10000)/$NbCodons]] } } set LeMessage {} lappend LeMessage [join $LesCircu0 " "] lappend LeMessage [join $LesCodonsTries0 " "] lappend LeMessage [join $LesPourCent0 " "] lappend LeMessage "" lappend LeMessage [join $LesCircu1 " "] lappend LeMessage [join $LesCodonsTries1 " "] lappend LeMessage [join $LesPourCent1 " "] lappend LeMessage "" lappend LeMessage [join $LesCircu2 " "] lappend LeMessage [join $LesCodonsTries2 " "] lappend LeMessage [join $LesPourCent2 " "] set Message [join $LeMessage "\n"] return [Affiche $Message "" "CodonOrderFor_[NotreOS]"] } proc AfficheUsageDesCodons {{Nom ""}} { if {$Nom==""} { set Nom [Entre [PreFixe]] } set UC [UsageDesCodons $Nom] set YaEuEntete 0 set YaEuPourCent 0 set LesA {} set LesCodons {} foreach Ligne [split $UC "\n"] { regsub -all {[ \t]+} $Ligne " " Ligne set Ligne [string trim $Ligne] if {$Ligne==""} { continue } set LesMots [LesMotsDuTexte $Ligne] if {[regexp -nocase {[A-Z]} $Ligne]} { set LesADeLaLigne {} set LesCodonsDeLaLigne {} foreach {A Codon} $LesMots { lappend LesA $A lappend LesCodons $Codon lappend LesADeLaLigne $A lappend LesCodonsDeLaLigne $Codon } set YaEuEntete 1 continue } if {$YaEuEntete} { set YaEuEntete 0 foreach A $LesADeLaLigne Codon $LesCodonsDeLaLigne P $LesMots { set Gde($A) $P set Gde($Codon) $P lappend LesG $P lappend LesADeG($P) $A lappend LesCodonDdeG($P) $Codon } set YaEuPourCent 1 continue } if {$YaEuPourCent} { set YaEuPourCent 0 foreach A $LesADeLaLigne Codon $LesCodonsDeLaLigne P $LesMots { set Lde($A) $P set Lde($Codon) $P lappend LesL $P lappend LesADeL($P) $A lappend LesCodonDdeL($P) $Codon } continue } } set LesG [lsort -integer -unique -decreasing $LesG] set LesL [lsort -integer -unique -decreasing $LesL] foreach Codon [list AAC AAT ACC ATC ATT CAG CTC CTG GAA GAC GAG GAT GCC GGC GGT GTA GTC GTT TAC TTC] { set X($Codon) 1 } set CodonsG "" set PourCentG "" foreach G $LesG { foreach Codon $LesCodonDdeG($G) { if {[info exists X($Codon)]} { append CircuG [format " %s %s" [AAduCodon $Codon] $Codon] } else { append CircuG [format " %s %s" " " " "] } set PourCent $G append CodonsG [format " %s %s" [AAduCodon $Codon] $Codon] append PourCentG [format " %5d" $PourCent] } } set Codons "" set PourCent "" foreach L $LesL { foreach Codon $LesCodonDdeL($L) { if {[info exists X($Codon)]} { append CircuL [format " %s %s" [AAduCodon $Codon] $Codon] } else { append CircuL [format " %s %s" " " " "] } set PourCent $L append CodonsL [format " %s %s" [AAduCodon $Codon] $Codon] append PourCentL [format " %5d" $PourCent] } } set Message $UC append Message "\n" append Message "\n" append Message $CircuG append Message "\n" append Message $CodonsG append Message "\n" append Message $PourCentG append Message "\n" append Message "\n" append Message $CircuL append Message "\n" append Message $CodonsL append Message "\n" append Message $PourCentL set Circu "" append Message "\n" append Message $Circu return [Affiche $Message "" "CodonUsageOf_$Nom"] } proc UsageDesCodons {NomVoulu} { global UsageDesCodons global RepertoireDuGenome global ListeDeBoites if {[info exists UsageDesCodons($NomVoulu)]} { return [set UsageDesCodons($NomVoulu)] } if {[info exists UsageDesCodons("EstCharge")]} { return "" } set FichierUsageDesCodons "$RepertoireDuGenome/fiches/usagedescodons" if {[file exists $FichierUsageDesCodons]} { array set UsageDesCodons [split [ContenuDuFichier $FichierUsageDesCodons] ":"] if {[info exists UsageDesCodons($NomVoulu)]} { return [set UsageDesCodons($NomVoulu)] } return "" } if { ! [OuiOuNon "Do I calculate now UsageDesCodons ?" 0]} { set UsageDesCodons("EstCharge") 1 return "" } set NombreDeCodons 0 foreach Boite [ListeDeBoites] { set Nom [Box $Boite nom] set Debut [Box $Boite debut] set Fin [Box $Boite fin] set Orient [Box $Boite orient] if { ! [YaPABdans $Nom]} { continue } if {[Enterre $Nom]} { continue } if {$Orient == "F"} { incr Fin 3 } else { incr Debut -3 } if {[OuiOuNonMemo "Do I use the genome DNA file for CodonW?"]} { set SeqNuc [BoutADN $Debut $Fin $Orient] } else { set Rep [RepDesNucPourCodonW] set SeqNuc [QueLaSequenceDuFichierTFA [GscopeFile $Nom $Rep]] } for {set i 0} {$i <= [expr $Fin-$Debut]} {incr i 3} { set Codon [string range $SeqNuc $i [expr $i+2]] if { ! [info exists CodonUsage($Codon)]} { if { ! [regexp {^[ATGC][ATGC][ATGC]$} $Codon]} { continue } lappend ListeDesCodons $Codon set CodonUsage($Codon) 0 } incr CodonUsage($Codon) incr NombreDeCodons if { ! [info exists CodonUsage($Codon,$Nom)]} { set CodonUsage($Codon,$Nom) 0 } incr CodonUsage($Codon,$Nom) } lappend ListeDesLongueurs [expr ($Fin-$Debut+1)/3] lappend ListeDesNoms $Nom } Espionne "J'ai compte $NombreDeCodons codons" set UC {} set OldPremiereBase "X" foreach Codon [lsort $ListeDesCodons] { set PremiereBase [string index $Codon 0] if {$PremiereBase != $OldPremiereBase} { if { $OldPremiereBase != "X" } { lappend UC $Codons lappend UC $PourCent lappend UC "" } set Codons "" set PourCent "" } set OldPremiereBase [string index $Codon 0] append Codons [format " %s %s" [AAduCodon $Codon] $Codon] append PourCent [format " %5d" [expr round(10000.*[set CodonUsage($Codon)]/$NombreDeCodons)]] } lappend UC $Codons lappend UC $PourCent lappend UC "" set UsageDesCodons(Global) "\n[join $UC "\n"]" foreach Nom $ListeDesNoms Longueur $ListeDesLongueurs { Espionne $Nom set UC {} set OldPremiereBase "X" foreach Codon [lsort $ListeDesCodons] { set PremiereBase [string index $Codon 0] if {$PremiereBase != $OldPremiereBase} { if { $OldPremiereBase != "X" } { lappend UC $Codons lappend UC $PourCent lappend UC $PourNom lappend UC "" } set Codons "" set PourCent "" set PourNom "" } set OldPremiereBase [string index $Codon 0] append Codons [format " %s %s" [AAduCodon $Codon] $Codon] append PourCent [format " %5d" [expr round(10000.*[set CodonUsage($Codon)]/$NombreDeCodons)]] if {[info exists CodonUsage($Codon,$Nom)]} { set CodonUsageDuNom [set CodonUsage($Codon,$Nom)] } else { set CodonUsageDuNom 0 } append PourNom [format " %5d" [expr round(10000.*$CodonUsageDuNom/$Longueur)]] } lappend UC $Codons lappend UC $PourCent lappend UC $PourNom lappend UC "" set UsageDesCodons($Nom) "\n[join $UC "\n"]" } set UsageDesCodons("EstCharge") 1 Sauve [join [array get UsageDesCodons] ":"] dans $FichierUsageDesCodons if {[info exists UsageDesCodons($NomVoulu)]} { return [set UsageDesCodons($NomVoulu)] } return "" } proc ClustalX {MSF {IsFile ""}} { if {$IsFile=="IsFile"} { set FichierMSF $MSF } else { set FichierMSF [TmpFile "msf"] Sauve $MSF dans $FichierMSF } exec clustalx $FichierMSF & } proc NJPlotMSF {MSF {IsFile ""}} { if {$IsFile=="IsFile"} { set Delete 0 set FichierMSF $MSF } else { set Delete 1 set FichierMSF [Sauve $MSF dans "[TmpFile].msf"] } set FichierPhylo [CreeLeFichierPhylo $FichierMSF "[TmpFile].ph"] if {$Delete} { file delete -force $FichierMSF } return [NJPlotPH $FichierPhylo] } proc NJPlotPH FichierPhylo { exec njplot $FichierPhylo & return $FichierPhylo } proc CreeLeFichierFonctionsValidees {} { global RepertoireDuGenome global ListeDeBoites if { ! [info exists ListeDeBoites]} { ChargeListeDeBoites } foreach Boite $ListeDeBoites { set Nom [Box $Boite nom] if {[Enterre $Nom]} { continue } set ValiDE [ExtraitInfo $Nom "ValiDE"] set ValiGN [ExtraitInfo $Nom "ValiGN"] set ValiCF [ExtraitInfo $Nom "ValiCF"] if {$ValiDE == "" } { continue } set CF [ClasseFonctionnelle $Nom] set FF [FiabiliteFonction $Nom] if {$FF == ""} { set FF "0" } lappend Liste [format "%3.3d %s %s %3.3d %-15s %s" $CF $Nom $FF $CF $ValiGN $ValiDE] } set Liste [concat $Liste [LesLignesDuFichier "$RepertoireDuGenome/aful/rolefamille"]] set ListeTriee [lsort $Liste] set Liste {} foreach Ligne $ListeTriee { lappend Liste [string range $Ligne 4 end] } Espionne [SauveLesLignes $Liste dans "$RepertoireDuGenome/fiches/fonctionsvalidees"] } proc PyroLike Orga { if {[regexp "paby|phor|pfur|txxx|pkod|psp|pwoe|thyd" $Orga]} { return 1 } return 0 } proc ArkaeaLike Orga { if {[PyroLike $Orga] || \ [regexp "mjan|aful|mthe|aper|ssol|saci|mvan|hsal|hvol|hcut|hhal|damb|dmob|dthe|dsp" $Orga]} { return 1 } return 0 } proc PhyloFolle Nom { global RepertoireDuGenome global PhylosFolles if {[info exists PhylosFolles]} { if {[info exists PhylosFolles($Nom)]} { return [set PhylosFolles($Nom)] } else { return -1 } } set FichierPhylosFolles "$RepertoireDuGenome/fiches/phylosfolles" if {[file exists $FichierPhylosFolles]} { foreach Ligne [LesLignesDuFichier $FichierPhylosFolles] { scan $Ligne "%s %s" Nom Folie set PhylosFolles($Nom) $Folie } return [PhyloFolle $Nom] } set ListeOrgas [Phylon $Nom] if {[llength $ListeOrgas] == 0} { return -1 } foreach Orga $ListeOrgas { if {$Orga == "xxxx" || [PyroLike $Orga]} { continue } if {[ArkaeaLike $Orga]} { return 0 } return 1 } return 0 } proc ChargePhylons {} { global RepertoireDuGenome global Phylons PhylonsOrgaEtDistance if { ! [file exists "$RepertoireDuGenome/fiches/distancesphylo"]} { set Phylons Bidon set PhylonsOrgaEtDistance Bidon return } foreach Ligne [LesLignesDuFichier "$RepertoireDuGenome/fiches/distancesphylo"] { set Liste [split $Ligne " "] set Nom [lindex $Liste 0] set ListeOrgaDistance [lrange $Liste 1 end] set ListeOrgas {} foreach {Orga Distance Access} $ListeOrgaDistance { lappend ListeOrgas $Orga } set Phylons($Nom) $ListeOrgas set PhylonsOrgaEtDistance($Nom) $ListeOrgaDistance } set FichierPhylosFolles "$RepertoireDuGenome/fiches/phylosfolles" if { ! [file exists $FichierPhylosFolles] && \ [OuiOuNon "Dois-je creer le fichier $FichierPhylosFolles ? "]} { foreach Nom [array names Phylons] { lappend ListePhylons "$Nom [PhyloFolle $Nom]" } Espionne [SauveLesLignes $ListePhylons dans $FichierPhylosFolles] } } proc Phylon Nom { global Phylons if { ! [info exists Phylons] } { ChargePhylons } if {[info exists Phylons($Nom)]} { return [set Phylons($Nom)] } return {} } proc PhylonOrgaEtDistance Nom { global Phylons global PhylonsOrgaEtDistance if { ! [info exists Phylons] } { ChargePhylons } if {[info exists PhylonsOrgaEtDistance($Nom)]} { return [set PhylonsOrgaEtDistance($Nom)] } return {} } proc CreeLesFichiersTFAsNUCsAvecBornesDesPABsEtADN {} { global RepertoireDuGenome if { ! [OuiOuNon "Je recree les sequences dans $RepertoireDuGenome"]} { return } foreach Ligne [LesLignesDuFichier "$RepertoireDuGenome/fiches/bornesdespabs"] { ExtraireDe $Ligne Nom Debut Fin Orient if {[file exists "$RepertoireDuGenome/prottfa/$Nom"]} { continue } set SeqNuc [BoutADN $Debut $Fin $Orient] set SeqPro [SeqNucToSeqPro $SeqNuc] set NUC [SequenceFormatTFA $SeqNuc "$Nom $Debut $Fin $Orient $Cut" "nucbrut"] Espionne [Sauve $NUC dans "$RepertoireDuGenome/nuctfa/$Nom"] set TFA [SequenceFormatTFA $SeqPro "$Nom $Debut $Fin $Orient $Cut" "protbrut"] Espionne [Sauve $TFA dans "$RepertoireDuGenome/prottfa/$Nom"] } } proc BornesDeSeraphinVersCasimir {} { global RepertoireDuGenome global ListeDesPABs global ListeDesTRNAs global ListeDesARNs if { ! [regexp "bys" $RepertoireDuGenome]} { FaireLire "Il fallait lancer setgscope bys" exit } ChargeLesPABs set NouvellesBornes {} foreach Boite $ListeDesPABs { set Nom [Box $Boite nom] set Debut [Box $Boite debut] set Fin [Box $Boite fin] set Orient [Box $Boite orient] lappend NouvellesBornes "$Nom [CasimirDu $Debut] [CasimirDu $Fin] $Orient" } Espionne [SauveLesLignes $NouvellesBornes dans "$RepertoireDuGenome/../casimir/fiches/bornesdespabs.arenommer"] ChargeLesTRNAs set NouvellesBornes {} foreach Boite $ListeDesTRNAs { set Nom [Box $Boite nom] set Debut [Box $Boite debut] set Fin [Box $Boite fin] set Orient [Box $Boite orient] lappend NouvellesBornes "$Nom [CasimirDu $Debut] [CasimirDu $Fin] $Orient" } Espionne [SauveLesLignes $NouvellesBornes dans "$RepertoireDuGenome/../casimir/fiches/bornesdestrnas.arenommer"] ChargeLesARNs set NouvellesBornes {} foreach Boite $ListeDesARNs { set Nom [Box $Boite nom] set Debut [Box $Boite debut] set Fin [Box $Boite fin] set Orient [Box $Boite orient] lappend NouvellesBornes "$Nom [CasimirDu $Debut] [CasimirDu $Fin] $Orient" } Espionne [SauveLesLignes $NouvellesBornes dans "$RepertoireDuGenome/../casimir/fiches/bornesdesarns.arenommer"] } proc CasimirDu Ser { global ListeSeraphin ListeCasimir if { ! [info exists ListeSeraphin]} { ChargeSeraphinEtCasimir } set iPrecedent -999999 set jPrecedent -999999 foreach i $ListeSeraphin j $ListeCasimir { if { [expr $iPrecedent <= $Ser] && [expr $Ser < $i] } { return [expr $jPrecedent+$Ser-$iPrecedent] } set iPrecedent $i set jPrecedent $j } return [expr $jPrecedent+$Ser-$iPrecedent] } proc SeraphinDu Cas { global ListeSeraphin ListeCasimir if { ! [info exists ListeSeraphin]} { ChargeSeraphinEtCasimir } set iPrecedent -999999 set jPrecedent -999999 foreach i $ListeSeraphin j $ListeCasimir { if { [expr $jPrecedent <= $Cas] && [expr $Cas < $j] } { return [expr $iPrecedent+$Cas-$jPrecedent] } } return [expr $iPrecedent+$Cas-$jPrecedent] } proc ChargeSeraphinEtCasimir {} { global RepertoireDuGenome global ListeSeraphin ListeCasimir foreach Ligne [LesLignesDuFichier "$RepertoireDuGenome/../bys/erreurssequence.liste"] { if {[regexp "ij" $Ligne]} { continue } scan $Ligne "%s %d %d" iOUj iSer jCas lappend ListeSeraphin $iSer lappend ListeCasimir $jCas } } proc Validation {{Sens "-increasing"}} { global ListeDeBoites if { ! [info exists ListeDeBoites]} { ChargeListeDeBoites } set JeVeuxFaire 1 if { $Sens == "Voir"} { set Sens "-increasing" set JeVeuxFaire 0 } set JeVeuxVoir [expr ! $JeVeuxFaire] foreach Boite [lsort $Sens $ListeDeBoites] { set Nom [Box $Boite nom] if {[FiabiliteFonction $Nom] != 5} { continue } if {$JeVeuxFaire && [ExtraitInfo $Nom "ValiDE"] != "" || \ $JeVeuxVoir && [ExtraitInfo $Nom "ValiDE"] == "" } { continue } puts $Nom continue if { [QueDitAful $Nom] && ! [OuiOuNon "Au suivant ?"] } { break } } } proc MarqueLesErreursDeSequence K { global RepertoireDuGenome set PosY 1 foreach Ligne [LesLignesDuFichier "$RepertoireDuGenome/erreurssequence.liste"] { scan $Ligne "%s %d %d" CodeType PositioTDNnsAncien PositioTDNnsNouveau if {$CodeType == "ij"} { set Couleur "black" ; set Texte "| Substitution en $PositioTDNnsAncien"} if {$CodeType == "i" } { set Couleur "red" ; set Texte "| Deletion en $PositioTDNnsAncien"} if {$CodeType == "j"} { set Couleur "red" ; set Texte "| Insertion en $PositioTDNnsAncien"} $K create text \ $PositioTDNnsNouveau [expr ([incr PosY]%3 + 1)*12 - 60] \ -text $Texte \ -anchor w \ -font {Courier 12} \ -fill $Couleur } } proc SimilitudeSurUneZone {i j} { global ADN CDN set Score 0 set l $j for {set k $i} {$k < [expr $i+10]} {incr k} { if {[string index $ADN $k] == [string index $CDN $l]} { incr Score } incr l } return $Score } proc PointeLesErreursDeSequence {} { global RepertoireDuGenome global ADN CDN JeMeSignale "Patience" set f [open "$RepertoireDuGenome/adn" "r"] gets $f ADN close $f set f [open "$RepertoireDuGenome/../casimir/adn" "r"] gets $f CDN close $f JeMeSignale "FinPatience" set LongueurSeraphin [string length $ADN] set LongueurCasimir [string length $CDN] set i 1 set j 1 while 1 { if {[string index $ADN $i] == [string index $CDN $j]} { if {$i >= $LongueurSeraphin} { break } incr i incr j continue } set MeilleurScoreEnK 0 for {set K $i} {$K < [expr $i+10]} {incr K} { set MeilleurScoreEnK [Maxi $MeilleurScoreEnK [SimilitudeSurUneZone $K $j]] set MeilleurK($MeilleurScoreEnK) $K } set MeilleurScoreEnL 0 for {set L $j} {$L < [expr $j+10]} {incr L} { set MeilleurScoreEnL [Maxi $MeilleurScoreEnL [SimilitudeSurUneZone $i $L]] set MeilleurL($MeilleurScoreEnL) $L } puts "[string range $ADN [expr $i] [expr $i+30]] $i" puts "[string range $CDN [expr $j] [expr $j+30]] $j" puts "[set MeilleurK($MeilleurScoreEnK)] $MeilleurScoreEnK" puts "[set MeilleurL($MeilleurScoreEnL)] $MeilleurScoreEnL" if {$MeilleurScoreEnK==$MeilleurScoreEnL} { if {1 && [OuiOuNon "Je saute les 2 ?"]} { incr i; incr j; lappend Acte "ij $i $j"; continue} } if {$MeilleurScoreEnK>$MeilleurScoreEnL} { if {1 && [OuiOuNon "Je saute le 1er ?"]} { incr i; lappend Acte "i $i $j"; continue} } if {$MeilleurScoreEnK<$MeilleurScoreEnL} { if {1 && [OuiOuNon "Je saute le 2nd ?"]} { incr j; lappend Acte " j $i $j"; continue} } if {[OuiOuNon "Alors je saute les 2 ?"]} { incr i; incr j; lappend Acte "ij $i $j"; continue} if {[OuiOuNon "Alors je saute le 1er ?"]} { incr i; lappend Acte "i $i $j"; continue} if {[OuiOuNon "Alors je saute le 2nd ?"]} { incr j; lappend Acte " j $i $j"; continue} } Espionne [SauveLesLignes $Acte dans "$RepertoireDuGenome/erreurssequence.liste.nouveau"] } proc CompareLesExpectsDesSegments {TexteA TexteB} { scan $TexteA "%s %s %s %s %s %s %s %f" Trou Sens Frame BanqueId Debut Fin Long a scan $TexteB "%s %s %s %s %s %s %s %f" Trou Sens Frame BanqueId Debut Fin Long b if {[expr double($a) < double($b)]} { return -1} if {[expr double($a) == double($b)]} { return 0} if {[expr double($a) > double($b)]} { return 1} } proc CreeLeFichierFonctionsDecouvertes {} { global RepertoireDuGenome global ListeDeBoites if { ! [info exists ListeDeBoites]} { ChargeListeDeBoites } foreach Boite $ListeDeBoites { set Nom [Box $Boite nom] set AF [NomDuMeilleurAful $Nom] if {$AF == ""} { continue } scan [MeilleurAful $Nom] "%s %s %f %s" AF AFok PN Raison if { ! $AFok} { continue } set TexteAF [lindex [DonneesAful $AF] 0] if {$TexteAF == "" } { set RoFa " 00" set TexteAF "$AF $RoFa sans reference fonctionnelle" } else { scan $TexteAF "%s %d" AF RoFa } set FF [FiabiliteFonction $Nom] if {$FF == ""} { set FF "0" } lappend Liste [format "%3.3d %s %s %7s %s" $RoFa $Nom $FF $PN $TexteAF] } set Liste [concat $Liste [LesLignesDuFichier "$RepertoireDuGenome/aful/rolefamille"]] set ListeTriee [lsort $Liste] set Liste {} foreach Ligne $ListeTriee { lappend Liste [string range $Ligne 4 end] } Espionne [SauveLesLignes $Liste dans "$RepertoireDuGenome/fiches/fonctionsdecouvertes"] } proc TexteOMO {NomVoulu {Format "Court"}} { global RepertoireDuGenome global TexteOMO if { ! [YaPABdans $NomVoulu]} { return "" } if { ! [info exists TexteOMO]} { set FichierOMO "$RepertoireDuGenome/fiches/organismesayantmemeoperon" if { ! [ file exists $FichierOMO]} { set TexteOMO Bidon return } foreach Ligne [LesLignesDuFichier $FichierOMO] { set LesMots [split $Ligne " "] set Nom [lindex $LesMots 0] set Voisin [lindex $LesMots 1] set iOMO [string length "$Nom $Voisin xxxx"] set sOMO [string trim [string range $Ligne $iOMO end]] set Texte "" for {set i 0} {$i < [string length $sOMO]} {incr i 5} { set C [string index $sOMO $i] if { $C != " " } { append Texte $C } else { append Texte "." } } set TexteOMO($Nom,Court) $Texte set TexteOMO($Nom,Long) $Ligne set TexteOMO($Nom,Avant) $Voisin set TexteOMO($Voisin,Apres) $Nom } } if { ! [info exists TexteOMO($NomVoulu,$Format)]} { return ""} return [set TexteOMO($NomVoulu,$Format)] } proc MiseAJourDesPABCrees {} { global RepertoireDuGenome foreach Trou [LesLignesDuFichier "$RepertoireDuGenome/creepab3.liste"] { set CreePABDejaVu 0 regsub "TROU" $Trou "[PreFixe]" Nom set Nom [string range $Nom 0 6] set InfoDuPAB {} lappend InfoDuPAB "Nom: $Nom" foreach Ligne [LesLignesDuFichier "$RepertoireDuGenome/infos/$Trou"] { if {[regexp "^Nom:" $Ligne]} { continue } if {[regexp ": $" $Ligne]} { continue } if {[regexp "^CreePAB:" $Ligne]} { if {$CreePABDejaVu} { FaireLire "$Trou contient plusieurs CreePAB.\nCreer infos +1000 manuellement, avec emacs." } set CreePABDejaVu 1 regsub "CreePAB" $Ligne "DuTrou" Ligne append Ligne " du $Trou" } lappend InfoDuPAB $Ligne } Espionne [SauveLesLignes $InfoDuPAB dans "$RepertoireDuGenome/infos/$Nom"] } } proc InformeLesMetsCorriges {} { global ListeDeBoites global RepertoireDuGenome global InformeSansDemander Wup "Je lis le fichier metscorriges qui n'est que les 1eres lignes" Wup " des fichiers gcgs contenant 'Cut ...'" set InformeSansDemander 1 foreach Ligne [LesLignesDuFichier "$RepertoireDuGenome/fiches/metscorriges"] { set Nom [lindex [split $Ligne " "] 0] set iCut [string first "Cut" $Ligne] # set iFin [expr [string first "Length" $Ligne]-1] set Zone [string range $Ligne $iCut end] set Append "NewStartCodon: $Zone" Informe $Nom $Append Espionne "\n$Nom\n$Append" } } proc LesOffsetsDePfur {} { global RepertoireDuGenome Wup "Il y a une sequence non utilisee, je la saute." set Offset 0 foreach Ligne [LesLignesDuFichier "$RepertoireDuGenome/db/pfur"] { if {[regexp ">" $Ligne]} { scan $Ligne ">%s" Courant if {[regexp "MM4to38\-10429" $Courant]} { puts $Ligne; continue } puts "$Courant $Offset" } else { if {[regexp "MM4to38\-10429" $Courant]} { puts $Ligne; continue } incr Offset [string length $Ligne] } } } proc DessineOrgaEtSesPlaces {{Fichier ""} {PourGif ""}} { global RepertoireDuGenome global LesOrdresPourGif global LigneOriginePhylo if {$Fichier==""} { set Fichier "$RepertoireDuGenome/fiches/orgaetsesplaces.tout_le_monde" } set LesLignes [LesLignesDuFichier $Fichier] set n [llength $LesLignes] set Titre "PhyloRank" set LC 25 set HL 20 set nColonnes 13 set nLignes $n set Fonte {Courier 15} set TailleTexteOrga [font measure $Fonte [string repeat "M" 26]] set EspacementHorizontal 15 set EspaceVertical 40 set PosYEntete [expr $EspaceVertical/2] set DecalageDesRectangles [expr $EspacementHorizontal + $TailleTexteOrga + $EspacementHorizontal] set LargeurVoulue [expr $DecalageDesRectangles + $nColonnes*$LC + $EspacementHorizontal] set HauteurVoulue [expr $EspaceVertical + ($nLignes+2)*$HL] if {$PourGif != ""} { set PourGif 1 set Canvas NeRienFaire set Bind NeRienFaire set Pack NeRienFaire set Fram NeRienFaire set Button NeRienFaire set Scrollbar NeRienFaire set Grid NeRienFaire set FonctionRejetteLaBoite "RejetteLaBoite" set LesOrdresPourGif {} set w "PourGif" set K "OrdrePourGif" } else { set PourGif 0 set Canvas canvas set Bind bind set Pack pack set Fram frame set Button button set Scrollbar scrollbar set Grid grid set FonctionRejetteLaBoite "NeRejettePasLaBoite" set K [UnCanva $LargeurVoulue $HauteurVoulue $LargeurVoulue $HauteurVoulue] regsub ".canvas" $K "" w wm title $w "$Titre" wm iconname $w "$Titre" } $K configure -background "lightgrey" $K create rectangle 0 0 $LargeurVoulue $HauteurVoulue -fill grey -tags [list "Cadre"] $K create text \ [expr $DecalageDesRectangles/2] [expr $EspaceVertical/2] \ -text $Titre \ -font {Courier 12} \ -anchor c set MettreEntete 1 set iEmeOrga 0 if {[info exists ValeurMaxiDuTableau]} { unset ValeurMaxiDuTableau } foreach Ligne $LesLignes { if { ! [regexp -nocase {[a-z]} $Ligne] } { continue } if {[regexp "^#" $Ligne] } { continue } scan $Ligne "%s" Orga set Complet [Glossaire $Orga Complet] if { $Orga == "xxxx" } { continue } set Phylum [PhylumDuGenome $Complet] if {$Phylum=="X"} { set Phylum [PhylumDuOrganisme $Complet] } set Couleur "black" if {$Phylum=="B"} { set Couleur "darkgreen" } if {$Phylum=="A"} { set Couleur "blue" } if {$Phylum=="E"} { set Couleur "red" } incr iEmeOrga set LigneOriginePhylo($K,$Orga) $Ligne Espionne $Ligne set TexteOrga [string range $Complet 0 25] $K create text \ $EspacementHorizontal [expr $EspaceVertical + $iEmeOrga*$HL] \ -text $TexteOrga \ -anchor w \ -font $Fonte \ -tags [list "$Complet" "$Orga" "TexteOrga" "Ligne_$iEmeOrga"] \ -fill $Couleur Wup "Attention ces valeurs doivent correspondre a CreeLaTable" set OffsetColonne 18 set ValeurVide " " set LargeurValeur [string length $ValeurVide] set Reste [string range $Ligne $OffsetColonne end] set Valeurs $Reste while {[regexp " " $Valeurs]} { regsub -all " " $Valeurs " " Valeurs } set ValeurMaxiDeLaLigne [MaxiDeLaListe [lrange [split [string trim $Valeurs] " "] 0 end-1]] set Colonne 0 set Rang 0 while {[regexp {[0-9]} $Reste]} { set SPP [string range $Reste 0 [expr $LargeurValeur-1]] set Reste [string range $Reste [expr $LargeurValeur+1] end] incr Colonne incr Rang if {$MettreEntete} { set PosX [expr $DecalageDesRectangles + $Colonne*$LC] set Texte $Rang $K create text \ $PosX $PosYEntete \ -width 20 \ -text $Texte \ -font {Courier 6} \ -anchor n \ -fill "black" } if { $SPP == $ValeurVide} { continue } set PP 0 scan $SPP "%d" PP if {$PP==0} { continue } if { ! [info exists ValeurMaxiDuTableau]} { set ValeurMaxiDuTableau $PP } if {$PP>$ValeurMaxiDuTableau} { set PP $ValeurMaxiDuTableau } set DuTableau 0 if {$DuTableau} { set p [expr (1.*$PP)/$ValeurMaxiDuTableau] } else { set p [expr (1.*$PP)/$ValeurMaxiDeLaLigne] } if {[regexp {[0-9]} $Reste]} { set Couleur [Nuance [expr $p] 0.5 0.1] } else { set Couleur "lightgrey" } if {$PourGif} { set LesTags [list "WebClic" "gscope:AfficheLesConcernesDeCeRang \{$Complet\} $SPP $Rang $Fichier"] } else { set LesTagsR [list "$Complet" "$SPP" "$Rang" "Affichable" "Ligne_$iEmeOrga"] set LesTagsT [list "$Complet" "$SPP" "$Rang" "TexteRang" "Affichable" "Ligne_$iEmeOrga"] } set PosX [expr $DecalageDesRectangles + $Colonne*$LC] $K create rect \ [expr $PosX-$LC/3] [expr $EspaceVertical + $iEmeOrga*$HL-$HL/3] \ [expr $PosX+$LC/3] [expr $EspaceVertical + $iEmeOrga*$HL+$HL/3] \ -tags $LesTagsR \ -outline $Couleur \ -fill $Couleur $K create text \ [expr $PosX+$LC/3] [expr $EspaceVertical + $iEmeOrga*$HL] \ -text $PP \ -font {Courier 6} \ -anchor e \ -tags $LesTagsT \ -fill "black" } set MettreEntete 0 } $K configure -height [Mini 800 [expr ($iEmeOrga+1)*$HL]] set Boutons $w.buttons $Button $Boutons.toggle -text "Hide both/Orga/Rank\nSave order" $Bind $Boutons.toggle <1> "ToggleTextePhylo $K Both" $Bind $Boutons.toggle <2> "ToggleTextePhylo $K Orga" $Bind $Boutons.toggle <3> "ToggleTextePhylo $K Rank" $Bind $Boutons.toggle "SavePhylOrder $K $Fichier" $Pack $Boutons.toggle -side left -expand 1 # $Pack $K $K bind "Affichable" <1> "AfficheLesConcernesDeCeRang $K %x %y $Fichier" $K bind all "ChangeOrdrePhylo $K %x %y $HL -1 $iEmeOrga" $K bind all "ChangeOrdrePhylo $K %x %y $HL 1 $iEmeOrga" if {$PourGif } { return $LesOrdresPourGif } if { 0 && [PourWscope] } { return $w } else { return $K } } proc SavePhylOrder {K OrgaEtSesPlaces} { global LigneOriginePhylo set PossibleFichier "${OrgaEtSesPlaces}_2" while {1} { set NouveauOrgaEtSesPlaces [FichierPourSaveAs $PossibleFichier] if {$NouveauOrgaEtSesPlaces==""} { return "" } if {[regexp "orgaetsesplaces" $NouveauOrgaEtSesPlaces]} { break } } regsub "orgaetsesplaces" $OrgaEtSesPlaces "pabretenus" PabsRetenus regsub "orgaetsesplaces" $NouveauOrgaEtSesPlaces "pabretenus" NouveauPabsRetenus foreach Id [$K find withtag "TexteOrga"] { set LesTags [$K gettags $Id] set iLigne [lsearch -regexp $LesTags "Ligne_"] set Ligne [lindex $LesTags $iLigne] set i [IntegerApres "Ligne_" dans $Ligne] lappend Liste "$i [lindex $LesTags 1]" } set ListeTriee [lsort -command CompareLesIntegersEnDebut $Liste] foreach Couple $ListeTriee { regsub {[0-9]+ +} $Couple "" Orga lappend Sortie [set LigneOriginePhylo($K,$Orga)] } File copy $PabsRetenus $NouveauPabsRetenus return [SauveLesLignes $Sortie dans $NouveauOrgaEtSesPlaces] } proc ToggleTextePhylo {K {Qui "Both"}} { global ToggleTextePhylo if { ! [info exists ToggleTextePhylo($K)]} { set ToggleTextePhylo($K) "raise" } set Etat [set ToggleTextePhylo($K)] if {$Etat=="raise"} { set Etat "lower" } else { set Etat "raise" } if {$Qui=="Both" || $Qui=="Orga"} { $K $Etat "TexteOrga" } if {$Qui=="Both" || $Qui=="Rank"} { $K $Etat "TexteRang" } set ToggleTextePhylo($K) $Etat return $Etat } proc ChangeOrdrePhylo {K x y HL Sens nOrgas} { set Id [$K find withtag current] set LesTags [$K gettags $Id] set iLigne [lsearch -regexp $LesTags "Ligne_"] set Ligne [lindex $LesTags $iLigne] set i [IntegerApres "Ligne_" dans $Ligne] set d [expr $i+$Sens] if {[expr $d<1] || [expr $d>$nOrgas]} { return $i } $K move $Ligne 0 [expr $Sens*$HL] set Autre "Ligne_[expr $i+$Sens]" $K move $Autre 0 [expr -$Sens*$HL] set LesUns [$K find withtag $Ligne] set LesAutres [$K find withtag $Autre] foreach Id $LesUns { set LesTags [$K gettags $Id] set i [lsearch -exact $LesTags $Ligne] set LesNouveaux [lreplace $LesTags $i $i $Autre] $K itemconfigure $Id -tags $LesNouveaux } foreach Id $LesAutres { set LesTags [$K gettags $Id] set i [lsearch -exact $LesTags $Autre] set LesNouveaux [lreplace $LesTags $i $i $Ligne] $K itemconfigure $Id -tags $LesNouveaux } return $d } proc ComptonsLesATGC {} { global ADN TDN RAC if { ! [info exists ADN]} { ChargeADNetTDNetRAC } set l [string length $ADN] set nA 0 set nT 0 set nG 0 set nC 0 for {set i 1} {$i < $l} {incr i} { set c [string index $ADN $i] if { $c == "A" } { incr nA } if { $c == "T" } { incr nT } if { $c == "G" } { incr nG } if { $c == "C" } { incr nC } } set l [expr $nA + $nT +$nG + $nC] puts " $l bases" puts " " puts " A $nA [format %5.2f [expr (100.*$nA)/$l]]%" puts " T $nT [format %5.2f [expr (100.*$nT)/$l]]%" puts " G $nG [format %5.2f [expr (100.*$nG)/$l]]%" puts " C $nC [format %5.2f [expr (100.*$nC)/$l]]%" puts " " puts "AT [expr $nA+$nT] [format %5.2f [expr (100.*($nA+$nT))/$l]]%" puts "GC [expr $nG+$nC] [format %5.2f [expr (100.*($nG+$nC))/$l]]%" } proc Comptons {} { global ListeDeBoites if { ! [info exists ListeDeBoites]} { ChargeListeDeBoites } set Compteur(Total) 0 set Compteur(FF) 0 set Compteur(FF0) 0 set Compteur(FF1) 0 set Compteur(FF3) 0 set Compteur(FF5) 0 set Compteur(FF7) 0 set Compteur(FF9) 0 set Compteur(Enterres) 0 set Compteur(Decedes) 0 set Compteur(hTotal) 0 set Compteur(hFF) 0 set Compteur(hFF0) 0 set Compteur(hFF1) 0 set Compteur(hFF3) 0 set Compteur(hFF5) 0 set Compteur(hFF7) 0 set Compteur(hFF9) 0 set Compteur(hEnterres) 0 set Compteur(hDecedes) 0 set Compteur(fTotal) 0 set Compteur(fFF) 0 set Compteur(fFF0) 0 set Compteur(fFF1) 0 set Compteur(fFF3) 0 set Compteur(fFF5) 0 set Compteur(fFF7) 0 set Compteur(fFF9) 0 set Compteur(fEnterres) 0 set Compteur(fDecedes) 0 foreach Boite $ListeDeBoites { set Nom [Box $Boite nom] if { ! [YaPABdans $Nom]} { continue } set FFx "FF[FiabiliteFonction $Nom]" incr Compteur(Total) incr Compteur($FFx) if {[Enterre $Nom]} { incr Compteur(Enterres) } if {[Decede $Nom]} { incr Compteur(Decedes) } if {[Enterre $Nom] && [ExisteOrthologueDans "phor" $Nom]} { incr Compteur(hEnterres) } if {[Enterre $Nom] && [ExisteOrthologueDans "pfur" $Nom]} { incr Compteur(fEnterres) } if {[Decede $Nom] && [ExisteOrthologueDans "phor" $Nom]} { incr Compteur(hDecedes) } if {[Decede $Nom] && [ExisteOrthologueDans "pfur" $Nom]} { incr Compteur(fDecedes) } if {[ExisteOrthologueDans "phor" $Nom]} { incr Compteur(hTotal); incr Compteur(h$FFx)} if {[ExisteOrthologueDans "pfur" $Nom]} { incr Compteur(fTotal); incr Compteur(f$FFx)} } foreach Valeur [lsort [array names Compteur]] { puts [format "%10s %d" $Valeur [set Compteur($Valeur)]] } } proc StatistiquesSurLesProteines {{QuelleListe ""} {EnContinu ""}} { if {$QuelleListe==""} { set QuelleListe ListeDesPABs } set EnContinu [string equal -nocase "Continu" $EnContinu] if {[regexp "^ListeDes" $QuelleListe]} { set Liste [eval $QuelleListe] } else { set Liste $QuelleListe } set nTotal 0 foreach Nom $Liste { set Debut [Box $Nom debut] set Fin [Box $Nom fin] set Long [expr $Fin - $Debut +1] if { ! [info exists Compteur($Long)]} { set Compteur($Long) 0 } incr Compteur($Long) incr nTotal } set LesLongueurs [lsort -integer [array names Compteur]] set Precedent 0 foreach Long $LesLongueurs { set Cumul($Long) [expr $Precedent + [set Compteur($Long)]] set Precedent [set Cumul($Long)] } if {$EnContinu} { set LesLongueursAVoir [NombresEntre [lindex $LesLongueurs 0] [lindex $LesLongueurs end]] } else { set LesLongueursAVoir $LesLongueurs } foreach Long $LesLongueursAVoir { if {[info exists Compteur($Long)]} { set N [set Compteur($Long)] set C [set Cumul($Long)] } else { set N 0 } set S [expr ($C/18)%80] puts [format "%5d %5d %5d %s" $Long $N $C [string repeat "*" $S]] } return [list [array get Compteur] [array get Cumul]] } proc CreeLeFichierDistancesPhylo {} { global RepertoireDuGenome global ListeDeBoites global ListeDesPABs set TenirCompteDeFiabiliteFonction 0 set FichierDistancesPhylo "$RepertoireDuGenome/fiches/distancesphylo" if {[file exists $FichierDistancesPhylo]} { if { ! [OuiOuNon "$FichierDistancesPhylo\n already exists. Do I replace it ?"]} { return "" } } if { ! [info exists ListeDeBoites]} { ChargeListeDeBoites } foreach Nom [ListeDesPABs] { if {$TenirCompteDeFiabiliteFonction && [FiabiliteFonction $Nom] < 3 } { continue } set Liste [ListeTrieeDesDistancesPhylos $Nom] if {[llength $Liste] > 0} { set NomListe "$Nom [join $Liste " "]" lappend ListeDesNomListe $NomListe } } return [SauveLesLignes $ListeDesNomListe dans $FichierDistancesPhylo] } proc RemplaceAccessParOrganismeDansFichierPhyloPourTous {{Nom ""}} { if {$Nom==""} { set Liste [ListeDesPABs] } else { set Liste [list $Nom] } foreach Nom $Liste { set FiPhy "[RepertoireDuGenome]/phylos/$Nom" set FiPhyOrg "[RepertoireDuGenome]/phylosOrg/$Nom" if {[file exists $FiPhyOrg]} { continue } if { ! [file exists $FiPhy]} { continue } set BonFiPhyOrg [RemplaceAccessParOrganismeDansFichierPhylo $Nom] Espionne $BonFiPhyOrg } } proc RemplaceAccessParOrganismeDansFichierPhylo {Nom {Out ""}} { if {[regexp "/" $Nom]} { set Fichier $Nom if {$Out==""} { regsub -nocase {(.ph|)$} $Fichier "-org&" FichierOut } else { set FichierOut $Out } } else { set Fichier "[RepertoireDuGenome]/phylos/$Nom" if {$Out==""} { set Rep "[RepertoireDuGenome]/phylosOrg" if { ! [file exists $Rep]} { file mkdir $Rep } set FichierOut "$Rep/$Nom" } else { set FichierOut $Out } } if { ! [file exists $Fichier]} { return "" } set i 0 set Texte [ContenuDuFichier $Fichier] set LesAccess {} set LesIndices {} set N 0 while {[regexp -start $i -indices {[^\n\)\(\,\:]+\:} $Texte Indices]} { if {[incr N]>99999} { break } scan $Indices "%d %d" D F set i $F set Access [string range $Texte $D [expr $F -1]] regsub -nocase "^VARSPLIC_" $Access "VARSPLIC:" Access lappend LesAccess $Access lappend LesIndices $Indices } set Format "Demi" set LesAccessOrga [LesOrgasDesAccess $LesAccess $Format] set Inconnu [Glossaire "Inconnu inconnu" $Format] set LesAO [RetourneLaListe $LesAccessOrga] set LesIn [RetourneLaListe $LesIndices] foreach AO $LesAO Indices $LesIn { scan $AO "%s" Access set Orga [StringSuivant "$Access " dans $AO] if {$Orga=="" || $Orga==$Inconnu} { set Orga $Access } scan $Indices "%d %d" D F incr F -1 Espionne "$Access $Orga $D $F" set Texte [string replace $Texte $D $F $Orga] } if {$Out=="GetText"} { return $Texte } return [Sauve $Texte dans $FichierOut] } proc CreeLeFichierPhylo {FichierMSF FichierPhylo} { if {[catch {exec clustalw $FichierMSF -tree -outtreefile=$FichierPhylo} Message]} { return "Erreur in CreeLeFichierPhylo\n$Message" } return $FichierPhylo } proc CreeLesFichiersPhylos {{Nom ""}} { set Repertoire "[RepertoireDuGenome]/phylos" if { ! [file exists $Repertoire]} { File mkdir $Repertoire } if { $Nom != ""} { set ListeATester [list $Nom] } else { set ListeATester [ListeDesPABs] } foreach Nom $ListeATester { set FichierPhylo "[RepertoireDuGenome]/phylos/$Nom" if {[file exists $FichierPhylo]} { continue } set FichierMSF "[RepertoireDuGenome]/msf/$Nom" if { ! [file exists $FichierMSF]} { continue } set Premiere [PremiereLigneDuFichier $FichierMSF] if {$Premiere==""} { continue } if {[regexp "Clustalw inutile" $Premiere]} { continue } if {[regexp "NoSequencesToAlign" $Premiere]} { continue } Espionne [CreeLeFichierPhylo $FichierMSF $FichierPhylo] } return } proc CompleteLeFichierErreurs Fichier { global ListeDeBoites if { ! [info exists ListeDeBoites]} { ChargeListeDeBoites } foreach Ligne [LesLignesDuFichier $Fichier] { set Nom "" if {[YaPABenDebutDe $Ligne]} { set Nom [string range $Ligne 0 6] } if {[regexp {^TROU[0-9][0-9]+[A-FN]} $Ligne]} { set Nom [string range $Ligne 0 8] } if { $Nom != "" } { set Ligne [format "%8.8s %8.8s %s" [Box $Nom debut] [Box $Nom fin] $Ligne] } Espionne $Ligne } } proc EstUneFeuille Arbre { return [expr [llength $Arbre] == 1] } proc NomDeLaFeuille Arbre { return [lindex $Arbre 0] } proc CetteFeuilleEstLaCible Arbre { global Cible if {$Cible == [NomDeLaFeuille $Arbre]} { return 1 } return 0 } proc Dedouble {Arbre aG ax aD ay} { upvar $aG G upvar $ax x upvar $aD D upvar $ay y if {[llength $Arbre] == 3} { set Arbre [list \ [lindex $Arbre 0] \ [lindex $Arbre 2] \ [lindex $Arbre 1] \ [lindex $Arbre 2] \ ] } set G [lindex $Arbre 0] set x [lindex $Arbre 1] set D [lindex $Arbre 2] set y [lindex $Arbre 3] } proc AppendEtRetourneDistance {Arbre Distance} { global ListeDistanceDeChaqueFeuille global MiniOuSomme JeMeSignale if { $Distance == "Inconnue" } { if {[EstUneFeuille $Arbre]} { if {[CetteFeuilleEstLaCible $Arbre]} { if {$MiniOuSomme == "Mini"} { set Distance 9999999. } else { set Distance 0.0 } return $Distance } else { return "Inconnue" } } else { Dedouble $Arbre G x D y set RetourG [AppendEtRetourneDistance $G "Inconnue"] if { $RetourG != "Inconnue"} { if {$MiniOuSomme == "Mini"} { set Dis [Mini $RetourG [Mini $x $y]] } else { set Dis [expr $RetourG+$x+$y] } AppendEtRetourneDistance $D $Dis if {$MiniOuSomme == "Mini"} { set Dis [Mini $RetourG $x] } else { set Dis [expr $RetourG+$x] } return $Dis } set RetourD [AppendEtRetourneDistance $D "Inconnue"] if { $RetourD != "Inconnue"} { if {$MiniOuSomme == "Mini"} { set Dis [Mini $RetourD [Mini $x $y]] } else { set Dis [expr $RetourD+$y+$x] } AppendEtRetourneDistance $G $Dis if {$MiniOuSomme == "Mini"} { set Dis [Mini $RetourD $y] } else { set Dis [expr $RetourD+$y] } return $Dis } return "Inconnue" } } else { if {[EstUneFeuille $Arbre]} { lappend ListeDistanceDeChaqueFeuille "[NomDeLaFeuille $Arbre] $Distance" return $Distance } else { Dedouble $Arbre G x D y if {$MiniOuSomme == "Mini"} { set Dis [Mini $Distance $x] } else { set Dis [expr $Distance+$x] } AppendEtRetourneDistance $G $Dis if {$MiniOuSomme == "Mini"} { set Dis [Mini $Distance $y] } else { set Dis [expr $Distance+$y] } AppendEtRetourneDistance $D $Dis } } } proc Boo Fichier { Espionne [ArbreBootstrapEnListe [ContenuDuFichier $Fichier]] exit } proc ArbreBootstrapEnListeOld {TextePH} { regsub -all "\n" $TextePH "" t regsub -all {[0-9]\.[0-9]*} $t "" t regsub -all {[\]]} $t "" t regsub -all {[\[]} $t "" t regsub -all {\:\)} $t ":9999.\)" t regsub -all {\(} $t {[list } t regsub -all "," $t " " t regsub -all ":" $t " " t regsub -all {\)} $t {]} t regsub -all {;} $t "" t eval set Arbre $t if {[llength $Arbre] == 6} { set Arbre [list [lrange $Arbre 0 3] 0.0 [lindex $Arbre 4] [lindex $Arbre 5]] } return $Arbre } proc ArbreBootstrapEnListe TextePH { regsub -all "\n" $TextePH "" t regsub -all {\:[0-9]\.[0-9]*} $t ":" t regsub -all {[\]\[]} $t "" t regsub -all {\(} $t {[list } t regsub -all "," $t " " t regsub -all ":," $t ":" t regsub -all {:\)} $t ":" t regsub -all ":" $t " " t regsub -all {\)} $t {]} t regsub -all {;} $t "" t exit eval set Arbre $t if {[llength $Arbre] == 4} { set Arbre [list \ [list [lindex $Arbre 0] [lindex $Arbre 1] [lindex $Arbre 3]] \ [lindex $Arbre 2] \ [lindex $Arbre 3]] } return $Arbre } proc AfficheArbre Arbre { global AfficheArbreIndent if {[EstUneFeuille $Arbre]} { Espionne "[string repeat " " $AfficheArbreIndent]+ $Arbre" return } set A1 [lindex $Arbre 0] set D1 [lindex $Arbre 1] set A2 [lindex $Arbre 2] set D2 [lindex $Arbre 3] Espionne "[string repeat " " $AfficheArbreIndent]+ $D1" incr AfficheArbreIndent AfficheArbre $A1 incr AfficheArbreIndent -1 Espionne "[string repeat " " $AfficheArbreIndent]+ $D2" incr AfficheArbreIndent AfficheArbre $A2 incr AfficheArbreIndent -1 } proc TestArbreEnListe {{args ""}} { global AfficheArbreIndent set AfficheArbreIndent 0 if {$args != ""} {set Fic $args} {set Fic "/genomics/link/ARP/phylos/ARP47"} set Arbre [ArbreEnListe [ContenuDuFichier $Fic]] AfficheArbre $Arbre exit } proc ArbreEnListe TextePH { regsub -all "\n" $TextePH "" t regsub -all {\(} $t {[list } t regsub -all "," $t " " t regsub -all ":" $t " " t regsub -all {\)} $t {]} t regsub -all {;} $t "" t eval set Arbre $t if {[llength $Arbre] == 6} { set Arbre [list [lrange $Arbre 0 3] 0.0 [lindex $Arbre 4] [lindex $Arbre 5]] } return $Arbre } proc ReBaptiseLaSequenceTFA {Sequence NomDeBapteme} { Wup "On remplace la premiere ligne." set ListeDesLignes [split $Sequence "\n"] set PremiereLigne ">$NomDeBapteme" return [join [lreplace $ListeDesLignes 0 0 $PremiereLigne] "\n"] } proc ReBaptiseLaSequenceGCG {Sequence NomDeBapteme} { Wup "On remplace le premier mot de la ligne des '..'" Wup "MAis attention avant c'etait autrement ..." set ListeDesLignes [split $Sequence "\n"] set iPP [lsearch -regexp $ListeDesLignes {\.\.}] if {$iPP<0} { FaireLire "$Sequence is not in GCG format." ; return $Sequence } set LignePP [lindex $ListeDesLignes $iPP] scan $LignePP "%s" AncienNom regsub "$AncienNom" $LignePP "$NomDeBapteme " BonneLignePP return [join [lreplace $ListeDesLignes $iPP $iPP $BonneLignePP] "\n"] } proc PrrpDesMSF {} { global RepertoireDuGenome global ListeDeBoites if { ! [info exists ListeDeBoites] } { ChargeListeDeBoites } foreach Boite $ListeDeBoites { set Nom [Box $Boite nom] if { [regexp {[5-9]} [FiabiliteFonction $Nom]] } { set FichierPrrp "$RepertoireDuGenome/prrp/$Nom" if {[file exists $FichierPrrp]} { continue } set FichierClustalw "$RepertoireDuGenome/clustalw/$Nom" if {[file exists $FichierClustalw]} { PrrpDuMSF $FichierClustalw } } } } proc PrrpDuMSF FichierMSF { global RepertoireDuGenome set DirDesPrrp "$RepertoireDuGenome/prrp" if {[YaPABdans $FichierMSF]} { set Nom [file tail $FichierMSF] } DecortiqueUnMSF $FichierMSF LesSequencesDansLOrdre Sequences foreach NomSeq $LesSequencesDansLOrdre { set Sequence [set Sequences($NomSeq)] set NomFichier "$NomSeq[NomDe ""]" lappend ListeDeFichiers [Sauve [TexteBrutToGCG $Sequence $NomFichier] dans $NomFichier] } set MSF [AlignePar "prrp" [join $ListeDeFichiers "\n"] "Interactif" $Nom] File rename $MSF "$DirDesPrrp/$Nom" } proc RepereNucOuBox {Ca K} { if {[YaPABouTROUouTRNAouARNenDebutDe $Ca]} { return [RepereBox $Ca $K] } set Nar [Narcisse $Ca] if {[YaPABouTROUouTRNAouARNenDebutDe $Nar]} { return [RepereBox $Nar $K] } if { ! [regexp {^[0-9]*$} $Ca]} { return [RepereBox $Ca $K] } if {[regexp {^[0-9]{,6}$} $Ca]} { return [RepereBox [Prefixe]$Ca $K] } return [RepereNuc $Ca $K] } proc RepereNuc {Position K} { global RepertoireDuGenome global ScrollRectangleOriginal IdScrollRectangle scan $Position "%s" Position if { ! [regexp {^[0-9]+$} $Position]} {return ""} if {[regexp "rond" $K]} { Aiguille "$Position" "black" $K "RepereBox" $Position return $K } scan "[$K coords [set IdScrollRectangle($K)]]" "%f %f %f %f" xMin yMin xMax yMax scan "[set ScrollRectangleOriginal($K)]" "%f %f %f %f" xMinO yMinO xMaxO yMaxO set Fraction [expr ($Position-$xMinO)/($xMaxO-$xMinO)] $K xview moveto $Fraction if {$K!="OrdrePourGif"} { ShowNuc $K 0 20 "Point" $Position } $K xview scroll -5 units if { $K=="OrdrePourGif"} { return "Fraction $Fraction" } return $K } proc QuiEstLa {DebutSeq FinSeq Banque} { global ListeDeBoites global AQuiEstCeDebut global AQuiEstCetteFin global LesDebuts global LesFins global LesDebutsTries global LesFinsTries set OrientSeq "F" if {[expr $DebutSeq > $FinSeq]} { set Toto $DebutSeq set DebutSeq $FinSeq set FinSeq $Toto set OrientSeq "R" } if {$Banque == "phor"} { return "Pour Phor faut attendre" } if { $Banque == "paby" } { if { ! [info exists AQuiEstCeDebut]} { if { ! [info exists ListeDeBoites] } { ChargeListeDeBoites } foreach Boite $ListeDeBoites { set Nom [Box $Boite nom] if {[regexp "TROU" $Nom]} { continue } set Debut [Box $Boite debut] set Fin [Box $Boite fin] set Orient [Box $Boite orient] lappend AQuiEstCeDebut($Debut) $Nom lappend AQuiEstCetteFin($Fin) $Nom lappend LesDebuts $Debut lappend LesFins $Fin } set LesDebutsTries [lsort -integer $LesDebuts] set LesFinsTries [lsort -integer $LesFins] } set ppDebut [lindex $LesDebutsTries 0] set pgDebut [lindex $LesDebutsTries end] set nDebuts [llength $LesDebutsTries] set Probable [expr ($DebutSeq-$ppDebut)*$nDebuts/($pgDebut-$ppDebut)] if {[expr $Probable < 6]} { set Probable 6 } elseif {[expr $Probable > [llength $LesDebutsTries]-1-6]} { set Probable [expr [llength $LesDebutsTries]-1-6] } else { if {[expr [lindex $LesDebutsTries $Probable] < $DebutSeq]} { while { [expr [lindex $LesDebutsTries $Probable] < $DebutSeq] } { incr Probable } } else { while { [expr [lindex $LesDebutsTries $Probable] > $DebutSeq] } { incr Probable -1} } } set Touches {} foreach X [lrange $LesDebutsTries [expr $Probable-6] [expr $Probable+6]] { foreach Lui [set AQuiEstCeDebut($X)] { if {[Box $Lui orient] != $OrientSeq} { continue } if { [Box $Lui debut] <= $DebutSeq && $DebutSeq <= [Box $Lui fin] \ || [Box $Lui debut] <= $FinSeq && $FinSeq <= [Box $Lui fin] } { lappend Touches $Lui } elseif {$DebutSeq <= [Box $Lui debut] && [Box $Lui debut] <= $FinSeq \ || $DebutSeq <= [Box $Lui fin] && [Box $Lui fin] <= $FinSeq } { lappend Touches $Lui } } } return $Touches } } proc OffsetDansEnteteSegAli {Ligne {BanqueBlast ""}} { scan $Ligne "%s" BanqueAccess regsub ">" $BanqueAccess "" BanqueAccess scan [OffsetEtOrganismeDuFragment $BanqueAccess $BanqueBlast] "%d" Offset return $Offset } proc CreeOuATapeBlastX {{Banque ""} {AvecOrganismes ""} {AvecPositions ""} {AvecDupliques ""}} { global RepertoireDuGenome global ListeDeBoites if {$Banque==""} { set Banque "protall" } if {$AvecOrganismes==""} { set AvecOrganismes 0 } if {$AvecPositions ==""} { set AvecPositions 1 } if {$AvecDupliques ==""} { set AvecDupliques 0 } Wup "AvecOrganismes+AvecPositions or AvecDupliques" set FichierOuATape "$RepertoireDuGenome/fiches/ouatapebx.$Banque" if {[file exists $FichierOuATape]} { if {[OuiOuNon "$FichierOuATape\nalready exists. Do I replace it ?"]} { File delete $FichierOuATape } else { if {[OuiOuNon "Do I keep the existing lines from \n $FichierOuATape \n ?"]} { foreach Ligne [LesLignesDuFichier $FichierOuATape] { scan $Ligne "%s" Nom if { ! [info exists DejaVu($Nom)]} { set DejaVu($Nom) 0 } incr DejaVu($Nom) } } } } if { ! [info exists ListeDeBoites]} { ChargeListeDeBoites } foreach Boite $ListeDeBoites { set Nom [Box $Boite nom] set Fichier "$RepertoireDuGenome/blastx/$Nom" if { ! [file exists $Fichier]} { continue } Espionne $Fichier if {$AvecOrganismes && ! [info exists DejaVu($Nom)]} { set Organismes [join [OuATapeBlastX $Fichier "ListeDesOrganismes"] "\n"] AppendAuFichier $FichierOuATape "$Nom $Organismes" } if {$AvecPositions && (! [info exists DejaVu($Nom)] || [set DejaVu($Nom)]<2)} { set Positions [join [OuATapeBlastX $Fichier "ListeDesPositions"] "\n"] AppendAuFichier $FichierOuATape "$Nom $Positions" } if {$AvecDupliques && ! [info exists DejaVu($Nom)]} { set Dupliques [join [OuATapeBlastX $Fichier "ListeDesDupliques"] "\n"] AppendAuFichier $FichierOuATape "$Nom $Dupliques" } } } proc CreeOuATapeTBlastN {{Banque ""} {AvecOrganismes ""} {AvecPositions ""} {AvecDupliques ""}} { global RepertoireDuGenome global ListeDeBoites if {$Banque==""} { set Banque "genomes" } if {$AvecOrganismes==""} { set AvecOrganismes 0 } if {$AvecPositions ==""} { set AvecPositions 1 } if {$AvecDupliques ==""} { set AvecDupliques 0 } Wup "AvecOrganismes+AvecPositions or AvecDupliques" set FichierOuATape "$RepertoireDuGenome/fiches/ouatapetbn.$Banque" if {[file exists $FichierOuATape]} { if {[OuiOuNon "$FichierOuATape\nalready exists. Do I replace it ?"]} { File delete $FichierOuATape } else { if {[OuiOuNon "Do I keep the existing lines from \n $FichierOuATape \n ?"]} { foreach Ligne [LesLignesDuFichier $FichierOuATape] { scan $Ligne "%s" Nom if { ! [info exists DejaVu($Nom)]} { set DejaVu($Nom) 0 } incr DejaVu($Nom) } } } } if { ! [info exists ListeDeBoites]} { ChargeListeDeBoites } foreach Boite $ListeDeBoites { set Nom [Box $Boite nom] set Fichier "$RepertoireDuGenome/tblastn$Banque/$Nom" if { ! [file exists $Fichier]} { continue } if {$AvecOrganismes && ! [info exists DejaVu($Nom)]} { set Organismes [join [OuATapeTBlastN $Fichier $Banque "ListeDesOrganismes"] " "] AppendAuFichier $FichierOuATape "$Nom $Organismes" } if {$AvecPositions && (! [info exists DejaVu($Nom)] || [set DejaVu($Nom)]<2)} { set Positions [join [OuATapeTBlastN $Fichier $Banque "ListeDesPositions"] " "] AppendAuFichier $FichierOuATape "$Nom $Positions" } if {$AvecDupliques && ! [info exists DejaVu($Nom)]} { set Dupliques [join [OuATapeTBlastN $Fichier $Banque "ListeDesDupliques"] " "] AppendAuFichier $FichierOuATape "$Nom $Dupliques" } } } proc OuATapeTBlastN {Fichier Banque QuoiRetourner} { global PrecedentNom PrecedenteListe if {$QuoiRetourner=="ListeDesOrganismes"} { set QuoiRetourner "LesOrgas" } if {$QuoiRetourner=="ListeDesPositions" } { set QuoiRetourner "LesHits" } if {$QuoiRetourner=="ListeDesPositionsVieux" } { set QuoiRetourner "LesHitsVieux" } Wup "Banque ne sert plus !" set Nom [file tail $Fichier] set DebutNom [Box $Nom debut] set FinNom [Box $Nom fin] if {[info exists PrecedentNom] && $PrecedentNom==$Nom} { set ListeDesHomologues $PrecedenteListe } else { set ListeDesHomologues [ChaqueProteineDuTBlastN $Fichier] } set PrecedentNom $Nom set PrecedenteListe $ListeDesHomologues if {$ListeDesHomologues == {} } { return {}} catch {unset ListeDesDupliques} catch {unset ListeDesPositions} set LesBeauxHits {} foreach Homo $ListeDesHomologues { set lHomo [split $Homo "\t"] set i -1 set Nom [lindex $lHomo [incr i]] set nCops [lindex $lHomo [incr i]] set nCopsSeq [lindex $lHomo [incr i]] set BanqueId [lindex $lHomo [incr i]] set Orga [lindex $lHomo [incr i]] set Score [lindex $lHomo [incr i]] set Expect [lindex $lHomo [incr i]] set DebutQRel [lindex $lHomo [incr i]] set FinQRel [lindex $lHomo [incr i]] set DebutSbjct [lindex $lHomo [incr i]] set FinSbjct [lindex $lHomo [incr i]] set LongSbjct [expr abs($FinSbjct-$DebutSbjct)+1] set DebutQuery [expr $DebutQRel+$DebutNom-1] set FinQuery [expr $FinQRel+$DebutNom-1] if { ! [info exists DejaVu($Orga)]} { set DejaVu($Orga) 1 lappend LesBeauxOrgas $Orga } lappend LesBeauxHits "\ \ \ \ \ \ \ \ " lappend LesHitsVieux [expr ($DebutQuery+$FinQuery)/2] lappend LesHitsVieux [expr ($DebutSbjct+$FinSbjct)/2] } if {$QuoiRetourner=="LesHits"} { return $LesBeauxHits } FaireLire "You use an old version of Gscope for OuATapeTBlastN" if {$QuoiRetourner=="LesOrgas"} { return $LesBeauxOrgas } if {$QuoiRetourner=="LesHitsVieux"} { return $LesHitsVieux } return "" } proc PNApres {Champ dans Texte} { return [ValeurApres $Champ dans $Texte "ExposantEventuellementMalFoutu"] } proc ChaqueProteineDuTBlastN {Fichier {AvecLaSeq ""}} { if {$AvecLaSeq==""} { set AvecLaSeq 0 } else { set AvecLaSeq 1 } set Nom [file tail $Fichier] set SeuilDuTBlastN 0.001 # set SeuilDuTBlastN 10. set nSequencesTrouves [DecortiqueBlast $Fichier \ $SeuilDuTBlastN "SansLimiteDeNombre" Query lBanqueId lAccess lDE lProfil lPN lPartieSegAli] if { $nSequencesTrouves == 0 } { set nCops 0 return {} } set ListeDesHomologues {} set nCops 0 set AttendreFinEntete 0 set FinEntete 0 foreach BanqueId $lBanqueId DE $lDE PN $lPN PartieSegAli $lPartieSegAli { set TaxId -1 scan [OffsetEtOrganismeDuFragment "$BanqueId $DE"] "%d %s %s %d" Offset Genre Espece TaxId if {$TaxId>0} { set Orga $TaxId } else { set OrgaComplet "$Genre $Espece" set Orga [Glossaire $OrgaComplet Court] } set nCopsDansCetteSequence 0 foreach Ligne $PartieSegAli { if { $AttendreFinEntete } { if { ! [regexp {[0-9a-zA-Z_]} $Ligne] } { set AttendreFinEntete 0 set FinEntete 1 } else { append Entete $Ligne continue } } if {[regexp {^>} $Ligne]} { set Entete $Ligne set AttendreFinEntete 1 } if { $FinEntete } { set FinEntete 0 set Offset [OffsetDansEnteteSegAli $Entete] } if { [regexp "^ Identities =" $Ligne] } { set Identities [StringApres "Identities =" dans $Ligne] set Positives [StringApres "Positives =" dans $Ligne] scan $Identities "%d/%d" nId nTotal scan $Positives "%d/%d" nPo nTotal } if { [regexp "^ Score =" $Ligne] } { if {[info exists Score]} { incr nCops incr nCopsDansCetteSequence if { $AvecLaSeq } { set EtLaSeq "\t$SeqSbjct" } else { set EtLaSeq "" } Wup "Je triche en cachant dans Score le PourcentageIdentite" set PourcentageIdentiteCacheDansScore [format "%6.2f" [expr (100.*$nId)/$nTotal]] if {[catch {set Homologie "$Nom\t$nCops\t$nCopsDansCetteSequence\t$BanqueId\t$Orga\t$PourcentageIdentiteCacheDansScore\t$Expect\t$DebutQuery\t$FinQuery\t$DebutSbjct\t$FinSbjct$EtLaSeq"}]} { unset Score ; break } lappend ListeDesHomologues $Homologie unset Score unset Expect unset DebutQuery unset DebutSbjct } set Score [FloatApres "Score =" dans $Ligne] catch {unset Expect} if {[regexp "Expect =" $Ligne]} { set Expect [PNApres "Expect =" dans $Ligne] } if {[regexp {Expect\([0-9]\) =} $Ligne Match]} { set Expect [PNApres $Match dans $Ligne] } if { ! [info exists Expect]} { Warne "$Ligne\nwithout Expect ... I break" catch {unset Score} catch {unset Expect} catch {unset DebutQuery} catch {unset DebutSbjct} break } catch {unset DebutQuery} catch {unset DebutSbjct} if { [expr $Expect > $SeuilDuTBlastN]} { catch {unset Score} catch {unset Expect} catch {unset DebutQuery} catch {unset DebutSbjct} break } } if {[regexp "^ Database:" $Ligne] } { break } if {[regexp "^Query:?" $Ligne] } { if { ! [info exists DebutQuery]} { #rR pour lire aussi les blast+ 2018/11/07 set Key "Query" if {[regexp "Query:" $Ligne]} { set Key "Query:" } set DebutQuery [IntegerApres $Key dans $Ligne] } set FinQuery [IntegerEnFin de $Ligne] } if {[regexp "^Sbjct:?" $Ligne] } { if { ! [info exists DebutSbjct]} { set SeqSbjct "" #rR pour lire aussi les blast+ 2018/11/07 set Key "Sbjct" if {[regexp "Sbjct:" $Ligne]} { set Key "Sbjct:" } set DebutSbjct [expr [IntegerApres $Key dans $Ligne] + $Offset] } regexp -indices {[0-9]+} $Ligne D set D [lindex $D 1] regexp -indices {[0-9]+} [string range $Ligne [incr D] end] F set F [expr [lindex $F 0]+$D-1] append SeqSbjct [string trim [string range $Ligne $D $F]] set FinSbjct [expr [IntegerEnFin de $Ligne] + $Offset] } } if {[info exists Score] && [expr $Expect <= $SeuilDuTBlastN] } { incr nCops incr nCopsDansCetteSequence if { $AvecLaSeq } { set EtLaSeq "\t$SeqSbjct" } else { set EtLaSeq "" } Wup "Je triche en cachant dans Score le PourcentageIdentite" set PourcentageIdentiteCacheDansScore [format "%6.2f" [expr (100.*$nId)/$nTotal]] if { ! [catch {set Homologie "$Nom\t$nCops\t$nCopsDansCetteSequence\t$BanqueId\t$Orga\t$PourcentageIdentiteCacheDansScore\t$Expect\t$DebutQuery\t$FinQuery\t$DebutSbjct\t$FinSbjct$EtLaSeq"}] } { lappend ListeDesHomologues $Homologie } } catch {unset Score} catch {unset Expect} catch {unset DebutQuery} catch {unset DebutSbjct} } return $ListeDesHomologues } proc ChaqueHitDuBlastP {Fichier {AvecLaSeq ""} {Cible ""}} { return [ChaqueProteineDuBlastX $Fichier $AvecLaSeq $Cible] } proc ChaqueProteineDuBlastX {Fichier {AvecLaSeq ""} {Cible ""}} { if {$AvecLaSeq==""} { set AvecLaSeq 0 } else { set AvecLaSeq 1 } set Nom [file tail $Fichier] set SeuilExpect 0.001 global SeuilExpectPourBlastX if {[info exists SeuilExpectPourBlastX]} { set SeuilExpect $SeuilExpectPourBlastX } set MaxList "SansLimiteDeNombre" set nSequencesTrouves [DecortiqueBlast $Fichier \ $SeuilExpect $MaxList Query lBanqueId lAccess lDE lProfil lPN lPartieSegAli] if { $nSequencesTrouves == 0 } { set nCops 0 return {} } set ListeDesHomologues {} set nCops 0 set AttendreFinEntete 0 set FinEntete 0 foreach BanqueId $lBanqueId PN $lPN PartieSegAli $lPartieSegAli { if {$Cible!="" && ! [string equal -nocase $BanqueId $Cible]} { continue } set TaxId -1 scan "0 Inconnu inconnu -1" "%d %s %s %d" Offset Genre Espece TaxId if {$TaxId>0} { set Orga $TaxId } else { set OrgaComplet "$Genre $Espece" set Orga [Glossaire $OrgaComplet Court] } set nCopsDansCetteSequence 0 foreach Ligne $PartieSegAli { if { $AttendreFinEntete } { if { ! [regexp {[0-9a-zA-Z_]} $Ligne] } { set AttendreFinEntete 0 set FinEntete 1 } else { append Entete $Ligne continue } } if {[regexp {^>} $Ligne]} { set Entete $Ligne set AttendreFinEntete 1 } if { $FinEntete } { set FinEntete 0 set Offset 0 } if { [regexp "^ Identities =" $Ligne] } { set Identities [StringApres "Identities =" dans $Ligne] set Positives [StringApres "Positives =" dans $Ligne] scan $Identities "%d/%d" nId nTotal scan $Positives "%d/%d" nPo nTotal } if { [regexp "^ Score =" $Ligne] } { if {[info exists Score]} { incr nCops incr nCopsDansCetteSequence if { $AvecLaSeq } { set EtLaSeq "\t$SeqSbjct" } else { set EtLaSeq "" } Wup "Je triche en cachant dans Score le PourcentageIdentite" set PourcentageIdentiteCacheDansScore [format "%6.2f" [expr (100.*$nId)/$nTotal]] if {[catch {set Homologie "$Nom\t$nCops\t$nCopsDansCetteSequence\t$BanqueId\t$Orga\t$PourcentageIdentiteCacheDansScore\t$Expect\t$DebutQuery\t$FinQuery\t$DebutSbjct\t$FinSbjct$EtLaSeq"}]} { unset Score ; break } lappend ListeDesHomologues $Homologie unset Score unset Expect unset DebutQuery unset DebutSbjct } set Score [FloatApres "Score =" dans $Ligne] catch {unset Expect} if {[regexp "Expect =" $Ligne]} { set Expect [PNApres "Expect =" dans $Ligne] } if {[regexp {Expect\([0-9]*\) =} $Ligne Match]} { set Expect [PNApres $Match dans $Ligne] } if { ! [info exists Expect]} { Warne "$Ligne\nwithout Expect ... I break" catch {unset Score} catch {unset Expect} catch {unset DebutQuery} catch {unset DebutSbjct} break } catch {unset DebutQuery} catch {unset DebutSbjct} if { [expr $Expect > $SeuilExpect]} { catch {unset Score} catch {unset Expect} catch {unset DebutQuery} catch {unset DebutSbjct} break } } if {[regexp "^ Database:" $Ligne] } { break } if {[regexp "^Query:" $Ligne] } { if { ! [info exists DebutQuery]} { #rR pour lire aussi les blast+ 2018/11/07 set Key "Query" if {[regexp "Query:" $Ligne]} { set Key "Query:" } set DebutQuery [IntegerApres $Key dans $Ligne] } set FinQuery [IntegerEnFin de $Ligne] } if {[regexp "^Sbjct:" $Ligne] } { if { ! [info exists DebutSbjct]} { set SeqSbjct "" #rR pour lire aussi les blast+ 2018/11/07 set Key "Sbjct" if {[regexp "Sbjct:" $Ligne]} { set Key "Sbjct:" } set DebutSbjct [expr [IntegerApres "Sbjct:" dans $Ligne] + $Offset] } regexp -indices {[0-9]+} $Ligne D set D [lindex $D 1] regexp -indices {[0-9]+} [string range $Ligne [incr D] end] F set F [expr [lindex $F 0]+$D-1] append SeqSbjct [string trim [string range $Ligne $D $F]] set FinSbjct [expr [IntegerEnFin de $Ligne] + $Offset] } } if {[info exists Score] && [expr $Expect <= $SeuilExpect] } { incr nCops incr nCopsDansCetteSequence if { $AvecLaSeq } { set EtLaSeq "\t$SeqSbjct" } else { set EtLaSeq "" } Wup "Je triche en cachant dans Score le PourcentageIdentite" set PourcentageIdentiteCacheDansScore [format "%6.2f" [expr (100.*$nId)/$nTotal]] if { ! [catch {set Homologie "$Nom\t$nCops\t$nCopsDansCetteSequence\t$BanqueId\t$Orga\t$PourcentageIdentiteCacheDansScore\t$Expect\t$DebutQuery\t$FinQuery\t$DebutSbjct\t$FinSbjct$EtLaSeq"}] } { lappend ListeDesHomologues $Homologie } } catch {unset Score} catch {unset Expect} catch {unset DebutQuery} catch {unset DebutSbjct} } return $ListeDesHomologues } proc SoleilsDesTBlastNs Selection { global RepertoireDuGenome foreach Nom [split $Selection "\n"] { lappend ListeDeBlasts "$RepertoireDuGenome/tblastngenomes/$Nom" } SoleilsDesBlasts [join $ListeDeBlasts "\n"] } proc SoleilsDesBlasts Selection { global GalerieCourante global ExpoCourante set ExpoCourante [NomDe expo] set GalerieCourante $ExpoCourante[NomDe galerie] CreeGalerie $GalerieCourante foreach Fichier [split $Selection "\n"] { GrapheBout $Fichier } ClosGalerieCourante ClosExpoCourante } proc OrganismeDeLaLigneTBlastN Ligne { JeMeSignale set Complet(taqu) "Thermus aquaticus" set Complet(aaeol) "Aquifex aeolicus" set Complet(aaeo) "Aquifex aeolicus" set Complet(aful) "Archaeoglobus fulgidus" set Complet(aper) "Aeropyrum pernix" set Complet(bsub) "Bacillus subtilis" set Complet(bburg) "Borrelia burgdorferi" set Complet(bbur) "Borrelia burgdorferi" set Complet(buch) "Buchnera sp" set Complet(bsp) "Buchnera sp" set Complet(baph) "Buchnera aphidicola" set Complet(baphb) "Buchnera aphidicola" set Complet(cjej) "Campylobacter jejuni" set Complet(cpne) "Chlamydia pneumoniae" set Complet(ctra) "Chlamydia trachomatis" set Complet(drad) "Deinococcus radiodurans" set Complet(ecoli) "Escherichia coli" set Complet(ecol) "Escherichia coli" set Complet(hinf) "Haemophilus influenzae" set Complet(hpylo) "Helicobacter pylori" set Complet(hpyl) "Helicobacter pylori" set Complet(mthe) "Methanobacterium thermoautotrophicum" set Complet(mtub) "Mycobacterium tuberculosis" set Complet(mjan) "Methanococcus jannaschii" set Complet(mgen) "Mycoplasma genitalium" set Complet(mpneu) "Mycoplasma pneumoniae" set Complet(mpne) "Mycoplasma pneumoniae" set Complet(nmen) "Neisseria meningitidis" set Complet(pae) "Pyrobaculum aerophilum" set Complet(paby) "Pyrococcus abyssi" set Complet(pfuri) "Pyrococcus furiosus" set Complet(pfur) "Pyrococcus furiosus" set Complet(pf) "Pyrococcus furiosus" set Complet(phori) "Pyrococcus horikoshii" set Complet(phor) "Pyrococcus horikoshii" set Complet(ph) "Pyrococcus horikoshii" set Complet(rprow) "Rickettsia prowazekii" set Complet(rpro) "Rickettsia prowazekii" set Complet(synecho) "Synechocystis sp" set Complet(syne) "Synechocystis sp" set Complet(ssp) "Synechocystis sp" set Complet(ssp.) "Synechocystis sp" set Complet(tmar) "Thermotoga maritima" set Complet(tpal) "Treponema pallidum" set Complet(txxx) "Thermococcus xxx" set Complet(uure) "Ureaplasma urealyticum" set Complet(yeast) "Saccharomyces cerevisiae" set Complet(yeas) "Saccharomyces cerevisiae" set Complet(ye) "Saccharomyces cerevisiae" set BanqueAccess [lindex [split $Ligne " "] 0] if {[regexp "_" $BanqueAccess] && ! [regexp "\:" $BanqueAccess]} { regsub "_" $BanqueAccess " " SansUnderscore set GloComplet [Glossaire $SansUnderscore Complet] if {$GloComplet != ""} { return $GloComplet } } set Banque [string tolower [lindex [split $BanqueAccess ":"] 0]] regsub {>} $Banque "" Banque if {[regexp -nocase "thermococcus" $Banque]} { return "Thermococcus xxx" return [Glossaire [set Complet(txxx)] Complet] } if {[regexp -nocase "PYRO_i_tot1.brut" $Banque]} { return "Pyrococcus horikoshii" } if {[regexp -nocase "PYRO_i_tot1.brut" $Banque]} { return "Pyrococcus horikoshii" } if {[regexp -nocase "ot3seq.fasta" $Banque]} { return "Pyrococcus horikoshii" } if {[regexp -nocase "^aero" $Banque]} { return "Aeropyrum pernix" } if {[regexp -nocase "^nmen" $Banque]} { return "Neisseria meningitidis" } if {[regexp -nocase "^MM4" $Banque]} { return "Pyrococcus furiosus" } if {[regexp -nocase "^DRA" $Banque]} { return "Deinococcus radiodurance" } if {[regexp -nocase "^UREA" $Banque]} { return "Ureaplasma urealyticum" } if {[regexp -nocase "^BUCH" $Banque]} { return "Buchnera sp" } set Access [string tolower [lindex [split $BanqueAccess ":"] 1]] if {[regexp "_" $Access]} { set Access [lindex [split $Access "_"] 0] } if {[info exists Complet($Access)]} { set Retour [Glossaire [set Complet($Access)] Complet] if {$Retour==""} { return "Inconnu inconnu" } return $Retour } if {[info exists Complet($Banque)]} { set Retour [Glossaire [set Complet($Banque)] Complet] if {$Retour==""} { return "Inconnu inconnu" } return $Retour } set Access [string range $Access 0 3] if {[info exists Complet($Access)]} { set Retour [Glossaire [set Complet($Access)] Complet] if {$Retour==""} { return "Inconnu inconnu" } return $Retour } if {[OuiOuNon "$Ligne incomprehensible.\n Sauriez-vous le definir ?" 0]} { FaireLire "Donner le nom complet de l'organisme en respectant Majuscule minuscule" set Organisme [Entre] set Complet($Ligne) $Organisme set Retour [Glossaire $Organisme Complet] if {$Retour==""} { return "Inconnu inconnu" } return $Retour } else { return "Inconnu inconnu" } } proc PartieSegAli {Page LigneAccess} { # LogWscope "PartieSegAli [string length $Page] $LigneAccess" scan $LigneAccess "%s" Access regsub {\.+$} $Access "" Access set Cherche ">$Access " set OriCherche $Cherche set Debut [string first $Cherche $Page] while {$Debut<0} { set NewCherche [string range $Cherche 0 end-1] set Debut [string first $NewCherche $Page] if {$Debut>=0 && [string trim $Cherche]==$NewCherche} { break } ;#rR rajouté 2017/07/10 pour >chr1 sans blanc derrière if { ! [OuiOuNon "I cannot find the segment alignment for \"$Cherche\"\ \nDo I continue to search with \"$NewCherche\" (one character less than before) ?\ \nPlease notate that $NewCherche is no more equal to $OriCherche and it can be wrong ..."]} { return "I didn't find $LigneAccess" } set Cherche $NewCherche set Debut [string first $Cherche $Page] } set Fin [string first "\n>" $Page $Debut] if { $Fin < 0 } { set Fin "end" } return [string range $Page $Debut $Fin] } proc Deselecte K { global RectangleDeSelectionNucleique global xDebutRectangleDeSelectionNucleique global yDebutRectangleDeSelectionNucleique global xFinRectangleDeSelectionNucleique global yFinRectangleDeSelectionNucleique global Piques foreach Nom [split [LesNomsPiques] "\n"] { Detoure $Nom $K unset Piques($Nom) } if {[info exists RectangleDeSelectionNucleique($K)]} { $K delete [set RectangleDeSelectionNucleique($K)] catch {unset RectangleDeSelectionNucleique($K)} catch {unset xDebutRectangleDeSelectionNucleique($K)} } } proc FiabiliteFonction Nom { set FF [string range [ExtraitInfo $Nom "Fonction"] 0 0] if { $FF == "" } { return 0 } return $FF } proc MiseAJourAvecLesInfosDuGenoscope {} { global RepertoireDuGenome global InformeSansDemander set InformeSansDemander 1 foreach Fichier [glob "$RepertoireDuGenome/DuGenoscope/infos.dir/*"] { set Nom [file tail $Fichier] Informe $Nom [ContenuDuFichier $Fichier] } } proc InfoInteressante Ligne { if {[regexp {^CNS-Adresse:} $Ligne]} { return 0 } if {[regexp {^CNS-Sequence:} $Ligne]} { return 0 } if {[regexp {^CNS-VieuxNom:} $Ligne]} { return 0 } if {[regexp {^CNS} $Ligne]} { return 1 } return 0 } proc CreeLesInfosDuGenescope {Fichier Repertoire} { global RepertoireDuGenome foreach Ligne [LesLignesDuFichier $Fichier] { if { $Ligne == "" } { continue } if {[regexp "^Nom: [ExpressionReguliereDesPABs]" $Ligne]} { if {[info exists InfoCourante]} { Sauve [join $InfoCourante "\n"] dans "$Repertoire/$Nom" } scan $Ligne "%s %s" Bidon Nom set InfoCourante {} } if {[InfoInteressante $Ligne]} { lappend InfoCourante $Ligne } } } proc TCNI {} { global RepertoireDuGenome set CNI [ConcordanceNumerotationDesIntergenes ] set LesMemes [lindex $CNI 1] set LesModifies [lindex $CNI 2] EspionneL $LesMemes Espionne "" EspionneL $LesModifies exit } proc ConcordanceNumerotationDesIntergenes {Ancien Nouveau} { global RepertoireDuGenome set LesModifies {} foreach Ligne [LesLignesDuFichier $Ancien] { scan $Ligne "%s %d %d %s %s" A D F O L set AncienNom($D,$F) $A set AncienNomDebut($D) $A set AncienNomFin($F) $A } foreach Ligne [LesLignesDuFichier $Nouveau] { scan $Ligne "%s %d %d %s %d" N D F O L if {[info exists AncienNom($D,$F)]} { set Nom [set AncienNom($D,$F)] Espionne "Reprise complete $Nom $N" lappend LesMemes "$Nom $D $F $O $L" lappend LesNouveaux "$Nom $D $F $O $L" set DejaVu($Ligne) 1 set DejaUtilise($Nom) 1 } else { lappend LesModifies $Ligne } } foreach Ligne [LesLignesDuFichier $Nouveau] { if {[info exists DejaVu($Ligne)]} { continue } scan $Ligne "%s %d %d %s %d" N D F O L if {[info exists AncienNomDebut($D)]} { set Nom [set AncienNomDebut($D)] if { ! [info exists DejaUtilise($Nom)]} { Espionne "Reprise debut $Nom $N" lappend LesNouveaux "$Nom $D $F $O $L" set DejaVu($Ligne) 1 set DejaUtilise($Nom) 1 } } } foreach Ligne [LesLignesDuFichier $Nouveau] { if {[info exists DejaVu($Ligne)]} { continue } scan $Ligne "%s %d %d %s %d" N D F O L if {[info exists AncienNomFin($F)]} { set Nom [set AncienNomFin($F)] if { ! [info exists DejaUtilise($Nom)]} { Espionne "Reprise fin $Nom $N" lappend LesNouveaux "$Nom $D $F $O $L" set DejaVu($Ligne) 1 set DejaUtilise($Nom) 1 } } } set Numero 10000 foreach Ligne [LesLignesDuFichier $Nouveau] { if {[info exists DejaVu($Ligne)]} { continue } scan $Ligne "%s %d %d %s %d" N D F O L set Nom [format "INTERGENE%4.4d" [incr Numero -1]] Espionne "En desespoir $Nom $N" lappend LesNouveaux "$Nom $D $F $O $L" set DejaVu($Ligne) 1 set DejaUtilise($Nom) 1 } set LesNouveaux [lsort -command CompareLesMilieux $LesNouveaux] set LesMemes [lsort -command CompareLesMilieux $LesMemes] set LesModifies [lsort -command CompareLesMilieux $LesModifies] return $LesNouveaux } proc SixBlastPsurPiques Selection { foreach Pique [split $Selection "\n"] { SixBlastPsurPique $Pique } } proc SixBlastPsurPique Pique { global ADN TDN RAC if { ! [info exists ADN] } { ChargeADNetTDNetRAC } set Debut [Box $Pique debut] set Fin [Box $Pique fin] foreach Frame {a b c d e f} Orient {F F F R R R} Offset {1 2 3 1 2 3} { set DebutFrame [expr ($Debut/3)*3+$Offset] set FinFrame [expr ( $Fin/3)*3+$Offset] set Nom "$Pique$Frame" set SeqNuc [BoutADN $DebutFrame $FinFrame $Orient] set SeqPro [SeqNucToSeqPro $SeqNuc] set TFA [SequenceFormatTFA $SeqPro $Nom "protbrut"] Blaste P $TFA "$Nom" } } proc SixBlastPsurZone K { global xDebutRectangleDeSelectionNucleique global yDebutRectangleDeSelectionNucleique global xFinRectangleDeSelectionNucleique global yFinRectangleDeSelectionNucleique if { ! [info exists xDebutRectangleDeSelectionNucleique($K)]} { FaireLire "IL faut selectionner une zone par " return "" } set Debut [PositionCanvaOriginaleX $K [Mini \ [set xDebutRectangleDeSelectionNucleique($K)] \ [set xFinRectangleDeSelectionNucleique($K)] \ ]] set Fin [PositionCanvaOriginaleX $K [Maxi \ [set xDebutRectangleDeSelectionNucleique($K)] \ [set xFinRectangleDeSelectionNucleique($K)] \ ]] foreach Frame {a b c d e f} Orient {F F F R R R} Offset {1 2 3 1 2 3} { set DebutFrame [expr ($Debut/3)*3+$Offset] set FinFrame [expr ( $Fin/3)*3+$Offset] set Nom "${Orient}_${DebutFrame}_${FinFrame}" set SeqNuc [BoutADN $DebutFrame $FinFrame $Orient] set SeqPro [SeqNucToSeqPro $SeqNuc] set TFA [SequenceFormatTFA $SeqPro $Nom "protbrut"] Blaste P $TFA "$Nom" } } proc BlastXsurZone K { global xDebutRectangleDeSelectionNucleique global yDebutRectangleDeSelectionNucleique global xFinRectangleDeSelectionNucleique global yFinRectangleDeSelectionNucleique if { ! [info exists xDebutRectangleDeSelectionNucleique($K)]} { FaireLire "IL faut selectionner une zone par " return "" } set Debut [PositionCanvaOriginaleX $K [Mini \ [set xDebutRectangleDeSelectionNucleique($K)] \ [set xFinRectangleDeSelectionNucleique($K)] \ ]] set Fin [PositionCanvaOriginaleX $K [Maxi \ [set xDebutRectangleDeSelectionNucleique($K)] \ [set xFinRectangleDeSelectionNucleique($K)] \ ]] BlastXdeADN "X" $Debut $Fin } proc ShowNuc {K X Y Action {PositionNucleique 0}} { global ADN TDN RAC global OldX OldADN OldTDN OldPosD OldPosG OldLigne global RectangleDeSelectionNucleique global xDebutRectangleDeSelectionNucleique global yDebutRectangleDeSelectionNucleique global xFinRectangleDeSelectionNucleique global yFinRectangleDeSelectionNucleique if { ! [info exists ADN]} { ChargeADNetTDNetRAC } set xVrai [$K canvasx $X] set yVrai [$K canvasy $Y] if { $Action == "Point" } { set xDebutRectangleDeSelectionNucleique($K) $xVrai set yDebutRectangleDeSelectionNucleique($K) $yVrai } if {[info exists OldLigne($K)]} { catch {$K delete [set OldADN($K)]} catch {$K delete [set OldTDN($K)]} catch {$K delete [set OldPosD($K)]} catch {$K delete [set OldPosG($K)]} catch {$K delete [set OldLigne($K)]} unset OldLigne($K) if { $PositionNucleique == 0 && $X == [set OldX($K)] } { return } } set x [$K canvasx $X] set y [$K canvasy $Y] if {$PositionNucleique > 0} { set i $PositionNucleique } else { set i [PositionCanvaOriginaleX $K [$K canvasx $X]] } set Orient "Inconnue" set BoiteTouchee [BoiteDuCourant $K $X $Y] if { $BoiteTouchee != "" } { if { [expr $i < ([Box $BoiteTouchee debut]+[Box $BoiteTouchee fin])/2]} { set i [Box $BoiteTouchee debut] } else { set i [expr [Box $BoiteTouchee fin]+1] } set x [PositionCanvaActuelleX $K $i] set y [expr $y-30] set Orient [Box $BoiteTouchee orient] } set ZoneADN [string range $ADN [expr $i-20] [expr $i+19]] set ZoneTDN [string range $TDN [expr $i-20] [expr $i+19]] set PositionD [format " %4.4d" $i] set PositionG [format "%4.4d " [expr $i-1]] set Fonte {Courier 10} set OldX($K) $X if { $Orient != "R" } { set OldADN($K) [$K create text [expr $x] [expr $y-10] \ -text $ZoneADN -font $Fonte -anchor center] } if { $Orient != "F" } { set OldTDN($K) [$K create text [expr $x] [expr $y+10] \ -text $ZoneTDN -font $Fonte -anchor center] } set OldPosD($K) [$K create text $x [expr $y] -text $PositionD -font $Fonte -anchor w] set OldPosG($K) [$K create text $x [expr $y] -text $PositionG -font $Fonte -anchor e] set OldLigne($K) [$K create line $x [expr $y-1000] $x [expr $y+1000]] if {[info exists RectangleDeSelectionNucleique($K)]} { $K delete [set RectangleDeSelectionNucleique($K)] } if { $Action == "Motion" } { set xFinRectangleDeSelectionNucleique($K) $xVrai set yFinRectangleDeSelectionNucleique($K) $yVrai set RectangleDeSelectionNucleique($K) [$K create rect \ [set xDebutRectangleDeSelectionNucleique($K)] \ [set yDebutRectangleDeSelectionNucleique($K)] \ [set xFinRectangleDeSelectionNucleique($K)] \ [set yFinRectangleDeSelectionNucleique($K)] \ -outline "yellow" -width 3 \ -tags "SelectionNucleique"] } } proc QueDitYvan Nom { global LesLignesDeYvan global RepertoireDuGenome if {! [info exists LesLignesDeYvan] } { set LesLignesDeYvan [LesLignesDuFichier "$RepertoireDuGenome/Yvan/Yvan_la_totale.txt"] } set i [lsearch -regexp $LesLignesDeYvan $Nom] if { $i == -1 } { set Message "Yvan ne dit rien" } else { set Message [join [lrange $LesLignesDeYvan [expr $i-1] [expr $i+1]] "\n"] } AfficheVariable "$Message\n\n[ContenuDuFichier $RepertoireDuGenome/infos/$Nom]" "GrandeLargeur" return $Message } proc QueDitCohen Nom { global RepertoireDuGenome set FichierCohen "$RepertoireDuGenome/cohen/$Nom" if {! [file exists $FichierCohen] } { FaireLire "Cohen ne dit rien" ; return "" } return [AfficheVariable [ContenuDuFichier $FichierCohen] "AvecRien"] } proc Presente Selection { global RepertoireDuGenome if {$Selection==""} { return "" } foreach Element [split $Selection "\n"] { if {[YaPABenDebutDe $Element]} { set Element "$RepertoireDuGenome/prottfa/$Element" } if {[regexp {TRNA|RNA} $Element]} { set Element "$RepertoireDuGenome/nuctfa/$Element" } if {[regexp {^TROU[0-9]+N$} $Element]} { set Element "$RepertoireDuGenome/nuctfa/$Element" } if {[regexp {^TROU[0-9]+[A-F]$} $Element]} { set Element "$RepertoireDuGenome/trousprottfa/$Element" } lappend Liste $Element } return [AfficheVariable [join $Liste "\n"] "AvecRienSansFetch"] } proc LesNomsPiques {} { global Piques if { ! [info exists Piques]} { return "" } set ListeDesPiques {} foreach Nom [array names Piques] { lappend ListeDesPiques $Nom } return [join $ListeDesPiques "\n"] } proc Entoure {Boite K} { global oldCouleurOutLine global oldLargeurOutLine if {[regexp "rond" $K]} { return "" } set Id [$K find withtag $Boite] set oldCouleurOutLine($K,$Boite) [$K itemcget $Id -outline] set oldLargeurOutLine($K,$Boite) [$K itemcget $Id -width] $K itemconfigure $Id -outline "pink" -width 8 return [$K itemcget $Id -outline] } proc Detoure {Boite K} { global oldCouleurOutLine global oldLargeurOutLine set Id [$K find withtag $Boite] if {[info exists oldCouleurOutLine($K,$Boite)]} { $K itemconfigure $Id \ -outline [set oldCouleurOutLine($K,$Boite)] \ -width [set oldLargeurOutLine($K,$Boite)] } return [$K itemcget $Id -outline] } proc PiqueBox {K X Y Action} { global Piques set Boite [BoiteDuCourant $K $X $Y] if { $Boite == "" } { return $Boite} set Nom [Box $Boite nom] if { [info exists Piques($Nom)] } { unset Piques($Nom) Detoure $Boite $K return $Boite } if { ! [info exists Piques($Boite)] } { set Piques($Nom) $Nom Entoure $Boite $K return $Boite } } proc MiseAJourDesNouveaux {} { global RepertoireDuGenome global InformeSansDemander set InformeSansDemander 1 foreach Ligne [LesLignesDuFichier "$RepertoireDuGenome/DuGenoscope/nouveau"] { catch {unset Cop1 Cop2} set Append "" regexp "[ExpressionReguliereDesPABs]" $Ligne Nom regexp -indices "ExpressionReguliereDesPABs" $Ligne iNom scan $iNom "%d %d" Moi Prochain incr Prochain set Ligne [string range $Ligne $Prochain end] if { ! [regexp "[ExpressionReguliereDesPABs]" $Ligne Cop1] } { Espionne "$Nom est nouveau" set Append "Pris-nulle-part: Je suis un nouveau" } else { regexp -indices "[ExpressionReguliereDesPABs]" $Ligne iCop1 scan $iCop1 "%d %d" Moi Prochain incr Prochain set Ligne [string range $Ligne $Prochain end] regexp "[ExpressionReguliereDesPABs]" $Ligne Cop2 if { [info exists Cop2]} { Espionne "$Nom $Cop2" foreach Info [LesLignesDuFichier $RepertoireDuGenome/../aby/infos/$Cop1] { append Append "\nPris-dans-$Cop2: $Info" } } Espionne "$Nom $Cop1" foreach Info [LesLignesDuFichier $RepertoireDuGenome/../aby/infos/$Cop1] { append Append "\nPris-dans-$Cop1: $Info" } } Informe $Nom $Append } } proc RangeLesFichiers Extension { global RepertoireDuGenome set Source [pwd] set Destination "$RepertoireDuGenome/$Extension" if { $Source == $Destination } { FaireLire "Attention tu es la ou tu veux ranger." return -1 } foreach Fichier [glob $Source/*.$Extension] { RangeLeFichier $Fichier dans "$Destination" } } proc RangeLeFichier {Fichier dans Destination} { global RepertoireDuGenome set ConFi [ContenuDuFichier $Fichier] if {[regexp "[ExpressionReguliereDesPABs]" $ConFi Nom]} { set Destin "$Destination/$Nom" if { [Sauve $ConFi dans $Destin] == $Destin } { if { [file exists "$RepertoireDuGenome/clustalw/$Nom"]} { File delete -force $Fichier } return $Destin } else { Warne "$Fichier n'a pas ete range en $Destin" return "" } } Warne "$Fichier ne contient pas de nom en [PreFixe]xxxx" return "" } proc CreeLesFichiersTfas {} { global RepertoireDuGenome FaireLire "CreeLesFichiersTfas obsolete" FaireLire "Attention, on ne tient pas compte des nouveaux [PreFixe]s" foreach TFA [split [ContenuDuFichier "$RepertoireDuGenome/DuGenoscope/pep"] ">"] { if { $TFA == "" } { continue } set Nom [string range $TFA 0 6] Sauve ">$TFA" dans "$RepertoireDuGenome/prottfa/$Nom" } } proc ChoisiEtAjouteChampsInfo Texte { global LesChampsInfo if { ! [info exists LesChampsInfo] } { lappend LesChampsInfo "Famille: " lappend LesChampsInfo "Famille: DOS" lappend LesChampsInfo "Famille: P62" lappend LesChampsInfo "Famille: SAP" lappend LesChampsInfo "Famille: Inconnue" lappend LesChampsInfo "Remarque: " lappend LesChampsInfo "Remarque: blastX" lappend LesChampsInfo "Remarque: TblastN" lappend LesChampsInfo "Remarque: profile" lappend LesChampsInfo "Remarque: analyse" lappend LesChampsInfo "CodonStart: " lappend LesChampsInfo "CodonStop: " lappend LesChampsInfo "Fantome: oui par condamnation rR" lappend LesChampsInfo "Enterre: oui force" lappend LesChampsInfo "Fonction: " lappend LesChampsInfo "Transmembrane: " lappend LesChampsInfo "Operon: " lappend LesChampsInfo "AutresHomologues: " lappend LesChampsInfo "CreePAB: " } set NouveauTexte [ChoixParmi $LesChampsInfo] if { $NouveauTexte != "" } { $Texte insert end "$NouveauTexte\n" } } proc ClasseNormalisee Texte { set ListeDesMots [split $Texte ";"] if { [llength $ListeDesMots] == 0 } { set Retour $Texte } if { [llength $ListeDesMots] > 0 } { set Retour [lindex $ListeDesMots 0] } return [string trim $Retour "\."] } proc EspeceNormalisee Texte { set ListeDesMots [split $Texte " "] if { [llength $ListeDesMots] == 0 } { set Retour $Texte } if { [llength $ListeDesMots] == 1 } { set Retour [lindex $ListeDesMots 0] } if { [llength $ListeDesMots] > 1 } { set Retour [join [lrange $ListeDesMots 0 1] " "]} return [string trim $Retour "\."] } proc BoutADNDuTFA {Deb Fin Orient {FichierTFA ""}} { global BoutADNDuTFA if {$FichierTFA==""} { set FichierTFA $BoutADNDuTFA("Current")} set BoutADNDuTFA("Current") $FichierTFA if { ! [info exists BoutADNDuTFA($FichierTFA)]} { set BoutADNDuTFA($FichierTFA) [QueLaSequenceDuFichierTFA $FichierTFA] } set LongueurTotale [expr [string length $BoutADNDuTFA($FichierTFA)]] if {$Fin=="end"} {set Fin $LongueurTotale} incr Deb -1 ; incr Fin -1 set Seq [string range $BoutADNDuTFA($FichierTFA) $Deb $Fin] if {$Orient=="R"} { set Seq [NucToReverseAndComplementNuc $Seq] } return $Seq } proc BoutADNDuTFAOldVersionSansMemoParFichier {Deb Fin Orient {FichierTFA ""}} { global BoutADNDuTFA BoutADNDuTFAFichier if {$FichierTFA==""} { set FichierTFA $BoutADNDuTFAFichier } if { ! [info exists BoutADNDuTFAFichier] || $BoutADNDuTFAFichier!=$FichierTFA} { set BoutADNDuTFAFichier $FichierTFA set BoutADNDuTFA [QueLaSequenceDuFichierTFA $FichierTFA] } set LongueurTotale [expr [string length $BoutADNDuTFA]] if {$Fin=="end"} {set Fin $LongueurTotale} incr Deb -1 ; incr Fin -1 set Seq [string range $BoutADNDuTFA $Deb $Fin] if {$Orient=="R"} { set Seq [NucToReverseAndComplementNuc $Seq] } return $Seq } proc BoutADN {{Debut 1} {Fin -1} {Orient "F"} {Banque ""} {aProbleme ""}} { global ADN TDN RAC global DerniereBase LongueurADN if {$aProbleme!=""} { upvar $aProbleme Probleme } if {$Banque!=""} { return [BoutADNDeLaBanque $Debut $Fin $Orient $Banque $aProbleme] } Wup "Attention on a mis un 'x' en position 0 pour que la 1ere base soit en 1" set Status "ADNetTDNetRACAvailable" if { ! [info exists ADN]} { set Status [ChargeADNetTDNetRAC] } if {$Debut=="Existe"} { if {$Status=="ADNetTDNetRACNotAvailable"} { return 0 } else { return 1 } } if {$Status=="ADNetTDNetRACNotAvailable"} { return "" } if { ! [info exists DerniereBase]} { set LongueurADN [string length $ADN] set DerniereBase [expr $LongueurADN-1] } if {$Fin==-1} { set Fin $DerniereBase } if { $Orient == "F" } { if { $Debut>=1 && $Fin <= $DerniereBase } { set Probleme 0 return [string range $ADN $Debut $Fin] } else { if {$Debut < 1} { set Probleme [expr $Debut-1] return "[BoutADN [expr $DerniereBase+$Debut] $DerniereBase $Orient][BoutADN 1 $Fin $Orient]" } if {$Fin > $DerniereBase} { set Probleme [expr $Fin-$DerniereBase] return "[BoutADN $Debut $DerniereBase $Orient][BoutADN 1 [expr $Fin-$DerniereBase] $Orient]" } } } else { if {$Debut>=1 && $Fin <=$DerniereBase} { set Probleme 0 return [string range $RAC [expr $LongueurADN-$Fin] [expr $LongueurADN-$Debut]] } else { if {$Debut < 1} { set Probleme [expr $Debut-1] return "[BoutADN 1 $Fin $Orient][BoutADN [expr $DerniereBase+$Debut] $DerniereBase $Orient]" } if {$Fin > $DerniereBase} { set Probleme [expr $Fin-$DerniereBase] return "[BoutADN 1 [expr $Fin-$DerniereBase] $Orient][BoutADN $Debut $DerniereBase $Orient]" } } } } proc InformeParSuppressionDuChampPourTous Champ { foreach Boite [ListeDeBoites] { set Nom [Box $Boite nom] InformeParSuppressionDuChamp $Nom $Champ } return } proc InformeParSuppressionDuChamp {Nom Champ {PourVoir ""}} { global RepertoireDuGenome if {$PourVoir==""} { set PourVoir 0 } else { set PourVoir 1 } Wup "Deletes all fields begining with 'Champ' in the infos files (Champ can be with or without ':' )" Wup "Attention use 'ABC:' to remove the Champ ABC (and not ABCD ...)" if {[regexp {\:} $Champ]} { regsub {\:} $Champ {\:} Champ } set FichierInfo "$RepertoireDuGenome/infos/$Nom" if { ! [file exists $FichierInfo]} { return "" } set NouvellesLignes {} set YaSuppression 0 foreach Ligne [LesLignesDuFichier $FichierInfo] { if {[regexp "^$Champ" $Ligne]} { set YaSuppression 1 continue } lappend NouvellesLignes $Ligne } if { ! $PourVoir && $YaSuppression} { SauveLesLignes $NouvellesLignes dans $FichierInfo } return [join $NouvellesLignes "\n"] } proc InformeParMiseAJourPourTous {{Commande ""} {Champ ""} {Test 0} {Ask 0}} { global RepertoireDuGenome global InformeSansDemander Wup "Evals Commande and appends it to info, field Champ if not empty." Wup "If Test is 1 nothing happends" set Test [expr $Test != 0] set Ask [expr $Ask != 0] if {$Commande==""} { set Commande [Entre "\[PutHereTheCommand \$Nom\]"] if {$Commande==""} { return "" } } if { ! [info exists InformeSansDemander]} { set InformeSansDemander 0 } set MemoInformeSansDemander $InformeSansDemander set InformeSansDemander [expr ! $Ask] set n 0 foreach Boite [ListeDeBoites] { set Nom [Box $Boite nom] eval set Valeur $Commande if {$Valeur==""} { continue } incr n if {$Champ!=""} { set Append "$Champ: $Valeur" } else { set Append $Valeur } if {$Test} { Espionne "$Nom ... $Append" } else { Informe $Nom $Append } } set InformeSansDemander $MemoInformeSansDemander return "$n infos/ files were updated" } proc ChargeCodonPreference {} { global CodonPreference CodonPreferenceMini CodonPreferenceMaxi global RepertoireDuGenome if { ! [file exists "$RepertoireDuGenome/DuGenoscope/codon_preference"]} { set CodonPreference Bidon return } set CodonPreferenceMini 999.9 set CodonPreferenceMaxi -999.9 foreach Ligne [LesLignesDuFichier "$RepertoireDuGenome/DuGenoscope/codon_preference"] { scan $Ligne "%s %s %f" Nom Bidon Preference set CodonPreference($Nom) $Preference set CodonPreferenceMini [Mini $Preference $CodonPreferenceMini] set CodonPreferenceMaxi [Maxi $Preference $CodonPreferenceMaxi] } } proc AideEnLigne Selection { global GscopeDir set LesMots [split [join [split $Selection "\n"] " "] " "] set Aucun 1 foreach Mot $LesMots { set FichierHelp "$GscopeDir/help/gscope_[string tolower $Mot]_help.txt" if {[file exists "$FichierHelp"]} { AfficheFichier "$FichierHelp" "AvecAide" set Aucun 0 } } if { $Aucun } { FaireLire "Pas d'aide disponible.\nSelectionner une ligne avec des mots en MAJUSCULE" } } proc Toggle SaVariable { upvar $SaVariable MaVariable set MaVariable [expr ! $MaVariable] return $MaVariable } proc ExtraitTouteInfo Nom { return [ExtraitInfo $Nom] } proc ValiDE Nom { set DE [ExtraitInfo $Nom "ValiDE:"] if {$DE==""} { set DE [ExtraitInfo $Nom "ValiDEProt:"] } if {[string equal -nocase "no value" $DE]} { set DE "" } return $DE } proc ValiGN Nom { set GN [ExtraitInfo $Nom "ValiGN:"] if {$GN==""} { set GN [ExtraitInfo $Nom "ValiGNProt:"] } if {[string equal -nocase "no value" $GN]} { set GN "" } return $GN } proc ExtraitInfo {Nom {Champ ""}} { global RepertoireDuGenome global ListeDeBoites global InfoEnMemoire global ListeDesContenuInfo global LesInfosRestentSurDisque if { ! [regexp -nocase {[a-z]} $Nom]} { return "" } if {0 && [info exists LesInfosRestentSurDisque]} { if { ! [file exists "$RepertoireDuGenome/infos/$Nom"]} { return "" } set Info [ContenuDuFichier "$RepertoireDuGenome/infos/$Nom"] } else { if { ! [info exists InfoEnMemoire($Nom)]} { if { ! [info exists InfoEnMemoire(Temoin)]} { foreach Boite [ListeDeBoites] { if { ! [regexp -nocase {[a-z]} $Boite]} { continue } set FichierInfo "$RepertoireDuGenome/infos/$Boite" if {[file exists $FichierInfo]} { set InfoEnMemoire($Boite) [ContenuDuFichier $FichierInfo] lappend ListeDesContenuInfo [string toupper [set InfoEnMemoire($Boite)]] } else { lappend ListeDesContenuInfo [string toupper "Nom: $Boite"] } } set InfoEnMemoire(Temoin) "Info est charge en memoire" } if {! [info exists InfoEnMemoire($Nom)]} { set FichierInfo "$RepertoireDuGenome/infos/$Nom" if {[file exists $FichierInfo]} { set InfoEnMemoire($Nom) [ContenuDuFichier $FichierInfo] } else { set InfoEnMemoire($Nom) "" } } } set Info [set InfoEnMemoire($Nom)] } #rR Attention tout est en majuscule si AllInfos if {$Nom=="AllInfos"} { return [join $ListeDesContenuInfo "\n"] } regsub {\:$} $Champ "" Champ if { $Champ == "" } { return $Info } set LesValeurs {} foreach Ligne [split $Info "\n"] { if { ! [regexp -nocase -- "^$Champ\: *" $Ligne] } { continue } regsub -nocase -- "^$Champ\: *" $Ligne "" Valeur lappend LesValeurs $Valeur } set Valeur [join $LesValeurs " / "] return $Valeur set Valeur "" set Separateur "" foreach Ligne [split $Info "\n"] { if {[regexp -nocase -- "^$Champ\:" $Ligne] } { set iValeur [expr [string first ":" $Ligne]+1] append Valeur "${Separateur}[string trim [string range $Ligne $iValeur end]]" set Separateur " / " } } return $Valeur } proc FetchCat {Access {Quoi ""}} { #rR completement obsolete car fetch n'existe plus return "" return [exec fetchcat $Access $Quoi] } proc FetchNoms Access { #rR completement obsolete car fetch n'existe plus return "" return [FetchCat $Access LesNoms] } proc FetchTest Access { #rR completement obsolete car fetch n'existe plus return 0 return [FetchCat $Access "LeTest"] } proc CorrigeLesOutliers {} { FaireLire "Attention obsolete" exit foreach Fichier [glob "[RepertoireDuGenome]/outlier/*"] { set Texte [ContenuDuFichier $Fichier] if {[regexp "^I\ndid" $Texte]} { Espionne $Fichier Sauve "I didn't find any Batrachochytrium_dendrobatidis or Fungi" dans $Fichier } } exit } proc OutlierOrganism {{Orga ""}} { global OutlierOrganism if {$Orga!=""} { if {[info exists OutlierOrganism]} { unset OutlierOrganism } } if { ! [info exists OutlierOrganism]} { set Orga "" FaireLire "Please enter the Organism to test as outlier" while {$Orga==""} { set Orga [string trim [Entre "Batrachochytrium dendrobatidis"]] regsub -all " " $Orga "_" Orga if {[Tax $Orga TaxId]==""} { FaireLire "I did not found the taxon '$Orga', please enter an otherone." set Orga "" continue } } set OutlierOrganism $Orga } return $OutlierOrganism } proc ReferenceClade {{Orga ""}} { global ReferenceClade if {$Orga!=""} { if {[info exists ReferenceClade]} { unset ReferenceClade } } if { ! [info exists ReferenceClade]} { set Orga "" FaireLire "Please enter the Reference Clade" while {$Orga==""} { set Orga [string trim [Entre "Fungi"]] regsub -all " " $Orga "_" Orga if {[Tax $Orga TaxId]==""} { FaireLire "I did not found the taxon '$Orga', please enter an otherone." set Orga "" continue } } set ReferenceClade $Orga } return $ReferenceClade } proc BeauScore {} { foreach Ligne [LesLignesDuFichier outlierscore] { scan $Ligne "%s %s" Nom S if {$S==""} { set S -2} set B [format "%8.1e" $S] Espionne $B lappend LesBeaux "$Nom $B" } SauveLesLignes $LesBeaux dans "[RepertoireDuGenome]/fiches/outlierscorebeaux" exit } proc OutlierScore {{Nom ""}} { global OutlierScore if {[info exists OutlierScore($Nom)]} { return $OutlierScore($Nom)} if {[info exists OutlierScore("EstCharge")]} { return "" } set OutlierScore("EstCharge") 1 set FichierOutlierScore "[Fiches]/outlierscore" if {[file exists $FichierOutlierScore]} { foreach Ligne [LesLignesDuFichier $FichierOutlierScore] { scan $Ligne "%s" N set Score "" regsub "$N +" $Ligne "" Score set OutlierScore($N) $Score } return [OutlierScore $Nom] } set LesAbsents {} set LesPresents {} foreach FichierOutlier [lsort [glob -nocomplain "[RepertoireDuGenome]/outlier/*"]] { set Queue [file tail $FichierOutlier] if { ! [EstUnPAB $Queue]} { continue } set BestOut "" set BestRef "" foreach Ligne [LesLignesDuFichier $FichierOutlier] { set Ligne [string range $Ligne 0 40] set Absent 0 if {[regexp "^I" $Ligne]} { set LesAbsents [list -1] lappend LesNomsDuScore(-1) $Queue set OutlierScore($Queue) "+999" set Absent 1 break } if {[regexp {^\*} $Ligne]} { if {$BestOut==""} { set BestOut $Ligne ; regsub -all {\*} $BestOut " " BestOut } if {$BestRef!=""} { break } } else { if {$BestRef==""} { set BestRef $Ligne } if {$BestOut!=""} { break } } } if { $Absent } { continue } set PnOut 1e+10 set PnRef 1e+10 if {$BestOut!=""} { scan $BestOut "%s" PnOut ; regsub -nocase {([0-9]+).(e.*)} $PnOut "\\1.\\2" PnOut } if {$BestRef!=""} { scan $BestRef "%s" PnRef ; regsub -nocase {([0-9]+).(e.*)} $PnRef "\\1.\\2" PnRef } if {$PnRef<1.e-200} { if {$PnRef==$PnOut} { set Score 1. } if {$PnOut>1.e-200} { set Score 99999 } } else { set Score [expr $PnOut/$PnRef] } set Ori $Score if {$Score==""} { set Score "+998" } else { set Score [format "%8.1e" $Score] set Ori "$Ori/$Score" regsub {[^e]+e} $Score "" Exp if {[regexp {\+} $Score]} { set Signe "+" } else { set Signe "-" } regsub {[\+\-]} $Exp "" N if {$N==0} { set Exp "+0" } else { set N [string trimleft $N "0"] set Exp "$Signe$N" } } set Score [format "%4s = %s / %s" $Exp $PnOut $PnRef] lappend LesPresents $Exp lappend LesNomsDeExp($Exp) $Queue set OutlierScore($Queue) $Score } set LesPresents [lsort -unique -real $LesPresents] set LesAbsents [lsort -unique -real $LesAbsents] foreach Exp $LesPresents { foreach N $LesNomsDeExp($Exp) { lappend LesNomScore "$N $OutlierScore($N)" } } foreach Exp $LesAbsents { foreach N $LesNomsDuScore($Exp) { lappend LesNomScore "$N $OutlierScore($N)" } } SauveLesLignes $LesNomScore dans $FichierOutlierScore return [OutlierScore $Nom] } proc OutlierOrganismInBlastPourTous {{Outlier ""} {Clade ""} {Seuil ""}} { file mkdir "[RepertoireDuGenome]/outlier" set I 0 foreach Nom [ListeDesPABs] { if {$I%100==0} { Espionne "outlier/$Nom" } incr I OutlierOrganismInBlast $Nom $Outlier $Clade $Seuil "Save" } } proc OutlierOrganismInBlast {Nom {Outlier ""} {Clade ""} {Seuil ""} {GetWhat ""}} { #rR quand on donne un outlier on n'utilise pas les fichiers ./outlier/Nom précalculés if {$GetWhat==""} { set GetWhat "Show" } set LaSortie {} if {$Outlier==""} { set FichierOutliers [GscopeFile $Nom outlier] if {[file exists $FichierOutliers]} { set LaSortie [LesLignesDuFichier $FichierOutliers] } } if {$LaSortie=={}} { if {$Seuil==""} { set Seuil 99999 } if {$Outlier ==""} { set Outlier [OutlierOrganism] } if {$Clade ==""} { set Clade [ReferenceClade] } set iOutlier [Tax $Outlier TaxId] set iClade [Tax $Clade TaxId] set LesOrgaTrie [LesLignesDuFichier [GscopeFile $Nom "taxobla"]] if {$LesOrgaTrie=={}} { return "The file taxobla/$Nom does not exist" } foreach Ligne $LesOrgaTrie { lassign [split $Ligne "\t"] Expect Score TaxId OS Reste set Score [string trim $Score] set Expect [string trim $Expect] if {$Expect > $Seuil} { break } set TaxId [string trim $TaxId] set OS [string trim $OS] set Reste [string trim $Reste] if {[QuestionDeScience "EVImm" "ret Descendant $iOutlier $TaxId ForceAncestorFirst"]} { lappend LaSortie "*** $Ligne" } else { if {[QuestionDeScience "EVImm" "ret Descendant $iClade $TaxId ForceAncestorFirst"]} { lappend LaSortie " $Ligne" } } } if {$LaSortie=={}} { set LaSortie [list "I didn't find any $Outlier or $Clade"] } } if {[regexp "/" $GetWhat] || [string equal -nocase "Save" $GetWhat]} { set FichierOutliers $GetWhat if {[string equal -nocase "Save" $GetWhat]} { set FichierOutliers [GscopeFile $Nom outlier] } return [SauveLesLignes $LaSortie dans $FichierOutliers] } if {[string equal -nocase "GetList" $GetWhat]} { return $LaSortie } if {[string equal -nocase "GetText" $GetWhat]} { return [join $LaSortie "\n"] } return [AfficheListe $LaSortie] } proc TestLODB {fileBlast} { set fileBlast "/genomics/link/CilioCarta/blastp/HSAP00001" set fileBlast "/home/kress/elephas.blastp" set blast [ContenuDuFichier $fileBlast] set B64 [Base64Encode $blast] # set orgas [QuestionDeScience EVImm "ret TaxonomyDuBlast $B64 - - GetText"] set orgas [TaxonomyDuBlast $B64 KeepAll - GetText] Espionne $orgas } proc LesHitsDuBlast {Fichier {SeuilExpect 0.001} {MaxListe 99999} {Quoi ""}} { DecortiqueBlast $Fichier $SeuilExpect $MaxListe Query lBId lA lDE lProfil lPN set Retour {} set LesBId {} set LesA {} foreach BId $lBId A $lA DE $lDE PN $lPN { lappend LesBId $BId lappend LesA $A set Hit "$PN $BId $A $DE" if {$Quoi=="BestHit"} { return $Hit } lappend Retour [format "%-75s %s" "$BId $A $DE" $PN] } if {[regexp "I" $Quoi]} { return $LesBId } if {[regexp "A" $Quoi]} { return $LesA } return $Retour exit } proc InformeFromBestBlastHitPourTous {} { set LesBest {} foreach Nom [ListeDesPABs] { lappend LesBest "$Nom [InformeFromBestBlastHit $Nom SansDemander]" } return $LesBest } proc InformeFromBestBlastHit {Nom {SansDemander ""}} { set Best [LesHitsDuBlast $Nom "" 1 "BestHit"] if {$Best==""} { return "" } scan $Best "%s %s %s" PN BId Ac set DE [join [lrange $Best 3 end]] set Bank "" if {[regexp {\|} $BId]} { lassign [split $BId "|"] Bank A I set DE "$Ac $DE" set BId $I set Ac $A } Informe$SansDemander $Nom "=BestBlastHitID: $BId" Informe$SansDemander $Nom "=BestBlastHitAC: $Ac" Informe$SansDemander $Nom "=BestBlastHitDE: $DE" Informe$SansDemander $Nom "=BestBlastHitPN: $PN" return $Best } proc DecortiqueBlast {TexteOuListeOuFichier {CutPN ""} {MaxListe ""} {aQuery ""} {alBanqueId ""} {alAccess ""} {alDE ""} {alProfil ""} {alPN ""} {alPartieSegAli ""}} { set NoAccessInHit 0 if {$alAccess=="NoAccessInHit"} { set NoAccessInHit 1 set alAccess "" } if {$CutPN==""} { set CutPN 0.001 } if {$MaxListe==""} { set MaxListe 99999 } if {$aQuery!="BlastHitCount" || $aQuery!="RetourneBlastTrie"} { if {$aQuery !=""} { upvar $aQuery Query } if {$alBanqueId !=""} { upvar $alBanqueId lBanqueId } if {$alAccess !=""} { upvar $alAccess lAccess } if {$alDE !=""} { upvar $alDE lDE } if {$alProfil !=""} { upvar $alProfil lProfil } if {$alPN !=""} { upvar $alPN lPN } } if {$alPartieSegAli != ""} { if { ! [string equal $alPartieSegAli "LongDefinition"]} { upvar $alPartieSegAli lPartieSegAli } set OnVeutPartieSegAli 1 set lPartieSegAli {} } else { set lPartieSegAli {} set OnVeutPartieSegAli 0 } if {$aQuery=="RetourneBlastTrie"} { set RetourneBlastTrie 1 } else { set RetourneBlastTrie 0 } set AvecMemo 0 if {$AvecMemo} { global MemoDecortique set LesVarMemo {FichierMemo NombreDeBons Query lBanqueId lAccess lDE lProfil lPN lPartieSegAli} set FichierMemo $TexteOuListeOuFichier if {[info exists MemoDecortique(FichierMemo)] && \ ! $RetourneBlastTrie && \ $MemoDecortique(FichierMemo)==$FichierMemo} { foreach V $LesVarMemo { set $V [set MemoDecortique($V)] } return $NombreDeBons } if {[info exists MemoDecortique]} { unset MemoDecortique } } set Fichier "" if {[EstUnPAB $TexteOuListeOuFichier] && [file exists [GscopeFile $TexteOuListeOuFichier blastp]]} { set ListeDesLignes [LesLignesDuFichier [GscopeFile $TexteOuListeOuFichier blastp]] } elseif {[regexp "\n" $TexteOuListeOuFichier]} { set ListeDesLignes [split $TexteOuListeOuFichier "\n"] } elseif {[regexp " " $TexteOuListeOuFichier]} { set ListeDesLignes $TexteOuListeOuFichier } elseif {[file exists $TexteOuListeOuFichier]} { set Fichier $TexteOuListeOuFichier set ListeDesLignes [LesLignesDuFichier $TexteOuListeOuFichier] } else { FaireLire "I don't know how to analyse the blast\n$TexteOuListeOuFichier\n\ It's not a text, not a list, not a file" return "" } if {$ListeDesLignes=={}} { set Query "" set lBanqueId {} set lAccess {} set lDE {} set lProfil {} set lPN {} set lPartieSegAli {} return 0 } if {$CutPN == "" } { set CutPN 0.001 } if {$MaxListe == "" } { set MaxListe "SansLimiteDeNombre" } if {$CutPN == "SansSeuilExpect"} { set CutPN 9999.9 } set RenvoieLesHitsAvecSegAliUniquement 1 if {$MaxListe == "SansLimiteDeNombreDuTout"} { set MaxListe "SansLimiteDeNombre" set RenvoieLesHitsAvecSegAliUniquement 0 } if {$MaxListe == "SansLimiteDeNombre"} { set MaxListe 99999 } set lBanqueId {} set lAccess {} set lDE {} set lProfil {} set lPN {} set NombreDeBons 0 set PremierMot "" scan [join [lrange $ListeDesLignes 0 3] " "] "%s" PremierMot set RechercheDansFichier 1 while {1} { # set PourBlastP [string equal -nocase $PremierMot "BLASTP"] # set PourBallast [string equal -nocase $PremierMot "Ballast"] # set PourTBlastX [string equal -nocase $PremierMot "TBLASTX"] # set PourBlastN [string equal -nocase $PremierMot "BLASTN"] # set PourTBlastN [string equal -nocase $PremierMot "TBLASTN"] set PourBlastP [expr ! [string compare $PremierMot "BLASTP"]] set PourBlastX [expr ! [string compare $PremierMot "BLASTX"]] set PourBallast [expr ! [string compare $PremierMot "BALLAST"]] set PourTBlastX [expr ! [string compare $PremierMot "TBLASTX"]] set PourBlastN [expr ! [string compare $PremierMot "BLASTN"]] set PourTBlastN [expr ! [string compare $PremierMot "TBLASTN"]] if {[expr $PourBlastP+$PourBlastX+$PourBallast+$PourTBlastX+$PourBlastN+$PourTBlastN] == 1} { break } if {$RechercheDansFichier && \ [regexp "BLASTP|BLASTX|Ballast|TBLASTX|BLASTN|TBLASTN" \ [join [lrange $ListeDesLignes 0 9] " "] PremierMot]} { set RechercheDansFichier 0 continue } if {[OuiOuNon "I can't choose between BLASTP BLASTX Ballast TBLASTX BLASTN TBLASTN\n \ Could you help me ?" 0]} { set PremierMot [Entre "BLASTP"] } else { if {[OuiOuNon "Do I use BLASTP ?" 0]} { set PremierMot "BLASTP" ; continue } if {[OuiOuNon "Do I skipp ?"]} { return "" } if {[OuiOuNon "Do I stop ?"]} { exit } } } set PositionPN 0 set PositionScore 1 if {$PourBallast} { set TexteSPSA "Sequences producing " set iProfil 62 set FinDE 65 } elseif {$PourTBlastX} { set PositionPN 0 set PositionScore 1 set TexteSPSA "Sequences producing " set FinDE 66 set iProfil 67 } else { set TexteSPSA "Sequences producing " set FinDE 65 set iProfil 66 } set IndexQuery [lsearch -regexp $ListeDesLignes "Query="] if { $IndexQuery == -1 } { FaireLire "Please select also the \"Query=\" line." return -1 } if {$aQuery=="BlastHitCount"} { set Query "NotImportantForBlastHitCount" set Nomquery "NotImportantForBlastHitCount" } else { set PossiblePAB [file tail $Fichier] set Query [QueryDeLaLigne [lindex $ListeDesLignes $IndexQuery] "DoNotCreateIt" $PossiblePAB] set NomQuery [file tail $Query] } if {[lsearch -regexp [lrange $ListeDesLignes 0 30] "No hits found"] != -1} { return 0 } set IndexSPSA [lsearch -regexp $ListeDesLignes $TexteSPSA] if { $IndexSPSA == -1 } { return 0} set Saut 2 if {[regexp -nocase {[a-z]} [lindex $ListeDesLignes [expr $IndexSPSA + 1]]]} { incr Saut } set PartieRestante [lrange $ListeDesLignes [incr IndexSPSA $Saut] end] set PartieEntete [lrange $ListeDesLignes 0 $IndexSPSA] set IndexPremierChevron [lsearch -regexp $PartieRestante {^>}] if { $IndexPremierChevron == -1 } { set PartieScores [lrange $PartieRestante 0 end] set PartieSegAli {} } else { set PartieScores [lrange $PartieRestante 0 [expr $IndexPremierChevron-1]] set PartieSegAli [lrange $PartieRestante $IndexPremierChevron end] } set OldPN -99999 set zPN 0 set IlFautTrier 0 set EstUnPsiBlast 0 set Profil 0 foreach Ligne $PartieScores { if { $Ligne == "" } { continue } if { [regexp "Sequences not found previously" $Ligne] } { set EstUnPsiBlast 1 continue } regsub "!" $Ligne " " Ligne if { $PourBallast && [regexp {\-{50}} $Ligne]} { continue } if { ! [regexp {[a-zA-Z]} $Ligne]} { if {[regexp "^ Database\:" $Ligne]} { break } if {[OuiOuNon "$Ligne\n do I skip this line ?"]} { continue } if {[OuiOuNon "$Ligne\n do I stop processing ?"]} { break } } if {[regexp {\\\\End} $Ligne]} { break } if { [regexp {^[0-9a-zA-Z]} $Ligne]} { set FromNCBI 0 set Access "" #rR le NCBI ne met plus d'access mais il y a deux blancs ;) if {[regexp {^([^ ]+) } $Ligne Match B]} { regsub " " $Ligne " $B " Ligne set FromNCBI 1 } if {! [scan $Ligne "%s %s" BanqueId Access]} {break} set OriginalBanqueId $BanqueId set OriginalAccess $Access set AccessLu $Access if {[regexp -nocase {^UniRef} $BanqueId]} { set Access $BanqueId } if {[regexp -nocase {[\(\)\{\}\[\]]} $Access]} { set Access $BanqueId } if { ! [EstUnAccessPDB $Access] && \ ([EstUnAccessPDB $BanqueId] || ! [regexp -nocase {[a-z_]} $Access])} { set Access $BanqueId } set Profil [expr ![string compare [string range $Ligne $iProfil $iProfil] "*"]] #rR 2019/01/22 if {[regexp {[0-9]+% *$} $Ligne]} { regsub { +[0-9]+% *$} $Ligne "" Ligne } set ScorePN [string trim $Ligne] regsub -all { +} $ScorePN " " ScorePN set LesMots [split $ScorePN " "] set sScore [lindex $LesMots end-$PositionScore] scan $sScore "%d" Score set sPN [lindex $LesMots end-$PositionPN] if {$sScore=="" || $sPN==""} { break } if {$FromNCBI} { set DE [StringSuivant "$OriginalBanqueId $OriginalBanqueId " dans $Ligne] } else { set DE $Ligne set DE [StringSuivant "$OriginalBanqueId" dans $DE] if { ! [EstUnAccessPDB $OriginalBanqueId] && \ ! [regexp -nocase {[^a-z0-9_]} $AccessLu] &&\ ! [regexp -nocase {^UniRef} $BanqueId]} { set DE [StringSuivant "$OriginalAccess" dans $DE] } } regsub "$sPN *$" $DE "" DE regsub "$sScore *$" $DE "" DE set DE [string trim $DE] } else { if { ! $PourBallast} { if {[regexp "^ Database\:" $Ligne]} { break } if {[OuiOuNon "$Ligne\n do I skip this line ?"]} { continue } if {[OuiOuNon "$Ligne\n do I stop processing ?"]} { break } } set Ligne [string trim $Ligne] if {! [scan $Ligne "%s %s" BanqueId Access]} { if {[regexp "^ Database\:" $Ligne]} { break } if {[OuiOuNon "$Ligne\n do I skip this line ?"]} { continue } if {[OuiOuNon "$Ligne\n do I stop processing ?"]} { break } } set DE [string range $Ligne [string length "$BanqueId $Access "] end] set Profil $OldProfil set PN $OldPN } regsub {^[eE]} $sPN "1e" sPN # scan $sPN "%f" PN set PN $sPN if {[catch { expr $PN > $CutPN } ]} { Warne "Oh le vilain $PN" set PN 1E-200 } if { ! $PourBallast && [expr $PN > $CutPN] } { break } #rR attention depuis 2013/10/16 on ameliore toujours DE ecrasant l'autre (avant il fallait OnVeutPartieSegAli) if { $PartieSegAli!={} } { set PartieSegAliRestante [lrange $PartieSegAli 0 end] ;#rR il y avait 1 ???? corrige 2013/10/16 set IndexProchainChevron [lsearch -start 1 -regexp $PartieSegAliRestante {^>}] if { [expr $IndexProchainChevron == -1] } { set IndexProchainChevron [lsearch -start 1 -regexp $PartieSegAliRestante {^ *Database:}] if { [expr $IndexProchainChevron != -1] } { set IndexFinSegAliCourante [expr $IndexProchainChevron-1] } else { set IndexFinSegAliCourante end } } else { set IndexFinSegAliCourante [expr $IndexProchainChevron-1] } set SegAliCourante [lrange $PartieSegAli 0 $IndexFinSegAliCourante] if {$OnVeutPartieSegAli} { lappend lPartieSegAli $SegAliCourante } ;#rR a mis le test ici pour toujours ameliorer la DE set LeMeilleurDE {} foreach LigneDuSegAli $SegAliCourante { if { ! [regexp -nocase {[0-9a-z]} $LigneDuSegAli]} { break } set MeilleurDE [string trim $LigneDuSegAli] regsub {^>[^ ]+ } $MeilleurDE "" MeilleurDE if { ! $FromNCBI } { regsub {^[^ ]+ } $MeilleurDE "" MeilleurDE } lappend LeMeilleurDE [string trim $MeilleurDE] } set MeilleurDE [join $LeMeilleurDE " "] if {[string length $MeilleurDE] > [string length $DE]} { set DE $MeilleurDE } set PartieSegAli [lrange $PartieSegAliRestante $IndexProchainChevron end] } if {$OldPN>$PN} { set IlFautTrier 1 } set OldPN $PN set OldProfil $Profil if {$NoAccessInHit} { set DE "$Access $DE" set Access "-" } lappend lBanqueId $BanqueId lappend lAccess $Access lappend lDE $DE lappend lProfil $Profil lappend lPN $PN lappend lScore $Score set PNUnique "$PN [incr zPN]" lappend lPNUnique $PNUnique set LIduPN($PNUnique) $Ligne set BIduPN($PNUnique) $BanqueId set ACduPN($PNUnique) $Access set DEduPN($PNUnique) $DE set PRduPN($PNUnique) $Profil set PNduPN($PNUnique) $PN set SCduPN($PNUnique) $Score set SAduPN($PNUnique) [join $SegAliCourante "\n"] incr NombreDeBons if {$NombreDeBons >= $MaxListe } { break } if {$RenvoieLesHitsAvecSegAliUniquement && \ $OnVeutPartieSegAli && $IndexFinSegAliCourante == "end" } { break } } if {$IlFautTrier} { set lPNUnique [lsort -real -index 0 $lPNUnique] set lLignes {} set lBanqueId {} set lAccess {} set lDE {} set lProfil {} set lPN {} set lScore {} foreach PNUnique $lPNUnique { lappend lLignes $LIduPN($PNUnique) lappend lBanqueId $BIduPN($PNUnique) lappend lAccess $ACduPN($PNUnique) lappend lDE $DEduPN($PNUnique) lappend lProfil $PRduPN($PNUnique) lappend lPN $PNduPN($PNUnique) lappend lScore $SCduPN($PNUnique) lappend lSegAli $SAduPN($PNUnique) } } global ScoreDansProfil if {[info exists ScoreDansProfil] && $ScoreDansProfil && [info exists lScore]} { set lProfil $lScore } if {$RetourneBlastTrie} { if {$IlFautTrier} { set BlastTrie [join $PartieEntete "\n"] append BlastTrie "\n" append BlastTrie [join $lLignes "\n"] append BlastTrie "\n\n" #rR append BlastTrie [join $PartieSegAli "\n"] append BlastTrie [join $lSegAli "\n"] append BlastTrie "\n" return $BlastTrie } else { return [join $ListeDesLignes "\n"] } } if {$AvecMemo} { foreach V $LesVarMemo { set MemoDecortique($V) [set $V] } } return $NombreDeBons } proc ChangeLaCommande Coco { global Commandes CommandesDefaut if { $Coco == "" } { return } set Commandes($Coco) [string trim [EntreTexte [set Commandes($Coco)]]] if { [Commandes($Coco)] == "" } {set Commandes($Coco) $CommandesDefaut($Coco) } } proc ChoixGN ListeDesGN { global retourChoixGN catch {destroy .choixGN} catch {unset retourChoixGN} toplevel .choixGN tk_optionMenu .choixGN.o retourChoixGN "Choisis le bon ..." foreach GN $ListeDesGN { .choixGN.o.menu add radiobutton -label $GN -variable retourChoixGN } pack .choixGN.o -side left -padx 25 -pady 25 tkwait variable retourChoixGN destroy .choixGN return $retourChoixGN } proc TestChoixParmi {} { set LCP [ColorationsPossibles] set LCPT [LaTraduction $LCP] Espionne [ChoixParmiJoli $LCP {} $LCPT] exit } proc LesFrames {} { return [ChoixDesPresents [LesProceduresExistantes]] } proc ChoixDesPresents {Liste {ListeDeTextes {}} {Invite "Select ... and validate."}} { return [lindex [LesPresentsAbsentsIndifferents $Liste $ListeDeTextes $Invite] 0] } proc LesPresentsAbsentsIndifferents {Liste {ListeDeTextes {}} {Invite "Select ... and validate."}} { global retourChoixMultiple global ChoixMultipleRadio global validOk Wup "returns 3 lists" if {$ListeDeTextes=={}} { set ListeDeTextes $Liste } if {[llength $Liste] == 0 } { return {} } set n 0 set LesLooks {} foreach Element $Liste { incr n set Look "a$n" lappend LesLooks $Look } if { [PourWscope] } { LesPAIs [ChoixMultiple $Look $ListeDeTextes] } else { set w [NomDe fenetre] catch {destroy $w} catch {unset validOk} toplevel $w wm geometry $w +300+100 wm title $w "$Invite" set MaxWidth 0 foreach Texte $ListeDeTextes { if { [string length $Texte] > $MaxWidth } { set MaxWidth [string length $Texte] } } frame $w.frame pack $w.frame -expand yes -fill both set BouRad "$w.frame.radios" set ScroHor "$w.frame.xscroll" set ScroVer "$w.frame.yscroll" scrollbar $ScroVer -command "$BouRad yview" scrollbar $ScroHor -command "$BouRad xview" \ -orient horizontal set CanvaScreenX 300 set CanvaScreenY 25 set HauteurUneLigne 25 canvas $BouRad \ -width $CanvaScreenX \ -height $CanvaScreenY \ -xscrollcommand "$ScroHor set" \ -yscrollcommand "$ScroVer set" set HauteurTotale 5 foreach Look $LesLooks Element $Liste Texte $ListeDeTextes { set FLook "$BouRad.$Look" frame $FLook radiobutton $FLook.radioP -relief flat -variable ChoixMultipleRadio($Look) -value p radiobutton $FLook.radioA -relief flat -variable ChoixMultipleRadio($Look) -value a radiobutton $FLook.radioI -relief flat -variable ChoixMultipleRadio($Look) -value i label $FLook.text -width $MaxWidth -text $Texte -anchor "w" pack $FLook.radioP $FLook.radioA $FLook.radioI $FLook.text -side left $BouRad create window 0 $HauteurTotale -anchor "nw" -window $FLook incr HauteurTotale $HauteurUneLigne } $BouRad configure -scrollregion [list 0 0 $CanvaScreenX $HauteurTotale] grid $w.frame.radios -row 0 -column 0 -rowspan 1 -columnspan 1 -sticky nsew grid $w.frame.yscroll -row 0 -column 1 -rowspan 1 -columnspan 1 -sticky nsew grid $w.frame.xscroll -row 1 -column 0 -rowspan 1 -columnspan 1 -sticky nsew grid rowconfig $w.frame 0 -weight 1 -minsize 0 grid columnconfig $w.frame 0 -weight 1 -minsize 0 $BouRad configure -height [Mini [expr $HauteurTotale+60] 600] set Boutons $w.termine frame $Boutons button $Boutons.dismiss -text "Dismiss" -background "red" -command { set validOk 0 } button $Boutons.toutpresent -text "All +" -background "yellow" -command { foreach Look [array names ChoixMultipleRadio] { set ChoixMultipleRadio($Look) p } } button $Boutons.toutabsent -text "All -" -background "orange" -command { foreach Look [array names ChoixMultipleRadio] { set ChoixMultipleRadio($Look) a } } button $Boutons.toutindif -text "All X" -background "lightblue" -command { foreach Look [array names ChoixMultipleRadio] { set ChoixMultipleRadio($Look) i } } button $Boutons.validate -text "Validate" -background "green" -command { set validOk 1 } pack $Boutons -side top pack $Boutons.dismiss $Boutons.toutpresent $Boutons.toutabsent $Boutons.toutindif $Boutons.validate -side left tkwait variable validOk destroy $w if { ! $validOk} { return [list {} {} {}] } foreach Look $LesLooks { lappend LesPAIs [set ChoixMultipleRadio($Look)] } } set retourChoixMultiple {} set LesPresents {} set LesAbsents {} set LesIndifferents {} foreach Look $LesLooks Element $Liste PAI $LesPAIs { if { $PAI == "p" } { lappend LesPresents $Element } if { $PAI == "a" } { lappend LesAbsents $Element } if { $PAI == "i" } { lappend LesIndifferents $Element } } return [list $LesPresents $LesAbsents $LesIndifferents] } proc ChoixMultiple {Liste {ListeDeTextes {}} {Invite "Select ..."}} { global retourChoixMultiple global ChoixMultipleRadio if {[PourWscope]} { return $Liste } if {$ListeDeTextes=="" } { set ListeDeTextes $Liste } if {[llength $Liste] == 0 } { return "" } set w [NomDe fenetre] catch {destroy $w} catch {unset validOk} toplevel $w wm geometry $w +300+100 #tk_optionMenu $w.o retourChoixParmi $Invite #$w.o configure -background "Seagreen" -foreground "black" -bd 20 #frame .question -height [llength $Liste] -width 10c set MaxWidth 0 foreach Texte $ListeDeTextes { if { [string length $Texte] > $MaxWidth } { set MaxWidth [string length $Texte] } } foreach Element $Liste Texte $ListeDeTextes { frame $w.$Element radiobutton $w.radio${Element}p -relief flat -variable ChoixMultipleRadio($Element) -value p radiobutton $w.radio${Element}a -relief flat -variable ChoixMultipleRadio($Element) -value a radiobutton $w.radio${Element}i -relief flat -variable ChoixMultipleRadio($Element) -value i text $w.text${Element} -height 1 -width $MaxWidth $w.text${Element} insert end $Texte #$w.o.menu add radiobutton -background $Couleur -foreground "black" \ # -label $Element -variable retourChoixParmi } frame $w.termine button $w.dismiss -text "Dismiss" -background "red" -command { set validOk 0 } button $w.toutpresent -text "Present" -command { foreach Element [array names ChoixMultipleRadio] { set ChoixMultipleRadio($Element) p } } button $w.toutabsent -text "Absent" -command { foreach Element [array names ChoixMultipleRadio] { set ChoixMultipleRadio($Element) a } } button $w.toutindif -text "Indifferent" -command { foreach Element [array names ChoixMultipleRadio] { set ChoixMultipleRadio($Element) i } } button $w.validate -text "Validate" -background "green" -command { set validOk 1 } # pack $w.o set First "" foreach Element $Liste { pack $w.$Element pack $w.radio${Element}p $w.radio${Element}a $w.radio${Element}i $w.text${Element} -in $w.$Element -side left -fill both -expand 1 } pack $w.termine -side top pack $w.toutpresent $w.toutabsent $w.toutindif $w.validate $w.dismiss -in $w.termine -side left tkwait variable validOk destroy $w set retourChoixMultiple {} foreach Element $Liste { set Var ChoixMultipleRadio($Element) if { [set $Var] == "p" } { lappend retourChoixMultiple [string toupper $Element] } else { if { [set $Var] == "a" } { lappend retourChoixMultiple [string tolower $Element] } else { # lappend retourChoixMultiple $Element } } } return $retourChoixMultiple } proc ClosCanalEtMontreBlaste {Canal Out} { close $Canal set Fenetre [AfficheFichier $Out "AvecGrapheAvecSegAlignementAvecAligneurs"] return if {[gets $Canal]} { return 1 } gets $Canal Message set Texte "I got an error from batch blast with following message :\n$Message" set Fenetre [AfficheVariable $Texte "ErrorFromBlast"] return 0 } proc ClosCanalEtMontreMSF {Aligneur Canal MSF Log} { global LaFenetreDesMSF close $Canal if { [info exists LaFenetreDesMSF($MSF)] } { Illumine $MSF [set LaFenetreDesMSF($MSF)] } else { set Fenetre [AfficheFichier $MSF "GrandeLargeurAvecEtudeMSF"] BoutonneLaFenetre $Fenetre "Log" "AfficheFichier $Log AvecRien" } } proc ClosExpoCourante {} { global ExpoCourante catch {unset ExpoCourante} } proc ClosGalerieCourante {} { global GalerieCourante global ExpoCourante global xPointDeRaccord yPointDeRaccord catch {unset xPointDeRaccord} catch {unset yPointDeRaccord} catch {unset GalerieCourante} } proc CochonsLes {SesMachins SesMachinsDefaut} { upvar $SesMachins Machins upvar $SesMachinsDefaut MachinsDefaut global retourCoche global MachinsCochons array set Machins [array get MachinsDefaut] set w [NomDe coche] catch {destroy $w} toplevel $w wm title $w "Merci de cocher ..." wm iconname $w "Coche" frame $w.buttons pack $w.buttons -side bottom -fill x -pady 2m button $w.buttons.dismiss -text "Dismiss" -background red -foreground white \ -command "set retourCoche($w) Dismiss" pack $w.buttons.dismiss -side left -expand 1 button $w.buttons.defaut -text "Default" -background yellow -foreground black \ -command "set retourCoche($w) Defaut" pack $w.buttons.defaut -side left -expand 1 button $w.buttons.accept -text "Accept" -background green -foreground black \ -command "set retourCoche($w) Accept" pack $w.buttons.accept -side left -expand 1 set i 0 foreach a [array names Machins] { set MachinsCochons($a) [set Machins($a)] set b $w.b$a checkbutton $b -text "$a" -variable MachinsCochons($a) -relief flat pack $b -side top -pady 2 -anchor w } tkwait variable retourCoche($w) if { [set retourCoche($w)] == "Defaut" } { array set MachinsCochons [array get MachinsDefaut] while { [set retourCoche($w)] == "Defaut" } { unset retourCoche($w) tkwait variable retourCoche($w) } } if { [set retourCoche($w)] != "Dismiss" } { array set Machins [array get MachinsCochons] } unset retourCoche($w) destroy $w return $SesMachins } proc Colle w { global xPointDeRaccord yPointDeRaccord DejaEmpiles global GalerieCourante global ExpoCourante set LargeurDuMotif [LargeurDe $w] set HauteurDuMotif [HauteurDe $w] set OnEnEmpile 4 set HauteurDuLe [expr $OnEnEmpile*$HauteurDuMotif] if { ! [info exists xPointDeRaccord] } { set DejaEmpiles 0 set xPointDeRaccord 0 set yPointDeRaccord 0 } else { incr DejaEmpiles incr yPointDeRaccord $HauteurDuMotif } if { $DejaEmpiles >= $OnEnEmpile } { set DejaEmpiles 0 set yPointDeRaccord 0 incr xPointDeRaccord $LargeurDuMotif set ScrollRegion [$GalerieCourante.frame.mur cget -scrollregion] set SR0 [lindex $ScrollRegion 0] set SR1 [lindex $ScrollRegion 1] set SR2 [lindex $ScrollRegion 2] set SR3 [lindex $ScrollRegion 3] $GalerieCourante.frame.mur configure \ -width "[expr $SR2 + $LargeurDuMotif]" \ -height "$HauteurDuLe" $GalerieCourante.frame.mur configure \ -scrollregion "$SR0 $SR1 [expr $SR2 + $LargeurDuMotif] $HauteurDuLe" } $GalerieCourante.frame.mur create window \ $xPointDeRaccord $yPointDeRaccord \ -window $w -anchor nw } proc CoordDuCourant {w} { set id [$w find withtag current] set x [lindex [$w coords $id] 0] set y [lindex [$w coords $id] 2] return "$x $y" } proc CouleurDePeau Access { set Orga [OrgaDuFetcheAccess $Access] return [Glossaire $Orga Couleur] } proc CouleurDePeauOsOc OsOc { set CouleurDeClasse(PROKARYOTA) "green" set CouleurDeClasse(EUKARYOTA) "skyblue" set CouleurDeClasse(EUBACTERIA) "yellow" set CouleurDeClasse(ARCHAEBACTERIA) "brown" Espionne $OsOc foreach {Phylum VaCouleurDeClasse} [array get CouleurDeClasse] { if {[regexp -nocase [string range $Phylum 0 3] $OsOc]} { return $ValCouleurDeClasse } } return [Glossaire $OsOc Couleur] } proc CreeExpo E { global ExpoCourante Warne "Creation de l'expo $E" toplevel $E button $E.cloture -text "Cloture" -background green -command "ClosExpoCourante" button $E.dismiss -text "Dismiss" -background red -command "ClosExpoCourante; destroy $E" pack $E.cloture -side top -fill x pack $E.dismiss -side top -fill x } proc CreeGalerie G { global ExpoCourante CreeExpo $ExpoCourante Warne "Creation de la galerie $G" frame $G pack $G -expand yes -fill both label $G.msg -wraplength 4i -justify left -text "$G" -relief sunken -borderwidth 1 pack $G.msg frame $G.frame -borderwidth 10 pack $G.frame -expand yes -fill both set Largeur 400 set Hauteur 600 canvas $G.frame.mur \ -width $Largeur -height $Hauteur \ -scrollregion "0 0 0 0" \ -confine true \ -background grey \ -xscrollcommand "$G.frame.xscroll set" \ -yscrollcommand "$G.frame.yscroll set" scrollbar $G.frame.yscroll -command "$G.frame.mur yview" scrollbar $G.frame.xscroll -command "$G.frame.mur xview" -orient horizontal grid $G.frame.mur -row 0 -column 0 -rowspan 1 -columnspan 1 -sticky nsew grid $G.frame.yscroll -row 0 -column 1 -rowspan 1 -columnspan 1 -sticky nsew grid $G.frame.xscroll -row 1 -column 0 -rowspan 1 -columnspan 1 -sticky nsew grid rowconfig $G.frame 0 -weight 1 -minsize 0 grid columnconfig $G.frame 0 -weight 1 -minsize 0 } proc CreeImagette {} { global GalerieCourante global ExpoCourante global DejaEmpiles set OnEnEmpile 4 if { [info exists GalerieCourante]} { set w $GalerieCourante.frame.mur[NomDe graphe] } else { if { ! [info exists ExpoCourante]} { set DejaEmpiles 0 set ExpoCourante [NomDe expo] CreeExpo $ExpoCourante } set w $ExpoCourante[NomDe graphe] incr DejaEmpiles if { $DejaEmpiles >= $OnEnEmpile } { $ExpoCourante.cloture invoke set DejaEmpiles 0 } } frame $w -borderwidth 10 Warne "Creation de $w" return $w } proc DecortiqueFetch {TexteGCG ChampsDuFetch} { upvar $ChampsDuFetch CDF set CDF(espece) "" set CDF(classe) "" set CDF(gn) "" set CDF(definition) "" foreach Ligne [split $TexteGCG "\n"] { switch -regexp $Ligne { "^OS" { append CDF(espece) "[string trim [string range $Ligne 2 end]] " } "^OC" { append CDF(classe) "[string trim [string range $Ligne 2 end]] " } "^GN" { append CDF(gn) "[string trim [string range $Ligne 2 end]] " } "^DE" { append CDF(definition) "[string trim [string range $Ligne 2 end]] " } } } } proc DeleteLesTmp {Selection Fenetre} { if { $Selection == "" } { FaireLire "Please select some files" return } foreach Fichier [split $Selection "\n"] { if { $Fichier != "" } { File delete -force $Fichier } } destroy $Fenetre MenageLesTmp "Exit" } proc EffaceCourant {w} { global TexteMontreCourant if {[info exists TexteMontreCourant($w)]} { $w delete $TexteMontreCourant($w) unset TexteMontreCourant($w) } } proc EnsoleilleLaSelection Selection { global GalerieCourante global ExpoCourante set ExpoCourante [NomDe expo] set GalerieCourante $ExpoCourante[NomDe galerie] CreeGalerie $GalerieCourante foreach Ligne [split $Selection "\n"] { set Access [lindex [split [string trim $Ligne] " "] 0] EtudieAccess $Access } ClosGalerieCourante ClosExpoCourante } proc EtudieAccess Access { set Orga [OrgaDuFetcheAccess $Access] if { $Orga == "Inconnu" } { Warne "$Access organisme inconnu .........." return } set GN $Access if {[regexp ":" $Access]} { set GN [lindex [split $Access ":"] 1] } set gn [string tolower $GN] GrapheLesBouts [glob /chop/ripp/fodbs/topdb/$Orga/bout/$gn-topdb] } proc EtudieCourant w { set Access [NomDuCourant $w] EtudieAccess $Access } proc AfficheLesSortiesBlast Selection { foreach NomDuFichierBlast [split $Selection "\n"] { AfficheUneSortieBlast $NomDuFichierBlast } } proc AfficheUneSequence {{NomDuFichier ""} {AvecManiere ""}} { global RepertoireDuGenome Gs "Frame" if { $NomDuFichier == ""} { set NomDuFichier [ButineArborescence "All"] if { $NomDuFichier == "" } { return } } return [AfficheFichier $NomDuFichier "AvecFormate$AvecManiere"] } proc AfficheUneSortieBlast {{NomDuFichier ""} {AvecManiere ""}} { global RepertoireDuGenome Gs "Frame" if { $NomDuFichier == ""} { set NomDuFichier [ButineArborescence "All"] if { $NomDuFichier == "" } { return } } if { ! [regexp "/" $NomDuFichier] && [EstUnPAB $NomDuFichier]} { set Nom $NomDuFichier set NomDuFichier "[RepertoireDuGenome]/blastp/$Nom" } return [AfficheFichier $NomDuFichier "AvecGrapheAvecSegAlignementAvecAligneurs$AvecManiere"] } proc EtudieUneSortieMSF {{NomDuFichier ""}} { global RepertoireDuGenome Gs "Frame" if { $NomDuFichier == "" } { set NomDuFichier [ButineArborescence "All"] if { $NomDuFichier == "" } { return } } return [AfficheFichier $NomDuFichier "GrandeLargeurAvecLogAvecEtudeMSF"] } proc Expose w { global GalerieCourante global ExpoCourante if {[info exists GalerieCourante]} { Colle $w } else { pack $w -side bottom } } proc FetcheCourant {w} { return [AfficheFetch [NomDuCourant $w]] } proc FichierFOF {Selection {Tmp ""}} { global RepertoireDuGenome global AccessDejaVus global FOFDejaVu Wup "Creates a file of filenames, each of one contains one of the sequences listed in the text Selection" JeMeSignale if { $Tmp == "" } { set FOF "tmp.[pid][NomDe ""].fof" } else { set FOF "$Tmp.fof" } if { [FormatDeLaSequence $Selection] == "tfas" } { TFAStoGCGs $Selection dans $FOF return "$FOF" } if {[info exists FOFDejaVu($Selection)]} { Sauve $FOFDejaVu($Selection) dans $FOF return "$FOF" } set Liste [split $Selection "\n"] catch {unset AccessDejaVus} foreach Ligne $Liste { if { [regexp "^Query=" $Ligne] } { set Access [QueryDeLaLigne $Ligne] lappend ListeFOF $Access set QueryAccess [file tail $Access] continue } set AccessOuFichier [lindex [split [string trim $Ligne] " "] 0] if { $AccessOuFichier == "" } { continue } set ListeDeFichiers [glob -nocomplain -- $AccessOuFichier] if { $ListeDeFichiers != "" } { foreach f $ListeDeFichiers { if {[file exists $f]} { lappend ListeFOF $f } } continue } if {[regexp {\*} $AccessOuFichier]} { set ListeDeAccess [split [FetchNoms $AccessOuFichier] " "] if { [llength $ListeDeAccess] != 0 } { foreach f $ListeDeAccess { lappend ListeFOF [Sauve [FetchCat "$f"] dans "[RepertoireDetravail]/$f"] } } continue } set Access $AccessOuFichier if {[regexp {^[a-zA-Z0-9_]+:[a-zA-Z0-9_]+[ !]* [a-zA-Z0-9_]+} $Ligne]} { set Access [AccessDUneLigneBlast $Ligne] if {[regexp {/} $Access]} { lappend ListeFOF $Access continue } } if { [regexp {\:} $Access] } { set Banque [lindex [split $Access ":"] 0] set NomDeAccess [lindex [split $Access ":"] 1] } else { set NomDeAccess $Access } if {[info exists Banque]} { set Sequence [Fetche "$Banque:$NomDeAccess"] if { $Sequence != "" } { lappend ListeFOF [Sauve $Sequence dans "[RepertoireDeTravail]/$NomDeAccess"] continue } } set Sequence [Fetche "protein:$NomDeAccess"] if { $Sequence != "" } { lappend ListeFOF [Sauve $Sequence dans "[RepertoireDeTravail]/$NomDeAccess"] continue } set Sequence [Fetche "$NomDeAccess"] if { $Sequence != "" } { lappend ListeFOF [Sauve $Sequence dans "[RepertoireDeTravail]/$NomDeAccess"] continue } } Sauve [join $ListeFOF "\n"] dans $FOF set FOFDejaVu($Selection) [ContenuDuFichier $FOF] return "$FOF" } proc FormateSequence {Sequence {NouveauFormat ""} {AncienFormat ""}} { if {$AncienFormat==""} { set AncienFormat [FormatDeLaSequence $Sequence] } if {$NouveauFormat==""} { set LesNouveauxPossibles [list \ "to-TFA-without-numbers" \ "to-TFA" \ "to-EMBL" \ "to-GCG" \ "nuc-to-prot-TFA" \ "nuc-to-prot-EMBL" \ "nuc-to-prot-GCG" \ "TFA-to-reverse-TFA" \ "TFA-to-complement-TFA" \ "TFA-to-rev-and-comp-TFA" \ "nuc-to-reverse" \ "nuc-to-complement" \ "nuc-to-rev-and-comp" \ ] set N [llength $LesNouveauxPossibles] set I [ChoixParmiJoli [NombresEntre 1 $N] "" $LesNouveauxPossibles] if {$I==""} { return "" } set NouveauFormat [lsearch $LesNouveauxPossibles [expr $I-1]] } if { $AncienFormat == "tfas" && $NouveauFormat == "to-GCG" } { FaireLire "Multiple TFA to GCG is not yet possible" return "" } set II 0 if { $I==[incr II]} { return [TexteTfaFromTexteTfaWithoutNumbers $Sequence]} if { $I==[incr II]} { return [SequenceFormatTFA $Sequence "" $AncienFormat]} if { $I==[incr II]} { return [SequenceFormatEMBL $Sequence "" $AncienFormat]} if { $I==[incr II]} { return [SequenceFormatGCG $Sequence "" $AncienFormat]} if { $I==[incr II]} { return [NucToProtTFA $Sequence "" $AncienFormat]} if { $I==[incr II]} { return [NucToProtEMBL $Sequence "" $AncienFormat]} if { $I==[incr II]} { return [NucToProtGCG $Sequence "" $AncienFormat]} if { $I==[incr II]} { return [TFAToReverseTFA $Sequence ""]} if { $I==[incr II]} { return [TFAToComplementTFA $Sequence ""]} if { $I==[incr II]} { return [TFAToReverseAndComplementTFA $Sequence ""]} if { $I==[incr II]} { return [NucToReverseNuc $Sequence]} if { $I==[incr II]} { return [NucToComplementNuc $Sequence]} if { $I==[incr II]} { return [NucToReverseAndComplementNuc $Sequence]} return "" } proc AddOrganismToOrgaCode {{NewOrga ""} {NewOrga2 ""}} { JeMeSignale if {$NewOrga2!=""} { set NewOrga "$NewOrga $NewOrga2" } regsub "_" $NewOrga " " NewOrga set FichierOrganismes "[GscopeEtc]/gscope_listedesorganismes.txt" set FichierGlossaire "[GscopeEtc]/gscope_glossaire" set Organismes [ContenuDuFichier $FichierOrganismes] if {$NewOrga!=""} { set Organismes "$NewOrga\n$Organismes" } if { ! [PourWscope]} { set Original $Organismes FaireLire "You can add other organisms 'Genus species' ... \n\ Doesn't matter for the alphabetical order or duplicates\n\ if it's a virus please enter 'Virus homo-sapiens-hiv'" set Organismes [EntreTexte $Organismes] if {$Organismes==""} { return "" } } set Organismes [join [lsort -unique [split $Organismes "\n"]] "\n"] if {$Original!=$Organismes} { Garde $FichierOrganismes Sauve $Organismes dans $FichierOrganismes file attribute $FichierGlossaire -permissions 0775 } set LesOrganismes [split $Organismes "\n"] foreach Ligne $LesOrganismes { regsub -all { +} $Ligne " " Ligne set Ligne [string trim $Ligne] if { ! [regexp -nocase {[a-z0-9\-]+ [a-z0-9\-]+\.?} $Ligne]} { FaireLire "Invalid organism\n$Ligne\nOnly 2 words please : 'Homo sapiens'" continue } set Genre [string tolower [lindex [split $Ligne " "] 0]] set espece [string tolower [lindex [split $Ligne " "] 1]] set G [string toupper [string range $Genre 0 0]] set esp [string range $espece 0 2] set gesp [string tolower $G]$esp set Complet "$G[string range $Genre 1 end] $espece" set Pointe "$G.$espece" set Demi "$G[string range $Genre 1 3].[string range $espece 0 4]" lappend LeGlossaire "$gesp\t$Complet\t$Pointe\t$Demi" } Garde $FichierGlossaire SauveLesLignes $LeGlossaire dans $FichierGlossaire file attribute $FichierGlossaire -permissions 0775 Glossaire "Reset" return [Glossaire] } proc TestGlossaire {} { Glossaire Reset Glossaire exit } proc OrganismePrioritaire {Orga} { global OrganismePrioritaire set ORGA [string toupper $Orga] if {[info exists OrganismePrioritaire($ORGA)]} { return $OrganismePrioritaire($ORGA) } if {[info exists OrganismePrioritaire("EstCharge")]} { return $Orga } set OrganismePrioritaire("EstCharge") 1 foreach Genome [LesGenomesComplets] { scan $Genome "%s %s" Genre Espece if {"$Genre $Espece"=="Pyrobaculum aerophilum"} { set O "pae" } else { set O [string index $Genre 0] append O [string range $Espece 0 2] } set OrganismePrioritaire([string toupper $O]) $Genome } set OrganismePrioritaire(MKAN) "Methanopyrus kandleri" set OrganismePrioritaire(A.SP.) "Anabaena sp." set OrganismePrioritaire(H.SP.) "Halobacterium sp." set OrganismePrioritaire(S.SP.) "Synechocystis sp." set OrganismePrioritaire(A.SP) "Anabaena sp." set OrganismePrioritaire(H.SP) "Halobacterium sp." set OrganismePrioritaire(S.SP) "Synechocystis sp." set OrganismePrioritaire(ASP.) "Anabaena sp." set OrganismePrioritaire(HSP.) "Halobacterium sp." set OrganismePrioritaire(SSP.) "Synechocystis sp." set OrganismePrioritaire(ASP) "Anabaena sp." set OrganismePrioritaire(HSP) "Halobacterium sp." set OrganismePrioritaire(SSP) "Synechocystis sp." set OrganismePrioritaire(LISTOFPRIORITAIRE) [array names OrganismePrioritaire] return [OrganismePrioritaire $Orga] } proc Glossaire {{Organisme ""} {Champ ""} {ChampSiOrgaSur2 ""}} { global Glossaire FichierGlossaire global GlossaireDesClasses global OrganismePrioritaire #rR Pour plus qu'il se plante on rend la meme chose if {[FileAbsent $FichierGlossaire]} { return $Organisme } if {$Organisme==""} { set Organisme "ListOf"; set Champ "All" } set OOri $Organisme; set COri $Champ; if {$Organisme=="Reset"} { if {[info exists Glossaire]} { unset Glossaire } return "" } if {$ChampSiOrgaSur2!=""} { set Organisme "$Organisme $Champ" set Champ $ChampSiOrgaSur2 } if {$Champ==""} { set Champ "Complet" } regsub " sp$" $Organisme " sp." Organisme regsub -all -nocase {[^a-z0-9_\-'\.]} $Organisme " " Organisme set Organisme [OrthographeCanonique $Organisme] set Organisme [OrganismePrioritaire $Organisme] if {$Organisme=="" || \ $Organisme=="Unknown unknown" || \ $Organisme=="uunk" || \ $Organisme=="unkn" } { set Organisme "Inconnu inconnu" } regsub " " $Organisme "_" OrgaUnderscore if {[info exists Glossaire($OrgaUnderscore,$Champ)]} { return [set Glossaire($OrgaUnderscore,$Champ)] } set OrgaUnderscore [string totitle $OrgaUnderscore] if {[info exists Glossaire($OrgaUnderscore,$Champ)]} { return [set Glossaire($OrgaUnderscore,$Champ)] } set ORGANISME [string toupper $Organisme] if {[info exists Glossaire($ORGANISME,MonComplet)]} { return [Glossaire $Glossaire($ORGANISME,MonComplet) $Champ] } if {[info exists Glossaire("EstCharge")]} { return "" } set Glossaire("EstCharge") 1 #rR Attention: if Organisme has : it's a list of organisms if {0 && [regexp ":" $Organisme]} { foreach O [SplitOrgas $Organisme] { lappend GlosO [Glossaire $O $Champ] } return [join $GlosO ":"] } set Espece "" scan $Organisme "%s %s" Genre Espece set Organisme $Genre if {$Espece!=""} { append Organisme " $Espece" } if {[regexp -nocase {(^hsp|^H\.sp)[\.]*$} $Organisme]} { set Organisme "Halobacterium sp" } if {[regexp -nocase {(^bsp|^B\.sp)[\.]*$} $Organisme]} { set Organisme "Buchnera sp" } if {[regexp -nocase {(^ssp|^S\.sp)[\.]*$} $Organisme]} { set Organisme "Synechocystis sp" } if {[regexp -nocase {(^mtub|^M\.tub)$} $Organisme]} { set Organisme "Mycobacterium tuberculosis" } if {[regexp -nocase {(^rpro|^R\.pro)$} $Organisme]} { set Organisme "Rickettsia prowazekii" } if {[regexp -nocase {(^mthe|^M\.the)$} $Organisme]} { set Organisme "Methanobacterium thermoautotrophicum" } if {[regexp -nocase {^M.thermoautotrop} $Organisme]} { set Organisme "Methanobacterium thermoautotrophicum" } if {[regexp -nocase {^paer$} $Organisme]} { set Organisme "Pseudomonas aeruginosa" } if {[regexp -nocase {^pae$} $Organisme]} { set Organisme "Pyrobaculum aerophilum" } if {[regexp -nocase {^upar$} $Organisme]} { set Organisme "Ureaplasma urealyticum" } if {[regexp -nocase {^rmel$} $Organisme]} { set Organisme "Sinorhizobium meliloti" } if {[regexp -nocase {^rlot$} $Organisme]} { set Organisme "Mesorhizobium loti" } # if {[info exists Glossaire($Organisme,$Champ)]} { return [set Glossaire($Organisme,$Champ)] } foreach Ligne [LesLignesDuFichier "$FichierGlossaire.classes"] { scan $Ligne "%s %s" Genre Espece set Classe [join [lrange [split $Ligne " "] 2 end] " "] set GlossaireDesClasses(${Genre}_$Espece) $Classe } set i 0 set ListeDuGlossaire [LesLignesDuFichier $FichierGlossaire] set LongGlossaire [llength $ListeDuGlossaire] foreach Ligne $ListeDuGlossaire { lappend Glossaire(ListOf,All) $Ligne set lili [split $Ligne "\t"] set Court [lindex $lili 0] set Complet [lindex $lili 1] set COMPLET [string toupper $Complet] set Pointe [lindex $lili 2] set Demi [lindex $lili 3] set Couleur [Nuance [expr {[incr i]*1.0/$LongGlossaire}]] set Angle [expr {$i*2*3.141592/$LongGlossaire}] regsub " " $Complet "_" Orga regsub {\.$} $Court "" Court set Glossaire($Orga,Orga) $Orga set Glossaire($Orga,Court) $Court set Glossaire($Orga,Complet) $Complet set Glossaire($Orga,COMPLET) $COMPLET set Glossaire($Orga,Pointe) $Pointe set Glossaire($Orga,Demi) $Demi set Glossaire($Orga,Couleur) $Couleur set Glossaire($Orga,Angle) $Angle set Glossaire($Orga,Tout) ":$Court:$Complet:$COMPLET:$Pointe:$Demi:$Orga:" if {[info exists GlossaireDesClasses($Orga)]} { set Classe [set GlossaireDesClasses($Orga)] } else { set Classe "ClassUnknown" } set Glossaire($Orga,Classe) $Classe lappend Glossaire(ListOf,Organismes) $Orga lappend Glossaire(ListOf,Complet) [set Glossaire($Orga,Complet)] lappend Glossaire(ListOf,Entier) [set Glossaire($Orga,Tout)] } set Glossaire(Pyrobaculum_aerophilum,Court) "pae" set Orga "Inconnu_inconnu" set Glossaire($Orga,Orga) $Orga set Glossaire($Orga,Court) "iinc" set Glossaire($Orga,Complet) "Inconnu inconnu" set Glossaire($Orga,COMPLET) "INCONNU INCONNU" set Glossaire($Orga,Pointe) "I.inconnu" set Glossaire($Orga,Demi) "Inco.incon" set Glossaire($Orga,Couleur) grey set Glossaire($Orga,Angle) 5. set Glossaire($Orga,Tout) ":Inconnu:Inconnu inconnu:INCONNU INCONNU:I.inconnu:Inco.incon:$Orga:" set Glossaire($Orga,Classe) "ClassUnknown" lappend Glossaire(ListOf,Organismes) $Orga lappend Glossaire(ListOf,Complet) [set Glossaire($Orga,Complet)] lappend Glossaire(ListOf,Entier) [set Glossaire($Orga,Tout)] foreach Orga $Glossaire(ListOf,Organismes) { if { ! [regexp -nocase {[a-z]} $Orga]} { continue } foreach Field [split $Glossaire($Orga,Tout) ":"] { if {$Field==""} { continue } set FIELD [string toupper $Field] if {$FIELD==[string toupper $Orga]} { continue } lappend Glossaire(ListOf,FIELD) $FIELD set Glossaire($FIELD,MonComplet) $Orga } } set Glossaire(ListOf,FIELD) [lsort -unique $Glossaire(ListOf,FIELD)] if {[string equal -nocase $Champ "Couleur"] } { return "grey" } return [Glossaire $OOri $COri] #rR ****************************************************** Wup "Faudra faire la suite proprement" set OrgaInconnu "Inconnu_inconnu" if {[info exists Glossaire($OrgaInconnu,$Champ)]} { return [set Glossaire($OrgaInconnu,$Champ)] } return "" } proc LesOrgasDesAccess {LesAccess {Champ "Complet"} {Nom ""}} { global RepertoireDuGenome global QuidSeqEstDisponible set LesAccessRestants $LesAccess set LesAccessRestantsEncore $LesAccessRestants set LesBonsAccessOrga {} if {$LesAccessRestants=={}} { return $LesBonsAccessOrga } Wup "With Descriptif ... not yet finish (because multiple OSs)" if {$Nom!=""} { set LesAccessRestantsEncore {} set FichierDescriptif "$RepertoireDuGenome/descriptifs/$Nom" if {[info exists $FichierDescriptif]} { foreach Access $LesAccessRestants { set O [OrgaDuDescriptif $Access $Nom] if {$O==""} { lappend LesBonsAccessOrga "$Access [Glossaire [set OrgaDe($Access)] $Champ]" } else { lappend LesAccessRestantsEncore $Access } } } } if {$LesAccessRestantsEncore=={}} { return $LesBonsAccessOrga } set LesAccessRestants $LesAccessRestantsEncore Wup "With distancephylo" if {$Champ=="Court" && $Nom!=""} { set LesAccessRestantsEncore {} set LesODAs [LesOrgaDistAccessDesOrthologues $Nom] foreach {O D A} $LesODAs { set OrgaDe($A) $O } set LesAccessRestantsRestants {} foreach Access $LesAccessRestants { if {[info exists OrgaDe($Access)]} { lappend LesBonsAccessOrga "$Access [Glossaire [set OrgaDe($Access)] $Champ]" } else { lappend LesAccessRestantsEncore $Access } } } if {$LesAccessRestantsEncore=={}} { return $LesBonsAccessOrga } set LesAccessRestants $LesAccessRestantsEncore Wup "For PDB or Ciona" set LesAccessRestantsEncore {} foreach Access $LesAccessRestants { if {[regexp {^ci[0-9]{10}$} $Access]} { set Organisme "Ciona intestinalis" lappend LesBonsAccessOrga "$Access [Glossaire $Organisme $Champ]" } elseif {[EstUnAccessPDB $Access]} { set Organisme [OrganismeDuPDB $Access] lappend LesBonsAccessOrga "$Access [Glossaire $Organisme $Champ]" } else { lappend LesAccessRestantsEncore $Access } } if {$LesAccessRestantsEncore=={}} { return $LesBonsAccessOrga } set LesAccessRestants $LesAccessRestantsEncore Wup "For Ciona" Wup "With QuidSeq" if {[info exists QuidSeqEstDisponible] && $QuidSeqEstDisponible} { set TexteAccessOrga [QuestionDeScience QuidSeq "QuidOSsOfACs [join $LesAccessRestants "|"]"] regsub {[ \n]+$} $TexteAccessOrga "" TexteAccessOrga set LesAccessOrga [split $TexteAccessOrga "\n"] foreach AccessOrga $LesAccessOrga { scan $AccessOrga "%s" Access regsub "^$Access +" $AccessOrga "" Organismes lappend LesBonsAccessOrga "$Access [Glossaire $Organismes $Champ]" } return $LesBonsAccessOrga } Wup "Without QuidSeq" foreach Access $LesAccessRestantsEncore { set Orga [OrgaDuAccess $Access $Champ] lappend LesBonsAccessOrga "$Access $Orga" } return $LesBonsAccessOrga } proc LesChampsInteressantsDuAccess {BanqueId Access args} { set SeparateurDuChamp(AC) " " set SeparateurDuChamp(ID) " " set SeparateurDuChamp(OS) " " set SeparateurDuChamp(OC) " " set SeparateurDuChamp(OX) " " set LesChamps $args if {[regexp {^[A-Z][A-Z]$} $Access]} { set LesChamps [concat [list $Access] $args] set Access $BanqueId } foreach Champ $LesChamps { set ChampInteressant($Champ) 1 } set LesLignesEMBL [LaSequenceDesBanques $BanqueId $Access AccessOK "OnVeutEMBL"] if {$LesLignesEMBL==""} { return {} } foreach Ligne $LesLignesEMBL { scan $Ligne "%s" ChampLu if {[string equal $ChampLu "SQ"]} { break } if { ! [info exists ChampInteressant($ChampLu)]} { continue } regsub "$ChampLu " $Ligne "" Ligne lappend LesValeurs($ChampLu) [string trim $Ligne] } set LeResultat {} foreach Champ $LesChamps { set Valeur "" set Sep "\n" if {[info exist SeparateurDuChamp($Champ)]} { set Sep $SeparateurDuChamp($Champ) } if {[info exists LesValeurs($Champ)]} { set Valeur [join $LesValeurs($Champ) $Sep] } lappend LeResultat $Valeur } return $LeResultat } proc OrgaDuAccess {Access {Champ "Complet"} {BanqueId ""}} { global QuidSeqEstDisponible # set Orga [BirdWeb UNIPROT $Access OS] if { ! [regexp -nocase {[a-z0-9]} $Access]} { return [Glossaire "" $Champ] } if {[info exists QuidSeqEstDisponible] && $QuidSeqEstDisponible} { set ACCESS [string toupper $Access] if {[regexp "PFOK|PFUR" $ACCESS]} { set OS "Pyrococcus furiosus" } elseif {[regexp {^PAE[0-9]{4}} $ACCESS]} { set OS "Pyrobaculum aerophilum" } elseif {[regexp "^TACI" $ACCESS]} { set OS "Thermoplasma acidophilum" } elseif {[regexp "^PYAB" $ACCESS]} { set OS "Pyrococcus abyssi" } else { set OS [QuestionDeScience "ouragan:25000:QuidSeq" "QuidOSOfAC $ACCESS"] } if {$OS!=""} { set Orga [Glossaire $OS $Champ] return $Orga } } set OS [ChampDuDescriptif [LeDescriptif $Access] OS] if {$OS!=""} { return [Glossaire $OS $Champ] } if {$BanqueId==""} { set BanqueId $Access regsub -nocase {[a-z]+:} $BanqueId "" Access } set LesLignesEMBL [LaSequenceDesBanques $BanqueId $Access AccessOK "OnVeutEMBL"] if {$LesLignesEMBL!=""} { set DE "" foreach Ligne $LesLignesEMBL { if {[regexp "^DE" $Ligne]} { regsub "^DE " $Ligne "" InfoDE append DE " $InfoDE" } if {[regexp "^OS" $Ligne]} { set lili [split [string trim [string range $Ligne 2 end]] " "] set Genre [lindex $lili 0] regsub {[^A-Za-z]} [lindex $lili 1] "" Espece set Organisme "$Genre $Espece" break } } if {[info exists Organisme]} { set Glo [Glossaire $Organisme $Champ] if {$Glo!=""} { return $Glo } return [OrganismeNormalise $Organisme $Champ] } if {[regexp {\[([^\]]+)]} $DE Match OS]} { set G ""; set E "" scan $OS "%s %s" G E if {$E!=""} { set Organisme "$G $E" } set Glo [Glossaire $Organisme $Champ] if {$Glo!=""} { return $Glo } return [OrganismeNormalise $Organisme $Champ] } } return [Glossaire "" $Champ] } proc OrganismeNormalise {Organisme {Champ ""}} { if {$Champ==""} { set Champ "Complet" } set G "" set E "" scan $Organisme "%s %s" G E if {$Champ=="Complet"} { return "$G $E" } if {$Champ=="COMPLET"} { return [string toupper "$G $E"] } if {$Champ=="Court"} { return [string tolower [string range $G 0 0] [string range $E 0 2]] } if {$Champ=="Demi"} { return "[string range $G 0 3].[string range $E 0 4]" } if {$Champ=="Pointe"} { return "[string range $G 0 0].[string range $E 0 end]" } return $Organisme } proc DefinitionDuAccess {BanqueId {Access ""}} { if {$Access==""} { set Access $BanqueId } set LesValeurs [LesChampsInteressantsDuAccess $BanqueId $Access "DE"] set DE [lindex $LesValeurs 0] regsub -all {[ \n\t]+} $DE " " DE set DE [string trim $DE] return $DE } proc HauteurDe w { global Memo return [set Memo(HauteurDe$w)] } proc IllumineLeGroupeDe {Nom Fenetre {Ask ""} {Maniere ""}} { if {$Ask==""} { set Ask "Secator" } if {$Ask=="Ask"} { set Ask [ChoixParmi [list "Secator" "Dpc" "Oumy" \ "SecatorSelect" "DpcSelect" "OumySelect"]] } if {$Ask==""} { return "" } if {[regexp "Select" $Ask]} { set Select 1 regsub "Select" $Ask "" Ask } else { set Select 0 } foreach Access [Groupe$Ask $Nom $Nom "In"] { Illumine $Access $Fenetre } if { ! $Select} { return $Fenetre } global PagePropre set Page [set PagePropre($Fenetre)] return [AfficheRognure $Page [selection get] "GrandeLargeur$Maniere" "${Ask}_group_selection_of/$Nom"] } proc LargeurDe w { global Memo return [set Memo(LargeurDe$w)] } proc ListeCompressee liste { set olde "HolaTriouPoilAuGenou" foreach e [lsort $liste] { if { $e != $olde } { lappend Compresse $e set olde $e } } return $Compresse } proc MenageLesTmp {Vert {Choix ""}} { global SortieAutorisee Gs "Frame" set KeepThis ".msf|.log|.blastp" set DeleteThis "" if {$Vert=="Rename" && $Choix==""} { set Choix $KeepThis } if {$Vert=="Delete" && $Choix==""} { set Choix $DeleteThis } if { [info exists SortieAutorisee] } { unset SortieAutorisee } regsub -all " " [eval glob -nocomplain -- tmp.*] "\n" LesTmp if { $LesTmp == "" } { set SortieAutorisee 1 return "" } set Fenetre [AfficheVariable $LesTmp "SansFetchAvecShow" "Select, then Rename or Delete.\n Or Accept Boum"] set bRename [BoutonneLaFenetre $Fenetre "Rename" "RenommeLesTmp \[selection get\] $Fenetre"] set bDelete [BoutonneLaFenetre $Fenetre "Delete" "DeleteLesTmp \[selection get\] $Fenetre"] set bExit [BoutonneLaFenetre $Fenetre "Accept Boum" "set SortieAutorisee 1; destroy $Fenetre"] $bExit configure -background "yellow" -foreground "black" Illumine $Choix $Fenetre [set b$Vert] configure -background "green" -foreground "black" return $Fenetre } proc MontreCourant {w x y} { global TexteMontreCourant set BBox [$w bbox all] set cx [expr ([lindex $BBox 2] + [lindex $BBox 0])/2] set cy [expr ([lindex $BBox 3] + [lindex $BBox 1])/2] if {[expr $x < $cx]} { set EW w } else { set EW e } if {[expr $y < $cy]} { set NS n } else { set NS s } set Ancre "$NS$EW" set X [$w canvasx [expr $x ]] set Y [$w canvasy [expr $y - 20 ]] if {[info exists TexteMontreCourant($w)]} { EffaceCourant $w } set Texte [NomDuCourant $w] set Queue ". .[string range $Texte [expr [string length $Texte]-20] end]" set TexteMontreCourant($w) [$w create text $X $Y -text "$Queue" -anchor $Ancre] } proc MontreOrganismes {{AvecRetour ""}} { Gs "Frame" if { [string equal -nocase $AvecRetour "AvecRetour"] } { set OptionRetour "AvecRetour" } else { set OptionRetour "" } foreach Ligne [Glossaire Bidon Entier] { set LesMots [split [string trim $Ligne ":"] ":"] set i 0 foreach Mot $LesMots { incr i if {[info exists Largeur($i)]} { set Largeur($i) [Maxi [set Largeur($i)] [string length $Mot]] } else { set Largeur($i) [string length $Mot] } } } foreach Ligne [Glossaire Bidon Entier] { set i 0 set Texte "" foreach Mot [split [string trim $Ligne ":"] ":"] { incr i append Texte [format "%-[set Largeur($i)]s " $Mot] } lappend LesTextes $Texte } return [AfficheVariable [join $LesTextes "\n"] "SansFetch$OptionRetour" "glossaire"] } proc NomDuCourant K { set LesTags [$K gettags [$K find withtag current]] foreach Tag $LesTags { if {[EstUnPAB $Tag]} { return $Tag } } return [lindex $LesTags 0] } proc RenommeLesTmp {Selection Fenetre} { if { $Selection == "" } { FaireLire "Please select some files" return } set Nom [Entre "keep"] foreach Fichier [split $Selection "\n"] { regsub -- {^tmp} $Fichier $Nom Nouveau if { $Fichier != "" && $Nouveau != "" } { File rename $Fichier $Nouveau } } destroy $Fenetre MenageLesTmp "Delete" } proc SeqIn {{Texte ""}} { if { $Texte == "" } { set T [EntreTexte] } else { set T $Texte } set T [string trim $T] if { $T == "" } { return "" } if { ! [regexp {[a-zA-Z0-9_]} $T] } { return "" } #rR nom de fichier ou access if { ! [regexp {[\n ]} $T] } { if {[file isdirectory $T]} { set ListeDeFichiers [glob -nocomplain -type f -- "$T/*"] if {$ListeDeFichiers=={}} { return "" } return [LOFtoTFAs $ListeDeFichiers "UseAccess"] } if {[regexp {[/\:]} $T] || [regexp -nocase {^[a-z0-9_]{4,12}$} $T] } { scan $T "%s" Access set LaSeq [LaSequenceDesBanques $Access $Access AccessOK "OnVeutNature"] if {$LaSeq!={}} { return [join $LaSeq "\n"] } } } #rR on a une sequence avec un format connu ou une sequence brute set Format [FormatDeLaSequence $T] if {[regexp "tfas|tfa|gcg|gcgmaybe|embl" $Format]} { return $T } if {[regexp "brut" $Format]} { #rR sequence brute, on ne permet que les chiffres ou blanc regsub -all {[0-9 \t]} $T "" T regsub -all {\*} $T "X" T return [SequenceFormatTFA $T "" $Format] } Warne "Je ne sais pas quoi faire de\n$T" return "" } proc ShowFileOld {{Fichier ""}} { global LesAvecs LesAvecsDefaut TousLesAvecs Gs "Frame" if { ! [info exists LesAvecs]} { set LesAvecs(AvecShow) 0 set LesAvecs(AvecEtudeBlast) 0 set LesAvecs(AvecRetour) 0 set LesAvecs(AvecAligneurs) 0 set LesAvecs(AvecLog) 0 set LesAvecs(AvecBlaste) 0 set LesAvecs(AvecGraphe) 0 set LesAvecs(AvecAlignement) 0 set LesAvecs(SansFetch) 0 array set LesAvecsDefaut [array get LesAvecs] set Source [info body AfficheVariable] foreach Ligne [split [info body AfficheVariable] "\n"] { if { ! [regexp -indices "Maniere" $Ligne Indices]} { continue } scan $Indices "%d" iManiere if { ! [regexp -indices "regexp" $Ligne Indices]} { continue } scan $Indices "%d %d" iDebutRegexp iFinRegexp set UnAvec [string range $Ligne [incr iFinRegexp 3] [incr iManiere -4]] if { ! [info exists LesAvecs($UnAvec)] } { if {[info exists LesAvecsDefaut($UnAvec)]} { set LesAvecs($UnAvec) [set LesAvecsDefaut($UnAvec)] } else { set LesAvecs($UnAvec) 0 } } set TousLesAvecs($UnAvec) [set LesAvecs($UnAvec)] } } CochonsLes LesAvecs TousLesAvecs set AvecCeuxCi "" foreach Avec [array names LesAvecs] { if { [set LesAvecs($Avec)] } { append AvecCeuxCi $Avec } } if {$Fichier == "" } { set Fichier [ButineArborescence All] if {$Fichier == ""} { return "" } } return [AfficheFichier $Fichier $AvecCeuxCi] } proc ShowFile {{Fichier ""}} { Gs "Frame" set LesAvecExistants {} set Source [info body AfficheVariable] foreach Ligne [split [info body AfficheVariable] "\n"] { if { ! [regexp -indices "Maniere" $Ligne Indices]} { continue } scan $Indices "%d" iManiere if { ! [regexp -indices "regexp" $Ligne Indices]} { continue } scan $Indices "%d %d" iDebutRegexp iFinRegexp set UnAvec [string range $Ligne [incr iFinRegexp 3] [incr iManiere -4]] lappend LesAvecExistants $UnAvec } set AvecCeuxCi [join [ChoixDesPresents $LesAvecExistants] ""] if {$Fichier == "" } { set Fichier [ButineArborescence All] if {$Fichier == ""} { return "" } } return [AfficheFichier $Fichier $AvecCeuxCi] } proc TFAtoGDE LesLignesTFA { Wup "On remplace les > par % avec juste le nom derriere >" set lesLignesGDE {} foreach Ligne $LesLignesTFA { if {[regexp "^>" $Ligne]} { set Entete Ligne regsub ">SEQ ID " $Entete "%" Entete regsub ">" $Entete "%" Entete regsub "," $Entete " " Entete scan $Entete "%s" Ligne } lappend LesLignesGDE $Ligne } return $LesLignesGDE } proc GNduMarque Marque { set tid [lindex [split $Marque :] 0] set tc [lindex [split $Marque :] 1] return [lindex [split [$tc itemcget [expr $tid +1] -text ] "\n"] 0] } proc DismissToutCePAB {Nom {Force ""}} { global LesFenetresDePAB global PagePropre if {$Nom=="" || ! [info exists LesFenetresDePAB($Nom)]} { return } if {$Force == "Force"} { set Force 1 } else { set Force 0 } if {$Force || [OuiOuNon "Je DISMISS tout $Nom ? "]} { foreach Fenetre [set LesFenetresDePAB($Nom)] { if { ! [winfo exists $Fenetre]} { continue } if {[info exists PagePropre($Fenetre)]} { unset PagePropre($Fenetre) } after 10 destroy $Fenetre } unset LesFenetresDePAB($Nom) } } proc Censure Texte { set ListeDesLignes [split $Texte "\n"] set iNom [lsearch -regexp $ListeDesLignes "^Nom\: "] if {$iNom<0} { FaireLire "$Texte\n\n has no 'Nom:' field." if {[OuiOuNon "Do I skipp Censure ?"]} { return $Texte } set NouveauTexte "" } else { set LigneNom [lindex $ListeDesLignes $iNom] set NouveauTexte [string trim $LigneNom] set ListeDesLignes [lreplace $ListeDesLignes $iNom $iNom] } set OldLigne "" foreach Ligne [lsort -ascii $ListeDesLignes] { set Ligne [string trim $Ligne] if { $Ligne == $OldLigne } { continue } if { ! [regexp {\:} $Ligne] } { continue } append NouveauTexte "\n$Ligne" set OldLigne $Ligne } return $NouveauTexte } proc CourtOS OS { return [Glossaire $OS Court] } proc BeauGN GN { return $GN } proc CopieLeMeilleurCopainsInfo {Nom Selection} { if { $Selection == "" } {return ""} foreach Ligne [split $Selection "\n"] { set Sequence [Fetche [AccessDUneLigneBlast $Ligne]] if { $Sequence == "" } { continue } DecortiqueFetch $Sequence ChampsDuFetch set OS [Glossaire [EspeceNormalisee $ChampsDuFetch(espece)] Court] set OC [ClasseNormalisee $ChampsDuFetch(classe)] set GN $ChampsDuFetch(gn) set DE $ChampsDuFetch(definition) lappend lOS $OS lappend lOC $OC lappend lGN $GN lappend lDE $DE lappend ListeDeChoix "$OS / $OC / [BeauGN $GN] / $DE" lappend ListeDeCouleurs [CouleurDePeauOsOc "$OC"] } set Elu [ChoixParmi $ListeDeChoix $ListeDeCouleurs] if { $Elu == "" } { return "" } set i [lsearch -exact $ListeDeChoix $Elu] set OS [lindex $lOS $i] set OC [lindex $lOC $i] set GN [lindex $lGN $i] set DE [lindex $lDE $i] if {[regexp " OR " $GN]} { set BonGN [ChoixParmi [split $GN " "]] if { $BonGN == "OR" } {set BonGN $GN} } else { set BonGN $GN } set aDE "" set aGN "" if { $DE != "" } { set aDE "DE: $DE\n" } if { $BonGN != "" } { set aGN "GN: $BonGN\n" } set Append [string trim "$aGN$aDE"] if { $Append != ""} { Informe $Nom $Append } return "$Append" } proc Fard {K X Y} { global TypeFard global KanvaAColorer set Nom [Box [BoiteDuCourant $K $X $Y] nom] set KanvaAColorer $K set Couleur [CouleurParTypeEtNom [set TypeFard($K)] $Nom $K] unset KanvaAColorer return $Couleur } proc ChargeLesCodonsStart {} { global LesCodonsStart global LesAAsStart foreach Boite [ListeDesPABs] { set Nom [Box $Boite nom] set Debut [Box $Boite debut] set Fin [Box $Boite fin] set Orient [Box $Boite orient] if { $Orient == "F" } { set Codon [BoutADN $Debut [expr $Debut+2] $Orient] } else { set Codon [BoutADN [expr $Fin-2] $Fin $Orient] } set Codon [string toupper $Codon] ; #rR 2017/11/06 set LesCodonsStart($Nom) $Codon set LesAAsStart($Nom) [AAduCodon $Codon] } } proc AAStart Nom { global LesAAsStart if {[info exists LesAAsStart($Nom)]} { return LesAAsStart($Nom) } if {[info exists LesAAsStart("EstCharge")]} { return "" } set LesAAsStart("EstCharge") 1 ChargeLesCodonsStart return [AAsStart $Nom] } proc NucDuCodonStart Nom { global RepertoireDuGenome global LesCodonsStart global LesAAsStart if { ! [info exists LesCodonsStart]} { ChargeLesCodonsStart } if { [info exists LesCodonsStart($Nom)] && [YaPABdans $Nom]} { return [set LesCodonsStart($Nom)] } else { return "" } } proc TestAAduCodon {} { Espionne [AAduCodon Tga] Espionne [AAduCodon TGA W] Espionne [AAduCodon tGA] Espionne [AAduCodon ATG] Espionne [AAduCodon ATG S] Espionne [AAduCodon ATG] Espionne [AAduCodon Reset] Espionne [AAduCodon ATG] Espionne [AAduCodon tGA] exit } proc CodonsDuAA {AA} { return [CodeGenetique $AA Codons] } proc AAduCodon {Codon {AA ""}} { global CodonToAminoAcid global FichierTranslate if {$Codon=="Reset" && [info exists CodonToAminoAcid]} {unset CodonToAminoAcid ; return ""} if {[string length $Codon] != 3 } { return "-" } if {[regexp -nocase {[^ATGC]} $Codon]} { return "X" } if { ! [info exists CodonToAminoAcid("EstCharge")]} { set CodonToAminoAcid("EstCharge") 1 set ListeDesLignes [split [ContenuDuFichier $FichierTranslate] "\n"] set IndexPointPoint [lsearch -regexp $ListeDesLignes {\.\.}] if { $IndexPointPoint == -1 } { Warne "$FichierTranslate merde."; exit} set PartieCodage [lrange $ListeDesLignes [incr IndexPointPoint 2] end] foreach Ligne $PartieCodage { set fin [expr [string first "\!" $Ligne]-1] set Interet [string range $Ligne 0 $fin] if {[info exists a]} { unset a } if {[info exists b]} { unset b } if {[info exists c]} { unset c } if {[info exists d]} { unset d } if {[info exists e]} { unset e } if {[info exists f]} { unset f } if {[info exists g]} { unset g } if {[info exists h]} { unset h } scan $Interet "%s %s %s %s %s %s %s %s %s %s" A AAA a b c d e f g h if {[info exists a]} { set CodonToAminoAcid([string toupper $a]) $A} if {[info exists b]} { set CodonToAminoAcid([string toupper $b]) $A} if {[info exists c]} { set CodonToAminoAcid([string toupper $c]) $A} if {[info exists d]} { set CodonToAminoAcid([string toupper $d]) $A} if {[info exists e]} { set CodonToAminoAcid([string toupper $e]) $A} if {[info exists f]} { set CodonToAminoAcid([string toupper $f]) $A} if {[info exists g]} { set CodonToAminoAcid([string toupper $g]) $A} if {[info exists h]} { set CodonToAminoAcid([string toupper $h]) $A} } if { ![CodonStopPossible "TGA"] } { set CodonToAminoAcid(TGA) "W" } } set CODON [string toupper $Codon] if {$AA!=""} { set CodonToAminoAcid($CODON) $AA } if { ! [info exists CodonToAminoAcid($CODON)]} { return "X" } return [set CodonToAminoAcid($CODON)] } proc TestCA {} { return [CompareADNDesFichiersTFA "/genomics/link/ProGS/nuctfa/PGS002" "/genomics/link/ProGS/nuctfa/PGS502" SansAffichage] } proc CompareADNDesTextesTFA {T1 T2 {SansAffichage ""} {Titre ""}} { set DeuxPages $T1 append DeuxPages "\n" append DeuxPages $T2 return [VoisinADN $DeuxPages $SansAffichage $Titre] } proc CompareADNDesFichiersTFA {F1 F2 {SansAffichage ""} {Titre ""}} { set T1 [ContenuDuFichier $F1] set T2 [ContenuDuFichier $F2] return [CompareADNDesTextesTFA $T1 $T2 $SansAffichage $Titre] } proc CompareADN {Page {SansAffichage ""} {Titre ""}} { global CompareADN if {[info exists CompareADN]} { set DeuxPages $CompareADN append DeuxPages "\n$Page" unset CompareADN return [VoisinADN $DeuxPages $SansAffichage $Titre] } set CompareADN $Page set Message "Please click on the CompareADN button of an another window" FaireLire $Message return $Message } proc VoisinADN {NomOuTexte {Debut ""} {Fin ""} {Orient ""} {SansAffichage ""} {Titre ""}} { if {[regexp -nocase {[A-Z]} $Debut]} { set SansAffichage $Debut set Titre $Fin set Debut "" set Fin "" } set AvecReverse 1 if {[EstPABouTROUouTRNAouARN $NomOuTexte]} { set Nom $NomOuTexte if {$Debut=="nuctfa"} { set adn [QueLaSequenceDuFichierTFA [GscopeFile $Nom "nuctfa"]] set Debut 1 set Fin [string length $adn] set LongN [expr $Fin-$Debut+1] set DebutEtendu $Debut set FinEtendu $Fin set Orient "F" } else { if {$Debut == "" } { set Nom [Box $Nom nom] set Debut [Box $Nom debut] set Fin [Box $Nom fin] set Orient [Box $Nom orient] } set LongN [expr $Fin-$Debut+1] set DebutEtendu [expr $Debut-900] set FinEtendu [expr $Fin +900] while { $DebutEtendu < 1 } { incr DebutEtendu 3} while { $FinEtendu > [LongueurADN] } { incr FinEtendu -3} set adn [BoutADN $DebutEtendu $FinEtendu $Orient] } } else { if {[regexp "^>" $NomOuTexte]} { set Nom [EnteteDuTexteTFA $NomOuTexte "access"] set adn [QueLaSequenceDuTexteTFA $NomOuTexte "ListOfTxt"] if {[llength $adn]>1} { set AvecReverse 0 ScanLaListe $adn adn AutreAdn } } else { if {[regexp -nocase {[^atgcn \n0-9\.]} $NomOuTexte] && \ ! [OuiOuNon "Do You really want to see the 6 frame translation of the whole text ?" 0] } { return "" } set Nom "Six_frames_translation" regsub -nocase -all {[^a-z]} $NomOuTexte "" adn } set Debut 1 set Fin [string length $adn] set LongN [expr $Fin-$Debut+1] set DebutEtendu $Debut set FinEtendu $Fin set Orient "F" } if {$AvecReverse} { set tdn [ComplementString $adn] } else { set tdn $AutreAdn } set pep(0) "" set pep(1) "" set pep(2) "" set pep(3) "" set pep(4) "" set pep(5) "" for {set i 0} { $i < [string length $adn] } {incr i } { append pep([expr $i%3]) "[AAduCodon [string range $adn $i [expr $i+2]]] " if {$AvecReverse} { append pep([expr $i%3+3]) "[AAduCodon [ReverseString [string range $tdn $i [expr $i+2]]]] " } else { append pep([expr $i%3+3]) "[AAduCodon [string range $tdn $i [expr $i+2]]] " } } set Blanc "" for {set i 0} {$i<6000} {incr i} {append Blanc " "} if {$Orient == "F" } { set OffsetAvant [expr $Debut-$DebutEtendu] set OffsetApres [expr $FinEtendu-$Fin] } else { set OffsetApres [expr $Debut-$DebutEtendu] set OffsetAvant [expr $FinEtendu-$Fin] } set BlancAvant [string range $Blanc 0 [expr $OffsetAvant-1]] set BlancApres [string range $Blanc 0 [expr $OffsetApres-1]] set pepOriF [string range $pep(0) $OffsetAvant [expr [string length $pep(0)]-$OffsetApres] ] set pepOriR [string range $pep(3) $OffsetAvant [expr [string length $pep(3)]-$OffsetApres] ] set Regle [string range $Blanc 0 [expr $OffsetAvant%10-1]] for {set a [expr -($OffsetAvant/10)*10]} {$a < 0} {incr a 10} { set Marque "$a " append Regle [string range $Marque 0 9] } for {set a 1} {$a<$LongN} {incr a 10} { set p [expr ($a+2)/3] set Marque "${a}<$p " append Regle [string range $Marque 0 9] } append Regle [string range $Blanc 0 [expr ($LongN-1)%10-1]] for {set a 10} {$a<$OffsetApres} {incr a 10} { set Marque "+$a " append Regle [string range $Marque 0 9] } set CodeGenetiqueN "" set CodeGenetiqueP "" foreach A {a c g t} { foreach B {a c g t} { foreach C {a c g t} { set Codon "$A$B$C" set AA [AAduCodon $Codon] set AAA [UT $AA] append CodeGenetiqueN "$Codon " append CodeGenetiqueAA [string range "$AA " 0 3] append CodeGenetiqueAAA [string totitle [string range "$AAA " 0 3]] } } } set Explication "Find below the 3 frames translation of the 2 DNA sequences. To find the differences use the horizontal scrollbar : an X indicates the mutation." set CodeGenetique "$CodeGenetiqueN\n$CodeGenetiqueAA\n$CodeGenetiqueAAA" if {$AvecReverse} { set Texte " $pep(2)\n $pep(1)\n$pep(0)\n$BlancAvant$pepOriF$BlancApres\n$adn\n$Regle\n$tdn\n $BlancAvant$pepOriR$BlancApres\n $pep(3)\n $pep(4)\n $pep(5)" } else { set Highlight "" foreach A [string toupper [split $adn ""]] T [string toupper [split $tdn ""]] { if {$A==$T} { append Highlight " " } else { append Highlight "X" } } # set Texte " $pep(2)\n $pep(5)\n$adn\n$tdn\n$Regle\n\n $pep(1)\n $pep(4)\n$adn\n$tdn\n$Regle\n\n$pep(0)\n$pep(3)\n$adn\n$tdn\n$Regle\n$BlancAvant$pepOriF$BlancApres\n$BlancAvant$pepOriR$BlancApres\n\n$Highlight" set Texte "$Explication\nFrame+2\n $pep(2)\n $pep(5)\n$adn\n$tdn\n$Regle\n\nFrame+1\n $pep(1)\n $pep(4)\n$adn\n$tdn\n$Regle\n\nFrame+0\n$pep(0)\n$pep(3)\n$adn\n$tdn\n$Regle\n$Highlight\nDifferences are highlighted with X ->" } append Texte "\nGenetic code\n$CodeGenetique" if {$SansAffichage!=""} { if {[PourWscope]} { set Texte "
$Texte
" } return $Texte } if {$Titre==""} { set Titre $Nom } return [AfficheVariable $Texte "GrandeLargeur" $Titre] Wup "AfficheVariable uses listbox, AfficheText uses widget text" return [AfficheTexte $Texte $Nom [expr $OffsetAvant-50]] } proc MultiAlignePlusieursAby {Aligneur Selection} { foreach FichierBlast [split $Selection "\n"] { set MSF [AligneLesHomologuesDuBlast $Aligneur $FichierBlast] if { $MSF == "" } { Warne "Il n'y a pas de sequences a aligner dans $FichierBlast" } else { Warne "Copie en $MSF" } } } proc HistogrammeDuNombreDeCopainsDansBlast {} { global NombreDeCopainsDansBlast if { ! [info exists NombreDeCopainsDansBlast] } { ChargeNombreDeCopainsDansBlast } foreach {Nom ValNombreDeCopainsDansBlast} [array get NombreDeCopainsDansBlast] { set nCops $ValNombreDeCopainsDansBlast if { $nCops > 2 } { lappend Liste $nCops } } Histogramme $Liste } proc HistogrammeDuFichier {Fichier {Sortie ""}} { set Liste {} foreach Ligne [LesLignesDuFichier $Fichier] { scan $Ligne "%d" N lappend Liste $N } return [Histogramme $Liste $Sortie] } proc Histogramme {ListeDeNombres {Sortie ""}} { if {$Sortie==""} { set Sortie "Term" } set MaxLargeur 80 set MaxnN -9999 foreach n $ListeDeNombres { if { ! [info exists nN($n)] } { set nN($n) 0 } incr nN($n) if { [set nN($n)] > $MaxnN } { set MaxnN [set nN($n)] } } set ListeDeNombresTriee [lsort -integer $ListeDeNombres] set Debut [lindex $ListeDeNombresTriee 0] set Fin [lindex $ListeDeNombresTriee end] set LesN [NombresEntre $Debut $Fin] set LesY {} foreach n $LesN { set x 0 if {[info exists nN($n)]} { set x [set nN($n)] } if {$Sortie=="Nombre"} { if {$x==0} { continue } Espionne "[format %3d $n] $x" continue } if {$Sortie=="Term"} { set Largeur [expr int(1.0*$x*$MaxLargeur/$MaxnN)] Espionne "[format %3d $n] [string repeat "." $Largeur]" continue } lappend LesY $x } if {$Sortie=="Graphe"} { return [Graphe $LesN $LesY] } if {$Sortie=="GetLists"} { return [list $LesN $LesY] } return "" } proc InformeSansDemander {Nom {Append ""}} { global InformeSansDemander if { ! [info exists InformeSansDemander]} { set InformeSansDemander 0 } set SauveInformeSansDemander $InformeSansDemander set InformeSansDemander 1 set Retour [Informe $Nom $Append] set InformeSansDemander $SauveInformeSansDemander return $Retour } proc InformeSansDemanderParWscope {Nom Page} { InformeSansDemander $Nom $Page return [Informe $Nom] } proc Informe {Nom {Append ""}} { global RepertoireDuGenome global FenetreInfoOuverte global FenetreSignal global LesKanvasOuverts global ListeDesContenuInfo global InfoEnMemoire global InformeSansDemander global TypeCouleur global TypeCouleurDuLinge global RetourEntreTexte Gs "Text" # if {[PourWscope]} { return [XpertComment $Nom] } set FichierInfo "$RepertoireDuGenome/infos/$Nom" if {[regexp "\n" $Append]} { foreach Ligne [split $Append "\n"] { if {[regexp "^Nom: " $Ligne]} { continue } set Inf [Informe $Nom $Ligne] } return $Inf } if {[regexp "^=CopyOf_" $Append]} { set Source [StringApres "_" dans $Append] return [Informe $Nom [ExtraitInfo $Source]] } set Remplace [regexp "^=" $Append] regsub {^[=+]} $Append "" Append if { ! [PourWscope] && [info exists FenetreInfoOuverte($Nom)]} { raise [set FenetreInfoOuverte($Nom)] if {$Append == ""} { return "[ContenuDuFichier $FichierInfo]" } if {[OuiOuNon "$Append\n doit etre rajoute a la page info $Nom\n \ La page info est deja ouverte.\n \ Dois-je abandonner ?"]} { return -1 } if {[OuiOuNon "Dois-je le faire maintenant ?"]} { [set FenetreInfoOuverte($Nom)].text insert end "$Append\n" return -2 } FaireLire "Vous ferez, plus tard, le couper-coller pour moi. Merci." return -3 } set FenetreInfoOuverte($Nom) $Nom if {! [file exists $FichierInfo] || [file size $FichierInfo]==0} { set Information "Nom: $Nom" if {[file exists "$RepertoireDuGenome/beton/infomodele"]} { append Information "\n[ContenuDuFichier $RepertoireDuGenome/beton/infomodele]" } Sauve $Information dans $FichierInfo } if {$Remplace} { scan $Append "%s" Champ set VieuxTextePurge [InformeParSuppressionDuChamp $Nom $Champ "PourVoir"] } else { set VieuxTextePurge [ContenuDuFichier $FichierInfo] } if { [info exists InformeSansDemander] && $InformeSansDemander } { set BonTexte "$VieuxTextePurge\n$Append" } else { if {[PourWscope]} { return [EntreTexte "$VieuxTextePurge\n$Append" "AvecRetourPourInforme" $FichierInfo] } set BonTexte [EntreTexte "$VieuxTextePurge\n$Append" [list "Show $Nom" "SeeAby Show $Nom"]] } if { $BonTexte != "" } { set TexteOk [Censure "$BonTexte"] Sauve $TexteOk dans $FichierInfo set InfoEnMemoire($Nom) $TexteOk if {[info exists ListeDesContenuInfo]} { set iTrouve [lsearch -regexp $ListeDesContenuInfo [string toupper "^Nom: $Nom"]] set ListeDesContenuInfo [lreplace $ListeDesContenuInfo $iTrouve $iTrouve [string toupper $TexteOk]] } if {[PourWscope]} { return $TexteOk } if {[info exists LesKanvasOuverts]} { foreach K $LesKanvasOuverts { if { ! [info exists TypeCouleur($K)]} { continue } RetexteUneBoite $Nom [NomDeScene $Nom] $K OnColorieLesFrames 1 RecoloreUneBoite $Nom [set TypeCouleur($K)] $K OnColorieLesFrames 0 RecoloreUnLinge $Nom [set TypeCouleurDuLinge($K)] $K } } } if {[info exists FenetreSignal($Nom)]} { destroy [set FenetreSignal($Nom)] unset FenetreSignal($Nom) } unset FenetreInfoOuverte($Nom) return $BonTexte } proc NombreDeCopainsDansBlast {{Nom ""}} { global NombreDeCopainsDansBlast if {[regexp -nocase {_?Reload_?} $Nom]} { if {[info exists NombreDeCopainsDansBlast]} { unset NombreDeCopainsDansBlast } regsub -nocase {_?Reload_?} $Nom "" Nom return [NombreDeCopainsDansBlast $Nom] } if {[info exists NombreDeCopainsDansBlast($Nom)]} { return $NombreDeCopainsDansBlast($Nom) } if {[info exists NombreDeCopainsDansBlast("EstCharge")]} { return $NombreDeCopainsDansBlast("EstCharge") } set NombreDeCopainsDansBlast("EstCharge") -1 set Fichier "[RepertoireDuGenome]/fiches/nombredecopainsdansblast" set NombreDeCopainsDansBlast(Filename) $Fichier if { ! [file exists $Fichier]} { return [set NombreDeCopainsDansBlast("EstCharge") -2] } foreach Ligne [LesLignesDuFichier $Fichier] { if { ! [regexp -nocase {[A-Z_0-9]+ +[0-9]+} $Ligne]} { continue } scan $Ligne "%s %d" NomLu nCops set NombreDeCopainsDansBlast($NomLu) $nCops } return [NombreDeCopainsDansBlast $Nom] } proc ChargeNombreDeCopainsDansBlast {} { #rR ne sert plus return [NombreDeCopainsDansBlast "Reload"] } proc CreeLeFichierNombreDeCopainsDansBlast {{Source ""} {SeuilExpect ""} {Extension ""}} { global RepertoireDuGenome while {$Source==""} { FaireLire "I'll create Blast Hit count, please choose the source information" set LesSources [list taxobla DifferentOX DaedalusHits apns blastx blastp tblastngenomes tblastnhuman "MyOwnBlastDirectory"] set LesTextes [list \ "Count different TaxId from Taxobla" \ "Count different TaxId" \ "Count all DaedalusHits" \ "Use ./apns/* files (obsolete)" \ "Count simply hits from BlastX" \ "Count simply hits from BlastP" \ "Count simply hits from TBlastN genomes" \ "Count simply hits from TBlastN human" \ "Count simply hits from MyOwnBlastDirectory" ] set Source [ChoixParmiJoli $LesSources {} $LesTextes] if {$Source=="MyOwnBlastDirectory"} { FaireLire "Please give the name of Your own blast directory\nthe letters 'blast' must appear in your name" set Source [Entre "blast"] } if {$Source=="" && [OuiOuNon "Do I cancel "]} { return "" } } if {$SeuilExpect==""} { set SeuilExpect 0.001 } set FichierNombreDeCopainsDansBlast "$RepertoireDuGenome/fiches/nombredecopainsdansblast$Extension" if {$Extension=="" && [OuiOuNon "Do You want to add an extension to \n\ $FichierNombreDeCopainsDansBlast"]} { set Extension [Entre ".$Source"] append FichierNombreDeCopainsDansBlast $Extension } set ListeNomNCops {} if {$Source=="DaedalusHits" || $Source=="DifferentOX"} { foreach Nom [ListeDesPABs] { set FicDaedalus "[RepertoireDuGenome]/daedalushits/$Nom" if { ! [file exists $FicDaedalus]} { continue } set nCops 0 if {[info exists DejaVu]} { unset DejaVu } foreach Ligne [LesLignesDuFichier $FicDaedalus] { set AncienneLigne $Ligne set PN [ValeurDeLaBalise PN Ligne] if {$PN==""} { continue ; FaireLire $AncienneLigne } if { [expr $PN > $SeuilExpect] } { break } set OX [ValeurDeLaBalise OX Ligne] if {[info exists DejaVu($OX)]} { continue } incr nCops if {$Source=="DifferentOX"} { set DejaVu($OX) 1 } } lappend ListeNomNCops "$Nom $nCops" } } elseif {$Source=="apns"} { set ListeDesAPNs [concat \ [glob -nocomplain "$RepertoireDuGenome/apns/*"] \ [glob -nocomplain "$RepertoireDuGenome/trousapns/*"] \ [glob -nocomplain "$RepertoireDuGenome/trouxsapns/*"] \ [glob -nocomplain "$RepertoireDuGenome/trounsapns/*"] \ ] foreach FichierAPN [lsort $ListeDesAPNs] { set Nom [file tail $FichierAPN] set nCops 0 foreach Ligne [LesLignesDuFichier $FichierAPN] { scan $Ligne "%s %s %f" BanqueId Access PN if { [expr $PN > $SeuilExpect] } { break } incr nCops } lappend ListeNomNCops "$Nom $nCops" } } elseif {[regexp "blast" $Source]} { foreach Nom [ListeDesPABs] { set FichierBlast "[RepertoireDuGenome]/$Source/$Nom" if { ! [file exists $FichierBlast]} { continue } set nCops [DecortiqueBlast $FichierBlast $SeuilExpect "" "BlastHitCount"] Espionne "$Nom $nCops" lappend ListeNomNCops "$Nom $nCops" } } elseif {[regexp "taxobla" $Source]} { foreach Nom [ListeDesPABs] { set FichierTaxobla "[RepertoireDuGenome]/$Source/$Nom" if { ! [file exists $FichierTaxobla]} { continue } set nCops [llength [LesLignesDuFichier $FichierTaxobla]] Espionne "$Nom $nCops" lappend ListeNomNCops "$Nom $nCops" } } else { FaireLire "Please give the source for CreeLeFichierNombreDeCopainsDansBlast" return "" } set Fichier [SauveLesLignes $ListeNomNCops dans $FichierNombreDeCopainsDansBlast] return [NombreDeCopainsDansBlast "Reload_Filename"] } proc CreeLesFichiersNucTfa {{Liste {}}} { global RepertoireDuGenome global ListeDeBoites Espionne $Liste if { ! [info exists ListeDeBoites] } { ChargeListeDeBoites } Wup "On peut en faire un seul, a la demande" if { $Liste == {}} { set ListeATraiter $ListeDeBoites } else { set ListeATraiter $Liste } foreach Boite $ListeATraiter { set Nom [Box $Boite nom] set Debut [Box $Boite debut] set Fin [Box $Boite fin] set Orient [Box $Boite orient] Espionne "$Nom $Debut $Fin $Orient" Espionne "$RepertoireDuGenome/nuctfa/$Nom" if {[file exists "$RepertoireDuGenome/nuctfa/$Nom"]} { continue } CreeLeFichierDansNucTfa $Nom $Debut $Fin $Orient } } proc CreeLeFichierDansNucTfa {Nom Debut Fin Orient} { global RepertoireDuGenome global ADN TDN RAC JeMeSignale if { ! [info exists ADN]} { ChargeADNetTDNetRAC } catch {unset Nuc} if { $Orient == "F" } { set Nuc [string range $ADN $Debut $Fin] } else { set Nuc "" for {set i $Fin} {[expr {$i>=$Debut}]} {incr i -1} { append Nuc [string range $TDN $i $i] } } set TFA [SequenceFormatTFA $Nuc $Nom "nucbrut"] return [Sauve $TFA dans "$RepertoireDuGenome/nuctfa/$Nom"] # set MauvaisNom "tmpreformatout.tmp" # set VraiDebut [expr [string first $MauvaisNom $GCG]+[string length $MauvaisNom]] # return [Sauve "${Nom}[string range $GCG $VraiDebut end]" dans "$RepertoireDuGenome/nuctfa/$Nom"] } proc EtudieLesProteinesDe GenomeCourant { global RepertoireDuGenome global ListeDeBoites Gs "Frame" if { ! [info exists ListeDeBoites] } { ChargeListeDeBoites } set FichiersPABs [glob "$RepertoireDuGenome/gcgs/*"] set FichiersTROUs [glob "$RepertoireDuGenome/trousgcgs/*"] set Page [join [lsort [concat $FichiersPABs $FichiersTROUs]] "\n"] return [AfficheVariable $Page "" "gcgs et trous"] } proc EtudieLesNucleiquesDe GenomeCourant { global RepertoireDuGenome global ListeDeBoites Gs "Frame" if { ! [info exists ListeDeBoites] } { ChargeListeDeBoites } set Fichiers "$RepertoireDuGenome/nuctfa/*" set Page [join [lsort [glob $Fichiers]] "\n"] return [AfficheVariable $Page "" "$Fichiers"] } proc SeeBlast Fichier { global RepertoireDuGenome set Nom [file tail $Fichier] AfficheUneSortieBlast "$RepertoireDuGenome/blasts/$Nom" } proc SeeADN FichierPep { global RepertoireDuGenome global ADN TDN RAC if { ! [info exists ADN] } { ChargeADNetTDNetRAC } set Nom [file tail $FichierPep] AfficheFichier "$RepertoireDuGenome/nuctfa/$Nom" "SansFetchAvecVoisinsAvecFormateAvecBlaste" } proc CreeADNetTDNetRACaPartirDuFichierBrut {Fichier {Start ""} {Extension ""}} { if {$Start==""} { set Start 0 } return [CreeADNetTDNetRAC [string range [ContenuDuFichier $Fichier] $Start end] $Extension] } proc CreeADNetTDNetRAC {SequenceBrute {Extension ""} {Rep ""}} { global RepertoireDuGenome global ADN TDN RAC if {$Rep==""} { set Rep [RepertoireDuGenome] } if {[file exists "$Rep/beton/adn$Extension"]} { if {[OuiOuNon "Les Fichiers $Rep/beton/adn$Extension ... existent deja.\nJe stoppe tout ?" 0]} { exit } if { [OuiOuNon "Je les garde ?" 0]} { return ""} if { ! [OuiOuNon "Je les recree ?" 1]} { return ""} } set Complement("X") "X" set Complement("x") "x" set Complement("A") "T" set Complement("T") "A" set Complement("G") "C" set Complement("C") "G" set Complement("a") "t" set Complement("t") "a" set Complement("g") "c" set Complement("c") "g" set Complement("N") "N" set Complement("n") "n" set Complement("M") "K" set Complement("K") "M" set Complement("R") "Y" set Complement("Y") "R" set Complement("W") "W" set Complement("S") "S" set Complement("m") "k" set Complement("k") "m" set Complement("r") "y" set Complement("y") "r" set Complement("w") "w" set Complement("s") "s" set Complement("V") "B" set Complement("H") "D" set Complement("D") "H" set Complement("B") "V" set Complement("v") "b" set Complement("h") "d" set Complement("d") "h" set Complement("b") "v" set ADN "n" append ADN $SequenceBrute set L [string length $ADN] set TDN "n" set RAC "n" for {set i 1} {$i<$L} {incr i} { set D [string range $ADN $i $i] set F [string range $ADN [expr $L-$i] [expr $L-$i]] append TDN [set Complement("$D")] append RAC [set Complement("$F")] } set FichierADN "$Rep/beton/adn$Extension" ; Sauve $ADN dans $FichierADN set FichierTDN "$Rep/beton/tdn$Extension" ; Sauve $TDN dans $FichierTDN set FichierRAC "$Rep/beton/rac$Extension" ; Sauve $RAC dans $FichierRAC return [list $FichierADN $FichierTDN $FichierRAC] } proc TestPcrProduct {} { set Oli5 [QueLaSequenceDuFichierTFA "[RepertoireDuGenome]/oligos/P2081.tfa"] set Oli3 [QueLaSequenceDuFichierTFA "[RepertoireDuGenome]/oligos/P2193.tfa"] set Seq [QueLaSequenceDuFichierTFA "[RepertoireDuGenome]/nuctfa/PGS990"] set R [QuestionDeScience "EVImm" "ret PcrProduct $Oli5 $Seq $Oli3 getfasta"] return $R return [PcrProduct $Oli5 $Seq $Oli3 "getfasta"] } proc PcrProduct {Oli5 Seq Oli3 {GetWhat ""}} { if {$GetWhat==""} { set GetWhat "GetFasta" } set H5 [SiteHybridisation $Oli5 $Seq "F"] set H3 [SiteHybridisation $Oli3 $Seq "R"] scan $H5 "%d %d %d %s" I5 IA5 Tm5 S5 scan $H3 "%d %d %d %s" I3 IA3 Tm3 S3 if {$IA5>$IA3} { set PPCR "X" set Entete "NoPcrProduct $I5 $IA5 $Tm5 $S5 $I3 $IA3 $Tm3 $S3" } else { set R3 [NucToReverseAndComplementNuc $Oli3] set SS [string range $Seq [expr $IA5 - 1] [expr $IA3 -1]] set PPCR "$Oli5$SS$R3" set Entete "PcrProduct $I5 $IA5 $Tm5 $S5 $I3 $IA3 $Tm3 $S3" } set TFA [SequenceFormatTFA $PPCR $Entete] if {[string equal -nocase "GetFasta" $GetWhat]} { return $TFA } return "$PPCR $I5 $IA5 $Tm5 $S5 $I3 $IA3 $Tm3 $S3" } proc SiteHybridisation {SeqO Sequence {FouR ""}} { if {$FouR==""} { set FouR "F" } set SO [string toupper $SeqO] if {$FouR=="R"} { set SO [NucToReverseAndComplementNuc $SO] } set SS [string toupper $Sequence] while 1 { set I [string first $SO $SS] Espionne "$I $SO" if {$I>0} { break } if {$SO==""} { break } if {$FouR=="F"} { set SO [string range $SO 1 end] } else { set SO [string range $SO 0 end-1] } } set LSO [string length $SO] set TmH 0 foreach C [split $SO ""] { if {$C=="A" | $C=="T"} { incr TmH 2 } if {$C=="G" | $C=="C"} { incr TmH 4 } } if {$FouR=="F"} { set IDebut [expr $I + 1] set IApresOli5 [expr $IDebut + $LSO] return "$IDebut $IApresOli5 $TmH $SO" } else { set SO [NucToReverseAndComplementNuc $SO] set IAvantOli3 [expr $I - 1 + 1] set IFin [expr $IAvantOli3 + $LSO] return "$IFin $IAvantOli3 $TmH $SO" } } proc TestPDB {} { set Lpdbid [list 1c0a 1il2 1asy] source [HomeRipp]/oso.tcl SetupPDBObject foreach pdbid $Lpdbid { set file "/db/catalog/pdb/compressed_files/[string range $pdbid 1 2]/pdb${pdbid}.ent.gz" Structure create $pdbid set cok [$pdbid new $file "" 0 0] foreach c [$pdbid _chains] { puts "$pdbid" puts "$c [$pdbid _chainIs $c]" # set s [join [$pdbid _resname -chain A] ""] } } exit foreach pdbid $Lpdbid { Structure create $pdbid set Rep [string range $pdbid 1 2] set file "/db/catalog/pdb/compressed_files/[string range $pdbid 1 2]/pdb${pdbid}.ent.gz" set cok [$pdbid new $file "" 0 0] foreach c [$pdbid _chains] { Espionne "$pdbid chain $c is [$pdbid _chainIs $c]" Espionne "$pdbid chain $c is [$pdbid _chainIs $c]" # Espionne [$pdbid _resname -chain $c] } $pdbid destroy } exit }