Index by: file name |
procedure name |
procedure call |
annotation
gscope_homolog.tcl
(annotations | original source)
#rR gscope_homolog.tcl
proc OuATapeTBlastX {Fichier Banque QuoiRetourner} {
FaireLire "OuATapeTBlastX est encore a developper"
set Nom [file tail $Fichier]
Wup " pour MS00068MS00069"
if {[regexp -nocase {([A-Z]+[0-9]+)[A-Z]} $Nom Match VraiNom] } { set Nom $VraiNom }
if {[Enterre $Nom] } {
return {}
}
set DebutNom [Box $Nom debut]
set FinNom [Box $Nom fin]
set ListeDesHomologues [ChaqueProteineDuTBlastX $Fichier]
if {$ListeDesHomologues == {} } { return {}}
catch {unset ListeDesDupliques}
catch {unset ListeDesPositions}
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]
set ABC(0) "A"
set ABC(1) "B"
set ABC(2) "C"
set DEF(0) "D"
set DEF(1) "E"
set DEF(2) "F"
if {$DebutQuery < $FinQuery} {
set OrientQuery "F"
set Frame [set ABC([expr ($DebutQuery-1)%3])]
} else {
set OrientQuery "R"
set Frame [set DEF([expr ($DebutQuery-1)%3])]
}
set BeauLongSbjct [format "%4d" $LongSbjct]
set BeauDebut [format "%8d" $DebutQuery]
set BeauFin [format "%8d" $FinQuery]
set BelleBanqueId [format "%-20s" [string trim $BanqueId]]
set UnSegment "$Nom $OrientQuery $Frame $BelleBanqueId $BeauDebut $BeauFin $BeauLongSbjct $Expect"
lappend LesSegments $UnSegment
lappend ListeDesPositions [expr ($DebutQuery+$FinQuery)/2]
lappend ListeDesPositions [expr ($DebutSbjct+$FinSbjct)/2]
lappend ListeDesOrganismes $BanqueId
if {$QuoiRetourner == "ListeDesDupliques"} {
set Touches [QuiEstLa $DebutSbjct $FinSbjct $Banque]
catch {unset Eux}
foreach Lui $Touches {
if {$Lui == $Nom} { continue }
if {[Decede $Lui]} { continue }
set DebutLui [Box $Lui debut]
set FinLui [Box $Lui fin]
set Tri [lsort -integer [list $DebutLui $FinLui $DebutSbjct $FinSbjct]]
set Recouvrement [expr [lindex $Tri 2]-[lindex $Tri 1]+1]
set TauxDeRecouvrement [expr (1.0*$Recouvrement)/$LongSbjct]
if { [expr $TauxDeRecouvrement < 0.1] } {
continue
}
lappend Eux "$Lui"
}
if {[info exists Eux]} {
lappend ListeDesDupliques $Eux
} else {
}
if {$Touches == {}} {
}
}
}
return [lsort -increasing -command CompareLesExpectsDesSegments $LesSegments]
if {$QuoiRetourner == "ListeDesDupliques"} {
if {[info exists ListeDesDupliques]} {
return $ListeDesDupliques
} else {
return {}
}
}
if {$QuoiRetourner == "ListeDesPositions"} {
if {[info exists ListeDesPositions]} {
return $ListeDesPositions
} else {
return {}
}
}
if {$QuoiRetourner == "ListeDesOrganismes"} {
if {[info exists ListeDesOrganismes]} {
return $ListeDesOrganismes
} else {
return {}
}
}
}
proc OuATapeBlastX {Fichier {QuoiRetourner ""}} {
set Nom [file tail $Fichier]
if {$QuoiRetourner==""} { set QuoiRetourner "ListeDesPositions" }
if {[Enterre $Nom] } {
return {}
}
set DebutNom [Box $Nom debut]
set FinNom [Box $Nom fin]
set ListeDesHomologues [ChaqueProteineDuBlastX $Fichier]
if {$ListeDesHomologues == {} } { return {}}
catch {unset ListeDesDupliques}
catch {unset ListeDesPositions}
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]
set ABC(0) "A"
set ABC(1) "B"
set ABC(2) "C"
set DEF(0) "D"
set DEF(1) "E"
set DEF(2) "F"
if {$DebutQuery < $FinQuery} {
set OrientQuery "F"
set Frame [set ABC([expr ($DebutQuery-1)%3])]
} else {
set OrientQuery "R"
set Frame [set DEF([expr ($DebutQuery-1)%3])]
}
set BeauLongSbjct [format "%4d" $LongSbjct]
set BeauDebut [format "%8d" $DebutQuery]
set BeauFin [format "%8d" $FinQuery]
set BelleBanqueId [format "%-20s" [string trim $BanqueId]]
set UnSegment "$Nom $OrientQuery $Frame $BelleBanqueId $BeauDebut $BeauFin $BeauLongSbjct $Expect"
lappend LesSegments $UnSegment
lappend ListeDesPositions [expr ($DebutQuery+$FinQuery)/2]
lappend ListeDesPositions [expr ($DebutSbjct+$FinSbjct)/2]
lappend ListeDesOrganismes $BanqueId
if {$QuoiRetourner == "ListeDesDupliques"} {
set Touches [QuiEstLa $DebutSbjct $FinSbjct $Banque]
catch {unset Eux}
foreach Lui $Touches {
if {$Lui == $Nom} { continue }
if {[Decede $Lui]} { continue }
set DebutLui [Box $Lui debut]
set FinLui [Box $Lui fin]
set Tri [lsort -integer [list $DebutLui $FinLui $DebutSbjct $FinSbjct]]
set Recouvrement [expr [lindex $Tri 2]-[lindex $Tri 1]+1]
set TauxDeRecouvrement [expr (1.0*$Recouvrement)/$LongSbjct]
if { [expr $TauxDeRecouvrement < 0.1] } {
continue
}
lappend Eux "$Lui"
}
if {[info exists Eux]} {
lappend ListeDesDupliques $Eux
} else {
}
if {$Touches == {}} {
}
}
}
return [lsort -increasing -command CompareLesExpectsDesSegments $LesSegments]
if {$QuoiRetourner == "ListeDesDupliques"} {
if {[info exists ListeDesDupliques]} {
return $ListeDesDupliques
} else {
return {}
}
}
if {$QuoiRetourner == "ListeDesPositions"} {
if {[info exists ListeDesPositions]} {
return $ListeDesPositions
} else {
return {}
}
}
if {$QuoiRetourner == "ListeDesOrganismes"} {
if {[info exists ListeDesOrganismes]} {
return $ListeDesOrganismes
} else {
return {}
}
}
}
proc DiffTaillesDesTroisOrthologuesDuMSFPourTous {} {
global RepertoireDuGenome
set LesDiffTailles {}
foreach Nom [ListeDesPABs] {
set Rapport [DiffBlaAli $Nom]
if {$Rapport==""} { continue }
if {3!=[scan $Rapport "%s %s %s" Etat Bla DbC]} { continue }
set DiffTailles [DiffTaillesDesTroisOrthologuesDuMSF $Nom $Bla $DbC]
Espionne "$DiffTailles $Etat"
lappend LesDiffTailles $DiffTailles
}
return $LesDiffTailles
}
proc DiffTaillesDesTroisOrthologuesDuMSF {NomOuFichier Bla DbC {Que ""}} {
global RepertoireDuGenome
set Nom [file tail $NomOuFichier]
if {$Que==""} { set Que $Nom }
if {[regexp "/" $NomOuFichier]} {
set FichierMSF $NomOuFichier
} elseif {[EstUnPAB $Nom]} {
set FichierMSF "$RepertoireDuGenome/msf/$Nom"
} else {
set FichierMSF $NomOuFichier
}
if { ! [file exists $FichierMSF]} { return 0 }
DecortiqueUnMSF $FichierMSF LesSequencesDansLOrdre Sequences
if { ! [info exists Sequences($Que)]} {
set Que [string toupper $Que]
if { ! [info exists Sequences($Que)]} {
return -1
}
}
if { ! [info exists Sequences($Bla)]} {
set Bla [string toupper $Bla]
if { ! [info exists Sequences($Bla)]} {
return -2
}
}
if { ! [info exists Sequences($DbC)]} {
set DbC [string toupper $DbC]
if { ! [info exists Sequences($DbC)]} {
return -3
}
}
set SeqQue [set Sequences($Que)]
set SeqBla [set Sequences($Bla)]
set SeqDbC [set Sequences($DbC)]
set lQ 0
set lB 0
set lD 0
set lQB 0
set lBD 0
set lDQ 0
set lQBD 0
foreach Q [split $SeqQue ""] B [split $SeqBla ""] D [split $SeqDbC ""] {
if {$Q!="."} { incr lQ }
if {$B!="."} { incr lB }
if {$D!="."} { incr lD }
if {$Q!="." && $B!="."} { incr lQB }
if {$B!="." && $D!="."} { incr lBD }
if {$D!="." && $Q!="."} { incr lDQ }
if {$Q!="." && $B!="." && $D!=0} { incr lQBD }
}
set lMax [Maxi [Maxi $lQ $lB] $lD]
set lMin [Mini [Mini $lQ $lB] $lD]
set pMinMax [expr (100*$lMin)/$lMax]
set pQMax [expr (100*$lQ)/$lMax]
set pBMax [expr (100*$lB)/$lMax]
set pDMax [expr (100*$lD)/$lMax]
return "$lQ $lB $lD $lQB $lBD $lDQ $lMax $lMin $pQMax $pBMax $pDMax $pMinMax"
}
proc TestYaOrthologue {} {
global RepertoireDuGenome
set Somme 0
set n 0
foreach Nom [ListeDesPABs] {
incr n
# set Somme [expr $Somme + [PourcentageIdentiteOrga $Nom phor "$RepertoireDuGenome/fiches/piclustalw"]]
incr Somme [YaOrthologue $Nom phor $RepertoireDuGenome]
# set Somme [expr $Somme + [PourcentageIdentiteOrga $Nom phor "$RepertoireDuGenome/fiches/piclustalw"]]
}
puts [expr $Somme/$n]
puts $n
exit
}
proc YaOrthologue {Nom Orga {Genome ""}} {
global RepertoireDuGenome
Wup "return 1 if piclustalw exists and >= 20"
set SeuilYaOrthologue 20
Wup "YaOrthologue works also for other genomes"
if {$Genome==""} {
if {[YaPABouTROUouTRNAouARNenDebutDe $Nom]} {
set FichierPIC ""
} else {
set Genome [lindex [GenomeDu $Nom] 0]
set FichierPIC "$Genome/fiches/piclustalw"
}
} else {
if { ! [file exists $Genome]} {
set Genome "$RepertoireDuGenome/../$Genome"
}
set FichierPIC "$Genome/fiches/piclustalw"
}
set PI [PourcentageIdentiteOrga $Nom $Orga $FichierPIC]
return [expr $PI >= $SeuilYaOrthologue]
}
proc NombreDeOrthologues Nom {
return [NombreDeHomologues $Nom orth]
}
proc NombreDeOrganismesOrthologues Nom {
return [NombreDeHomologues $Nom orga]
}
proc NombreDeHomologues {Nom {Type "homo"}} {
global NombreDeHomologues
global RepertoireDuGenome
global NotreOrga
set Type [string range [string tolower $Type] 0 3]
if {[info exists NombreDeHomologues($Nom,$Type)]} { return [set NombreDeHomologues($Nom,$Type)] }
if {[info exists NombreDeHomologues]} { return 0 }
set FichierNombreHomo "$RepertoireDuGenome/fiches/nombredehomologues"
if {[file exists $FichierNombreHomo]} {
foreach Ligne [LesLignesDuFichier $FichierNombreHomo] {
scan $Ligne "%s %d %d %d" NomLu nHomologues nOrthologues nOrganismes
set NombreDeHomologues($NomLu,homo) $nHomologues
set NombreDeHomologues($NomLu,orth) $nOrthologues
set NombreDeHomologues($NomLu,orga) $nOrganismes
}
set NombreDeHomologues(Bidon) "EstCharge"
return [NombreDeHomologues $Nom $Type]
}
set FichierPIC "$RepertoireDuGenome/fiches/piclustalw.$NotreOrga"
if { ! [file exists $FichierPIC]} { return -1 }
foreach Ligne [LesLignesDuFichier $FichierPIC] {
set nHomologues 0
set nOrthologues 0
set nOrganismes 0
scan $Ligne "%s" NomLu
if {[info exists DejaVu]} { unset DejaVu }
foreach {Orga PI} [lrange [split $Ligne " "] 1 end] {
if {$PI<20} { break }
incr nHomologues
if {$Orga==$NotreOrga} { continue }
incr nOrthologues
if {[info exists DejaVu($Orga)]} { continue }
set DejaVu($Orga) 1
incr nOrganismes
}
set NombreDeHomologues($NomLu,homo) $nHomologues
set NombreDeHomologues($NomLu,orth) $nOrthologues
set NombreDeHomologues($NomLu,orga) $nOrganismes
lappend LaSauvegarde "$NomLu $nHomologues $nOrthologues $nOrganismes"
}
SauveLesLignes $LaSauvegarde dans $FichierNombreHomo
set NombreDeHomologues(Bidon) "EstCharge"
return [NombreDeHomologues $Nom $Type]
}
proc ExisteOrthologueDans {Orga Nom} {
global OrthologueDans
global RepertoireDuGenome
if { ! [info exists OrthologueDans]} { ChargeOrthologueDans }
if { [info exists OrthologueDans($Orga,$Nom)] && [set OrthologueDans($Orga,$Nom)] } {
return 1
} else {
return 0
}
}
proc ChargeLesOrthologuesDe {} {
global RepertoireDuGenome
global LesOrthologuesDe
JeMeSignale Patience
set FichierOrganismesOrthologues "$RepertoireDuGenome/fiches/organismesorthologues"
if { ! [file exists $FichierOrganismesOrthologues]} {
set LesOrthologuesDe(Bidon) "EstCharge"
return ""
}
foreach Ligne [LesLignesDuFichier $FichierOrganismesOrthologues] {
set Liste [split $Ligne " "]
set Nom [lindex $Ligne 0]
Wup "On accepte le melange Genre espece court Genre espece court court Genre espece court ..."
set YaGenre 0
foreach Mot [lrange $Ligne 1 end] {
if {$YaGenre} {
lappend LesOrthologuesDe($Nom) "$Genre $Mot"
set YaGenre 0
} else {
if {[regexp {^[A-Z]} $Mot]} {
set YaGenre 1
set Genre $Mot
} else {
lappend LesOrthologuesDe($Nom) "$Mot"
}
}
}
set LesOrthologuesDe(Bidon) "EstCharge"
}
JeMeSignale FinPatience
}
proc OrganismesOrthologues {K X Y} {
global LesOrthologuesDe
if { ! [info exists LesOrthologuesDe]} { ChargeLesOrthologuesDe }
set Boite [BoiteDuCourant $K $X $Y]
if { $Boite == "" } { return $Boite}
set Nom [Box $Boite nom]
if { ! [info exists LesOrthologuesDe($Nom)]} { return "" }
set Ortho [ChoixParmi [set LesOrthologuesDe($Nom)]]
if { $Ortho == "" } { return "" }
return $Ortho
}
proc HistogrammeDuNombreDeParalogues {{Format "Graphe"}} {
foreach Nom [ListeDesPABs] {
set n [NombreDeParaloguesDe $Nom]
if {$n>0} {
lappend LesNombres $n
}
}
Histogramme $LesNombres $Format
}
proc NombreDeParaloguesDe Nom {
return [llength [ParaloguesDe $Nom]]
}
proc ParaloguesDe {Nom {Format ""}} {
global LesParaloguesDe
if { ! [info exists LesParaloguesDe($Format)]} {
ChargeLesParaloguesDe $Format
set LesParaloguesDe($Format) "SontCharges"
}
if {$Format==""} {
if {[info exists LesParaloguesDe($Nom)]} {
return [set LesParaloguesDe($Nom)]
} else {
return {}
}
} else {
if {[info exists LesParaloguesDe($Nom,$Format)]} {
return [set LesParaloguesDe($Nom,$Format)]
} else {
return {}
}
}
}
proc ChargeLesParaloguesDe {{Format ""}} {
global RepertoireDuGenome
global LesParaloguesDe
set Extension "blastp"
if {$Format=="msf"} { set Extension "msf" }
set Fichier "$RepertoireDuGenome/fiches/paralogues.$Extension"
if { ! [file exists $Fichier] } { set LesParaloguesDe(Bidon) {} ; return }
foreach Ligne [LesLignesDuFichier $Fichier] {
regsub -all "\{" $Ligne "" Ligne
regsub -all "\}" $Ligne "" Ligne
set Liste [split [string trim $Ligne] " "]
set Nom [lindex $Ligne 0]
set LesParaloguesDe($Nom) [lrange $Ligne 1 end]
}
if {$Format!=""} {
foreach Ligne [LesLignesDuFichier "$Fichier.$Format"] {
set Liste [split [string trim $Ligne] " "]
set Nom [lindex $Ligne 0]
set APN [join [lrange $Ligne 1 end] " "]
lappend LesParaloguesDe($Nom,$Format) $APN
}
}
}
proc SautParalogue {K X Y} {
set Boite [BoiteDuCourant $K $X $Y]
if { $Boite == "" } { return $Boite}
set Nom [Box $Boite nom]
set LesParas [ParaloguesDe $Nom]
if { $LesParas == {} } { return "" }
foreach Para LesParas {
set DE [DefinitionApproximative $Para]
lappend LesBeauxParas "$Para $DE"
}
set Para [ChoixParmi $LesParas $LesBeauxParas]
if { $Para == "" } { return "" }
RepereBox "Nom: $Para" $K
return $Para
}
proc ChargeOrthologueDans {} {
global RepertoireDuGenome
global OrthologueDans
foreach O [LesOrganismesTresProches] {
set OrthologueDans($O) Bidon
if { ! [file exists "$RepertoireDuGenome/fiches/orthologuedans$O"]} { continue }
foreach Ligne [LesLignesDuFichier "$RepertoireDuGenome/fiches/orthologuedans$O"] {
scan $Ligne "%s %s" Nom Rapport
if {[regexp "Mort" $Rapport]} {
set OrthologueDans($O,$Nom) 0
} else {
set OrthologueDans($O,$Nom) 1
}
}
}
}
proc CreeLeFichierOrthologueDans {Orga {OrgaEstUneBanque 0}} {
global RepertoireDuGenome
if {$OrgaEstUneBanque} {
set Banque $Orga
} else {
set Banque "genomes"
}
foreach Nom [ListeDesPABs] {
set Fichier "$RepertoireDuGenome/tblastn$Banque/$Nom"
if {[Enterre $Nom]} { continue }
if { ! [file exists $Fichier]} { continue }
set Rapport [OrthologueDansTBlastN $Nom $Orga]
puts "$Nom $Rapport"
lappend ListeNomRapport "$Nom $Rapport"
}
Espionne [SauveLesLignes $ListeNomRapport dans "$RepertoireDuGenome/fiches/orthologuedans$Orga"]
}
proc CreeLeFichierExpectDans Banque {
global RepertoireDuGenome
foreach Nom [ListeDesPABs] {
set Fichier "$RepertoireDuGenome/tblastn$Banque/$Nom"
if {[Enterre $Nom]} { continue }
if { ! [file exists $Fichier]} { continue }
DecortiqueBlast $Fichier \
"SansSeuilExpect" "SansLimiteDeNombre" Query lBanqueId lAccess lDE lProfil lPN
if {[llength $lPN] == 0} {
lappend ListeNomPN "$Nom 9999.9"
} else {
lappend ListeNomPN "$Nom [lindex $lPN 0]"
}
}
SauveLesLignes $ListeNomPN dans "$RepertoireDuGenome/fiches/expectdans$Banque"
}
proc CompteDesOrganismesAyantMemeOperon Nom {
global LesOrganismesAyantMemeOperon
if { ! [info exists LesOrganismesAyantMemeOperon] } {
ChargeLesOrganismesAyantMemeOperon
}
if { ! [info exists LesOrganismesAyantMemeOperon(LaListeMerci,Compte)] } {
foreach {Clef Valeur} [array get LesOrganismesAyantMemeOperon] {
if { ! [regexp ",Compte$" $Clef]} { continue }
lappend LesComptes $Valeur
}
set LesOrganismesAyantMemeOperon(LaListeMerci,Compte) $LesComptes
}
if { [info exists LesOrganismesAyantMemeOperon($Nom,Compte)] } {
return [set LesOrganismesAyantMemeOperon($Nom,Compte)]
} else {
return 0
}
}
proc ListeDesOrganismesAyantMemeOperon Nom {
global LesOrganismesAyantMemeOperon
if { ! [info exists LesOrganismesAyantMemeOperon] } {
ChargeLesOrganismesAyantMemeOperon
}
if { [info exists LesOrganismesAyantMemeOperon($Nom)] } {
return [set LesOrganismesAyantMemeOperon($Nom)]
} else {
return {}
}
}
proc ChargeLesOrganismesAyantMemeOperon {} {
global RepertoireDuGenome
global LesOrganismesAyantMemeOperon
global NotreOS
global NotreOrga
global DejaVuCetOrgaAyantMemeOperon
global ListeCompleteDesOrganismesAyantMemeOperon
set FichierOMO "$RepertoireDuGenome/fiches/organismesayantmemeoperon"
if { ! [file exists $FichierOMO]} {
set LesOrganismesAyantMemeOperon(Est-Il-Valide) 0
return 0
}
set LesOrganismesAyantMemeOperon(Est-Il-Valide) 1
foreach Ligne [LesLignesDuFichier $FichierOMO] {
while {[regexp " " $Ligne]} { regsub -all " " $Ligne " " Ligne }
set NomVoisinEtOrgas [split [string trim $Ligne] " "]
if {[llength $NomVoisinEtOrgas] < 3} { continue }
set Nom [lindex $NomVoisinEtOrgas 0]
set Voisin [lindex $NomVoisinEtOrgas 1]
Wup "Attention, le voisin est ci dessous en premiere position"
set LesOrgas {}
foreach Orga [lrange $NomVoisinEtOrgas 1 end] {
if {[regexp -nocase "^$NotreOrga$" $Orga] } { continue }
lappend LesOrgas $Orga
if {[info exists DejaVuCetOrgaAyantMemeOperon($Orga)]} { continue }
set DejaVuCetOrgaAyantMemeOperon($Orga) 1
if { ! [EstUnPAB $Orga]} { lappend ListeCompleteDesOrganismesAyantMemeOperon $Orga }
}
set N [expr [llength $LesOrgas] -1]
set OldN 0
if {[info exists LesOrganismesAyantMemeOperon($Nom,Compte)]} {
set OldN [set LesOrganismesAyantMemeOperon($Nom,Compte)]
}
set LesOrganismesAyantMemeOperon($Nom,Compte) [Maxi $N $OldN]
set OldNV 0
if {[info exists LesOrganismesAyantMemeOperon($Voisin,Compte)]} {
set OldNV [set LesOrganismesAyantMemeOperon($Voisin,Compte)]
}
set LesOrganismesAyantMemeOperon($Voisin,Compte) [Maxi $N $OldNV]
set LesOrganismesAyantMemeOperon($Nom) $LesOrgas
}
return 1
}
proc OrganismesAyantMemeOperon {lPA lOA lPB lOB} {
Wup "On retourne un organisme court ... tant pis pour les duplications"
foreach {PA A} $lPA OA $lOA {
foreach {PB B} $lPB OB $lOB {
if { $OA != $OB } { continue }
set DPP [Maxi 10 [expr abs($PB-$PA)]]
set DAB [expr abs($B-$A)]
set DD [expr abs($DPP-$DAB)]
set ErreurRelative [expr (1.0*$DD)/$DPP]
if {[expr $ErreurRelative < 2.0]} {
set O [Glossaire $OA Court]
if {$O==""} { set O "xxxx" }
lappend LesOrgasRetenus $O
} else {
}
}
}
if {[info exists LesOrgasRetenus]} {
set OldO "xxxxxxx"
foreach O [lsort -ascii $LesOrgasRetenus] {
if { $OldO == $O } { continue }
lappend LesOrgasTries $O
set OldO $O
}
return [join $LesOrgasTries " "]
} else {
return ""
}
}
proc CreeLeFichierOrganismesAyantMemeOperon {{Banque genomes} {SensSepares 0}} {
global ListeDeBoites
global RepertoireDuGenome
global MemoPositionsDesAmis
global MemoOrganismesDesAmis
set FichierOMO "$RepertoireDuGenome/fiches/organismesayantmemeoperon"
while {[file exists $FichierOMO]} {
if {[OuiOuNon "$FichierOMO already exists,\nDo I append to it ?"]} { break }
if {[OuiOuNon "$FichierOMO already exists,\nDo I replace it ?"]} {
File delete $FichierOMO
break
}
if {[OuiOuNon "Do I cancel ?"]} { return "" }
if {[OuiOuNon "Do I stop ?"]} { exit }
}
if { ! [info exists MemoPositionsDesAmis] \
&& [file exists "$RepertoireDuGenome/fiches/ouatapetbn.$Banque"] \
&& [OuiOuNon "Can I use $RepertoireDuGenome/fiches/ouatapetbn.$Banque"]} {
foreach Ligne [LesLignesDuFichier "$RepertoireDuGenome/fiches/ouatapetbn.$Banque"] {
set LesMots [split $Ligne " "]
set Nom [lindex $LesMots 0]
if {[regexp -nocase {[a-z]} [lindex $LesMots 1]]} {
set MemoOrganismesDesAmis($Nom) [lrange $LesMots 1 end]
}
if {[regexp -nocase {[0-9]} [lindex $LesMots 1]]} {
set MemoPositionsDesAmis($Nom) [lrange $LesMots 1 end]
}
}
}
if { ! [info exists AQuiEstCeDebut]} {
if { ! [info exists ListeDeBoites] } { ChargeListeDeBoites }
foreach Boite $ListeDeBoites {
set Nom [Box $Boite nom]
if {[Enterre $Nom] || ! [YaPABdans $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]
}
foreach Sens [list "F"] {
catch {unset PositionsDesAmisDuVoisin}
foreach Debut $LesDebutsTries {
set Nom [lindex [set AQuiEstCeDebut($Debut)] 0]
set Orient [Box $Nom orient]
if { $SensSepares && ($Orient != $Sens) } { continue }
set Debut [Box $Nom debut]
set Fin [Box $Nom fin]
set Fichier "$RepertoireDuGenome/tblastn$Banque/$Nom"
if {[FileAbsent $Fichier]} { continue }
if {[info exists MemoPositionsDesAmis($Nom)]} {
set OrganismesDesAmis [set MemoOrganismesDesAmis($Nom)]
set PositionsDesAmis [set MemoPositionsDesAmis($Nom)]
} else {
set PositionsDesAmis {}
set OrganismesDesAmis {}
set LesHits [OuATapeTBlastN $Fichier $Banque "ListeDesPositions"]
foreach Hit $LesHits {
Espionne "Hit $Hit"
regsub -all ">" $Hit " " Hit
set OX [StringApres "<OX " dans $Hit]
set DQ [StringApres "<DQ " dans $Hit]
set FQ [StringApres "<FQ " dans $Hit]
set DS [StringApres "<DS " dans $Hit]
set FS [StringApres "<FS " dans $Hit]
set MQ [expr ($DQ+$FQ)/2]
set MS [expr ($DS+$FS)/2]
lappend PositionsDesAmis $MQ $MS
set Orga [Glossaire [Tax $OX] Court]
lappend OrganismesDesAmis $Orga
Espionne "$Nom $OX [Tax $OX] $MQ $MS"
}
# set OrganismesDesAmis [OuATapeTBlastN $Fichier $Banque "ListeDesOrganismes"]
# set PositionsDesAmis [OuATapeTBlastN $Fichier $Banque "ListeDesPositionsVieux"]
}
if { $PositionsDesAmis != {} \
&& [info exists PositionsDesAmisDuVoisin] \
&& $PositionsDesAmisDuVoisin != {} } {
Espionne "OrganismesAyantMemeOperon \
$PositionsDesAmisDuVoisin $OrganismesDesAmisDuVoisin \
$PositionsDesAmis $OrganismesDesAmis"
set OMO [OrganismesAyantMemeOperon \
$PositionsDesAmisDuVoisin $OrganismesDesAmisDuVoisin \
$PositionsDesAmis $OrganismesDesAmis]
if { $OMO != "" } {
lappend lNomVoisinOMO "$Nom $Voisin $OMO"
}
}
set PositionsDesAmisDuVoisin $PositionsDesAmis
set OrganismesDesAmisDuVoisin $OrganismesDesAmis
set Voisin $Nom
set DebutVoisin $Debut
set FinVoisin $Fin
}
}
foreach Ligne $lNomVoisinOMO {
set Liste [split $Ligne " "]
set Nom [lindex $Liste 0]
set Voisin [lindex $Liste 1]
set lOMO [lrange $Liste 2 end]
foreach O $lOMO {
if { ! [regexp -nocase {[a-z]} $O]} {
FaireLire "$Ligne\n contient un blanc."
}
if { ! [info exists Occurrence($O)]} {
set Occurrence($O) 0
}
incr Occurrence($O)
}
}
foreach {O ValOccurrence} [array get Occurrence] {
lappend LesOrgasDeOccurrence($ValOccurrence) $O
lappend ListeDesValeurs $ValOccurrence
}
set LesValeursTriees [lsort -decreasing -integer $ListeDesValeurs]
set OldValeur -1
foreach Valeur $LesValeursTriees {
if {$Valeur == $OldValeur} { continue }
set OldValeur $Valeur
foreach O $LesOrgasDeOccurrence($Valeur) {
lappend ListeDesOrgasTries $O
}
}
foreach Ligne $lNomVoisinOMO {
set Liste [split $Ligne " "]
set Nom [lindex $Liste 0]
set Voisin [lindex $Liste 1]
set lOMO [lrange $Liste 2 end]
set BelleLigne "$Nom $Voisin"
foreach Orga [lrange $ListeDesOrgasTries 0 end] {
if {[regexp $Orga $Ligne]} {
append BelleLigne [format " %4s" $Orga]
} else {
append BelleLigne " "
}
}
lappend ListeDesBellesLignes $BelleLigne
AppendAuFichier $FichierOMO $BelleLigne
}
return $FichierOMO
}
proc NombreDOrganismesAyantMemeOperons Nom {
set ListeOMO [ListeDesOrganismesAyantMemeOperon $Nom]
}
proc CouleurSuivantOrganismesAyantMemeOperon Nom {
global CouleurDuFond
global Org1 Org2
set ListeOMO [lrange [ListeDesOrganismesAyantMemeOperon $Nom] 1 end]
set nOMO [llength $ListeOMO]
if { $nOMO == 0 } {
set Couleur "white"
} elseif { $nOMO == 1 && [regexp $Org1 $ListeOMO]} {
set Couleur "skyblue"
} elseif { $nOMO == 1 && [regexp $Org2 $ListeOMO]} {
set Couleur "blue"
} elseif { $nOMO == 2 && [regexp $Org1 $ListeOMO] && [regexp $Org2 $ListeOMO]} {
set Couleur "green"
} elseif { $nOMO == 2 && [regexp $Org1 $ListeOMO] && ![regexp $Org2 $ListeOMO]} {
set Couleur "yellow"
} elseif { $nOMO == 2 && ![regexp $Org1 $ListeOMO] && [regexp $Org2 $ListeOMO]} {
set Couleur "orange"
} elseif { $nOMO > 2 && [regexp $Org1 $ListeOMO] && [regexp $Org2 $ListeOMO]} {
set Couleur "red"
} elseif { $nOMO > 2 && ![regexp $Org1 $ListeOMO] && [regexp $Org2 $ListeOMO]} {
set Couleur "pink"
} elseif { $nOMO > 2 && [regexp $Org1 $ListeOMO] && ![regexp $Org2 $ListeOMO]} {
set Couleur "purple"
} else {
set Couleur "black"
}
return $Couleur
}
proc RelieLesOperons {K Position} {
global LesOrdresPourGif
set PourGif [string equal $K "OrdrePourGif"]
foreach Boite [ListeDesPABs] {
set Nom [Box $Boite nom]
set ListeOMO [ListeDesOrganismesAyantMemeOperon $Nom]
if { [llength $ListeOMO] < 2 } { continue }
set Voisin [lindex $ListeOMO 0]
set Couleur [CouleurSuivantOrganismesAyantMemeOperon $Nom]
if { [Box $Nom orient] == "F" } {
set yHautMoi [expr $Position-30]
set yBasMoi [expr $Position-3]
set StartMoi 270.
} else {
set yHautMoi [expr $Position+3]
set yBasMoi [expr $Position+30]
set StartMoi 0.
}
if { [Box $Voisin orient] == "F" } {
set yHautLui [expr $Position-30]
set yBasLui [expr $Position-3]
set StartLui 180.
} else {
set yHautLui [expr $Position+3]
set yBasLui [expr $Position+30]
set StartLui 90.
}
if {$PourGif || 1} {
set xMoi [Milieu $Nom]
set xLui [Milieu $Voisin]
} else {
set Moi [$K find withtag $Nom]
set Lui [$K find withtag $Voisin]
scan [$K coords $Moi] "%f %f %f %f" a b c d
set xMoi [expr ($a+$c)/2]
set yMoi [expr ($b+$d)/2]
scan [$K coords $Lui] "%f %f %f %f" a b c d
set xLui [expr ($a+$c)/2]
set yLui [expr ($b+$d)/2]
}
$K create arc $xLui $yHautLui $xMoi $yBasLui \
-start $StartLui -extent 90. -style arc -outline $Couleur -width 2 \
-tags [list "WebEnter" [TexteOMO $Nom "Long"]]
$K create arc $xLui $yHautMoi $xMoi $yBasMoi \
-start $StartMoi -extent 90. -style arc -outline $Couleur -width 2 \
-tags [list "WebEnter" [TexteOMO $Nom "Long"]]
set xMilieu [expr ($xMoi+$xLui)/2]
set yMilieu [expr ($yHautMoi+$yBasMoi)/2]
$K create text $xMilieu $yMilieu \
-anchor center \
-font {Courier 2} \
-text [TexteOMO $Nom "Court"] \
-tags [list "Arc" "$Nom/$Voisin"]
$K bind "Arc" <Enter> "PiqueArc $K %x %y"
$K bind "Arc" <Leave> "PiqueArc $K %x %y Efface"
}
if {$PourGif && [info exists LesOrdresPourGif]} { return $LesOrdresPourGif }
}
proc OrthologueDansTBlastN {Nom Orga {OrgaEstUneBanque 0}} {
global RepertoireDuGenome
if {$OrgaEstUneBanque} {
set Banque $Orga
} else {
set Banque "genomes"
}
set DebutNom [Box $Nom debut]
set FinNom [Box $Nom fin]
set Fichier "$RepertoireDuGenome/tblastn$Banque/$Nom"
set ListeDesOrthologues [ChaqueProteineDuTBlastN $Fichier "AvecLaSeq"]
if {[llength $ListeDesOrthologues] == 0 } {
return "Mort-$Banque-nul"
}
set OrthoTBN 0
set nStars 0
set YavaitQuelquUn 0
foreach Homo $ListeDesOrthologues {
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 OrgaHomo [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 SeqSbjct [lindex $lHomo [incr i]]
set LongSbjct [expr abs($FinSbjct-$DebutSbjct)+1]
set DebutQuery [expr $DebutQRel+$DebutNom-1]
set FinQuery [expr $FinQRel+$DebutNom-1]
if {$Orga != $OrgaHomo} { continue }
set YavaitQuelquUn 1
set SeuilDeOrthoTBN 0.001
if {[expr $Expect > $SeuilDeOrthoTBN]} {
break
}
if {[llength [split $SeqSbjct "*"]] > 1} {
incr nStars
} else {
return "Orthologue TBlastN dans [Glossaire $Orga Court] a $Expect"
}
}
if { $nStars != 0 } {
foreach OrgaProche [LesOrganismesTresProches] {
if {$Orga == $OrgaProche && [regexp "oui confirme" [ExtraitInfo $Nom $OrgaProche]]} {
return "Orthologue TBlastN dans [Glossaire $Orga Court] a $Expect par decret"
}
}
return "Mort-$Orga-$nStars-*"
}
if { $YavaitQuelquUn } {return "Mort-$Orga-loin" }
return "Mort-$Orga-vide"
}
proc ChargeLesPositionsDesOrthologues {{Banque ""}} {
global RepertoireDuGenome
global LesPositionsDesOrthologues
global LongueurADNDesOrganismes
if {$Banque==""} { set Banque "genomes" }
JeMeSignale Patience
set LesPositionsDesOrthologues($Banque) "Sont charges"
set LesLignes [LesLignesDuFichier "$RepertoireDuGenome/fiches/ouatapetbn.$Banque"]
if {[regexp " <" [lindex $LesLignes 0]]} {
foreach Ligne $LesLignes {
scan $Ligne "%s" Nom
set Reste [StringSuivant "$Nom " dans $Ligne]
while {$Reste!=""} {
set BH [ValeurDeLaBalise "BlastHit" Reste "Rogner" ID]
if {1} {
regsub -all {[PNSCOXDQFQDSFS<>]} $BH "" BH
set Vide ""
scan $BH "%f %f %d %d %d %d %d %s" PN SC OX DQ FQ DS FS Vide
if {$Vide!=""} { FaireLire $BH }
} else {
ValeurDeLaBalise PN BH "NePasRogner" PN
ValeurDeLaBalise SC BH "NePasRogner" SC
ValeurDeLaBalise OX BH "NePasRogner" OX
ValeurDeLaBalise DQ BH "NePasRogner" DQ
ValeurDeLaBalise FQ BH "NePasRogner" FQ
ValeurDeLaBalise DS BH "NePasRogner" DS
ValeurDeLaBalise FS BH "NePasRogner" FS
}
set MaPos [expr ($DQ+$FQ)/2]
set TaPos [expr ($DS+$FS)/2]
if { ! [info exists DejaVu($OX)]} {
set DejaVu($OX) 1
lappend LesPositionsDesOrthologues("LaListeDesOrgas",$Banque) $OX
}
if { ! [info exists LongueurADNDesOrganismes($OX)]} {
set LongueurADNDesOrganismes($OX) -1
}
set LongueurADNDesOrganismes($OX) [Maxi [set LongueurADNDesOrganismes($OX)] $TaPos]
lappend LesPositionsDesOrthologues($Nom,$Banque,$OX) $TaPos
set LesPositionsDesOrthologues($Banque,$OX) "Sont charges"
}
}
} else {
foreach {LigneOrgas LignePos} $LesLignes {
set ListeOrgas [split [string trim $LigneOrgas] " "]
set Nom [lindex $ListeOrgas 0]
set ListeOrgas [lrange $ListeOrgas 1 end]
set ListePos [split [string trim $LignePos] " "]
if { $Nom != [lindex $ListePos 0] } { FaireLire "Ca merde en\n$LigneOrgas\n$LignePos" }
set ListePos [lrange $ListePos 1 end]
foreach Orga $ListeOrgas {MaPos TaPos} $ListePos {
if {$Orga==""} {
set Orga "iinc"
# FaireLire "$LigneOrgas\n ne contient pas d'orga correct !!!!"
}
if { ! [info exists DejaVu($Orga)]} {
set DejaVu($Orga) 1
lappend LesPositionsDesOrthologues("LaListeDesOrgas",$Banque) $Orga
}
if { ! [info exists LongueurADNDesOrganismes($Orga)]} {
set LongueurADNDesOrganismes($Orga) -1
}
set LongueurADNDesOrganismes($Orga) [Maxi [set LongueurADNDesOrganismes($Orga)] $TaPos]
lappend LesPositionsDesOrthologues($Nom,$Banque,$Orga) $TaPos
set LesPositionsDesOrthologues($Banque,$Orga) "Sont charges"
}
}
}
set LongueurADNDesOrganismes("SontCharges") 1
JeMeSignale FinPatience
}
proc PositionsDesOrthologues {Nom Banque {Orga ""}} {
global LesPositionsDesOrthologues
if {! [info exists LesPositionsDesOrthologues($Banque)]} {ChargeLesPositionsDesOrthologues $Banque}
if {$Nom=="LaListeDesOrgas"} {
if {[info exists LesPositionsDesOrthologues("LaListeDesOrgas",$Banque)]} {
return [set LesPositionsDesOrthologues("LaListeDesOrgas",$Banque)]
}
}
if {! [info exists LesPositionsDesOrthologues($Nom,$Banque,$Orga)]} {
return {}
} else {
return [set LesPositionsDesOrthologues($Nom,$Banque,$Orga)]
}
}
proc DotPlot {Banque {Orga ""} {DesProches ""} {PourGif ""} } {
global ListeDeBoites
global DotPlotDesProches
Gs "Canvas"
while {$Orga=="Ask"} {
set O [ChoixParmi [FamiliarTaxId LaListeMerci]]
if {$O!=""} { scan $O "%s %s %d" G E Orga ; break }
if {[OuiOuNon "Do I cancel ?"]} { return "" }
}
if {$PourGif!=""} {
set PourGif 1
set DesProches "Proches"
} else {
set PourGif 0
}
if {$DesProches == ""} {
set DotPlotDesProches [OuiOuNon "DotPlot des points proches uniquement ?"]
} elseif { $DesProches == "Proches"} {
set DotPlotDesProches 1
} else {
set DotPlotDesProches 0
}
if { ! [info exists ListeDeBoites]} { ChargeListeDeBoites }
if {$Banque == "paby"} {
return [DotPlotParalogues]
}
set MinX 99999999
set MaxX -99999999
set MinY 99999999
set MaxY -99999999
set NousEtEux {}
foreach Boite $ListeDeBoites {
set Nom [Box $Boite nom]
if { ! [YaPABdans $Nom]} { continue }
set Moi $Nom
set LeursPositions [PositionsDesOrthologues $Nom $Banque $Orga]
if {[llength $LeursPositions] < 1} { continue }
set PosMoi [Milieu $Moi]
set MinX [Mini $MinX $PosMoi]
set MaxX [Maxi $MaxX $PosMoi]
foreach PosLui $LeursPositions {
set MinY [Mini $MinY $PosLui]
set MaxY [Maxi $MaxY $PosLui]
lappend NousEtEux "$PosMoi.$PosLui $Moi $PosMoi $PosLui"
}
}
if {$NousEtEux=={}} {
FaireLire "Sorry, I didn't found any $Orga within all homologues"
return ""
}
if {$DotPlotDesProches} {
set NousEtEux [lsort -command CompareLesFloatsEnDebut $NousEtEux]
}
foreach Couple $NousEtEux {
scan $Couple "%f %s %d %d" pml Bibi PosBibi PosLui
lappend Nous $Bibi
lappend Vous $PosLui
lappend NosPos $PosBibi
lappend VosPos $PosLui
}
if {$PourGif} {
return [Plotte $Nous $Vous $NosPos $VosPos $MinX $MaxX $MinY $MaxY $Orga "PourGif"]
} else {
return [Plotte $Nous $Vous $NosPos $VosPos $MinX $MaxX $MinY $MaxY $Orga]
}
}
proc DotPlotParalogues {} {
global ListeDeBoites
if { ! [info exists ListeDeBoites]} { ChargeListeDeBoites }
set MinX 999999
set MaxX -999999
set MinY 999999
set MaxY -999999
foreach Boite $ListeDeBoites {
set Nom [Box $Boite nom]
if { ! [YaPABdans $Nom]} { continue }
set Moi $Nom
set Eux [ParaloguesDe $Nom]
if {[llength $Eux] < 1} { continue }
set PosMoi [Milieu $Moi]
set MinX [Mini $MinX $PosMoi]
set MaxX [Maxi $MaxX $PosMoi]
lappend Nous $Moi
lappend Vous $Moi
lappend NosPos $PosMoi
lappend VosPos $PosMoi
foreach Lui $Eux {
set PosLui [Milieu $Lui]
set MinY [Mini $MinY $PosLui]
set MaxY [Maxi $MaxY $PosLui]
lappend Nous $Moi
lappend Vous $Lui
lappend NosPos $PosMoi
lappend VosPos $PosLui
}
}
return [Plotte $Nous $Vous $NosPos $VosPos $MinX $MaxX $MinY $MaxY]
}
Index by: file name |
procedure name |
procedure call |
annotation
File generated 2022-04-05 at 12:55.