proc LesFantomesEnFrameshift {} { foreach Nom [ListeDesPABs] { if { ! [Fantome $Nom]} { continue } if { ! [regexp "FS ok" [ExtraitInfo $Nom "EP:"]]} { continue } Informe $Nom } exit } proc BornesBonSens {} { foreach NomDebutFinOrient [LesLignesDuFichier "[RepertoireDuGenome]/fiches/bornesdespabs"] { ExtraireDe $NomDebutFinOrient N D F O if {$D>$F} { set W $D ; set D $F ; set F $W } lappend Sortie "$N $D $F $O" } SauveLesLignes $Sortie dans "[RepertoireDuGenome]/fiches/bornesdespabsOK" exit } proc PossibleFrameshift Nom { global PossibleFrameshift if {[info exists PossibleFrameshift($Nom)]} { return [set PossibleFrameshift($Nom)] } if {[info exists PossibleFrameshift("EstCharge")]} { return [set PossibleFrameshift("EstCharge")] } set PossibleFrameshift("EstCharge") "-1 -1" set FichierFrameshifts "[RepertoireDuGenome]/fiches/Frameshifts" foreach Ligne [LesLignesDuFichier $FichierFrameshifts] { scan $Ligne "%d %d" D F set Raisons "" if {[regexp "=" $Ligne]} { set Raisons [StringSuivant "=" dans $Ligne] regsub {=.*} $Ligne "" Ligne } foreach NomLu [lrange [LesMotsDeLaLigne [split $Ligne " "]] 2 end] { set Debut [Box $NomLu debut] set Fin [Box $NomLu fin] if {[Box $NomLu orient]=="F"} { set DN [expr $D-$Debut+1] set FN [expr $F-$Debut+1] } else { set DN [expr $Fin-$F+1] set FN [expr $Fin-$D+1] } set DP [expr ($DN-1)/3+1] set FP [expr $FN/3] set PossibleFrameshift($NomLu) "$D $F $DN $FN $DP $FP $Raisons" } } return [PossibleFrameshift $Nom] } proc LocaliseLesFrameshifts {{FichierFrameshifts ""}} { if {$FichierFrameshifts==""} { set FichierFrameshifts "[RepertoireDuGenome]/fiches/Frameshifts" } if {[regexp "All$" $FichierFrameshifts]} { set OnlyFS 0 } else {set OnlyFS 1} foreach Nom [ListeDesPABs] { if { $OnlyFS && ! [regexp -nocase "FS ok|FS Nt|FS Ct|Gap" [ExtraitInfo $Nom "EP"]]} { continue } set Raison [ExtraitInfo $Nom "EP"] regsub -all " " $Raison "_" Raison foreach Fichier [LesBlastXDesHitsMultiples $Nom] { if {[info exists DejaVu($Fichier)]} { continue } set DejaVu($Fichier) $Nom set NN [file tail $Fichier] set Offset [Box $Nom debut] foreach Ligne [LesLignesDuFichier $Fichier] { if { ! [regexp "nucleic sequence from" $Ligne]} { continue } set Moi [StringApres "nucleic sequence from " dans $Ligne] set Lui [StringApres "$Moi to " dans $Ligne] set Offset [Mini [Box $Moi debut] [Box $Lui debut]] break } set Loc "[LocaliseLeFrameshiftDuBlastX $Fichier] $NN" scan $Loc "%d %d" D F set Localisation "[expr $D+$Offset-1] [expr $F+$Offset-1]" set Resultat "$Localisation $NN $Raison" Espionne $Resultat lappend LesLocs $Resultat } } set Localisations {} set OldLoc "" set Noms "" lappend LesLocs "-1 -1 xxx" foreach Ligne $LesLocs { scan $Ligne "%d %d %s %s" D F Nom Raison if {$Nom=="xxx" || ($OldLoc!="" && "$D $F"!=$OldLoc)} { lappend Localisations "$OldLoc [join $LesNoms " "] = [join $LesRaisons "+"]" set LesNoms {} set LesRaisons {} } lappend LesNoms $Nom lappend LesRaisons $Raison set OldLoc "$D $F" } return [SauveLesLignes $Localisations dans $FichierFrameshifts] } proc LocaliseLeFrameshiftDuBlastX Fichier { global SeuilExpectPourBlastX ; set SeuilExpectPourBlastX 10.1234 set A -1 ; set B -1 foreach Ligne [ChaqueProteineDuBlastX $Fichier] { scan $Ligne "%s %d %d %s %s %f %f %d %d %d %d" NomLu N I Access Orga S E DQ FQ DS FS if {$I==1} { set LesPos {} } lappend LesPos $DQ lappend LesPos $FQ if {$I==1} { continue } set LesPos [lsort -integer $LesPos] set A [lindex $LesPos 1] set B [lindex $LesPos 2] break } return "[Mini $A $B] [Maxi $A $B]" } proc EtudeCodonStart {{CommenceIci ""}} { global PagePropre set Moi [FrappeQuUnCoup $CommenceIci "set"] foreach Nom [ListeDesPABs] { if {[FrappeQuUnCoup $Nom $Moi] } { continue } if {[set CS [CodonStart $Nom]]==""} { continue } set F [TestCodonStartEtDeletionDuMSF $Nom] MetIt $Nom "Ask" catch {unset PagePropre($F) ; after 10 Destroy $F ; FermeFenetre} if {[JArreteDeBosser $Moi]} { return "JArreteDeBosser" } } } proc RejectIt {Nom {Raison ""}} { if {$Raison==""} { set Raison "Ask" } if {$Raison=="Ask"} { return [Informe $Nom "Rejected: "] } if {[regexp "ParDecret" $Raison]} { return [InformeSansDemander $Nom "=Rejected: $Raison date [Date Nice]"] } return [Informe $Nom "Rejected: $Raison"] } proc MetIt {Nom {Raison ""}} { if {$Raison==""} { set Raison "Ask" } set MVL [string index [QueLaSequenceDuFichierTFA "[RepertoireDuGenome]/prottfa/$Nom"] 0] if {$Raison=="Ask"} { return [Informe $Nom "CSP: $MVL 1"] } if {[regexp "ParDecret" $Raison]} { return [InformeSansDemander $Nom "CSP: $MVL 1 $Raison date [Date Nice]"] } return [Informe $Nom "CSP: $MVL 1 $Raison"] } proc AfficheLesBlastXDesHitsMultiples Nom { foreach Fichier [LesBlastXDesHitsMultiples $Nom] { AfficheFichier $Fichier "AvecSegAlignement" } return } proc LesBlastXDesHitsMultiples Nom { global LesBlastXDesHitsMultiples if {[info exists LesBlastXDesHitsMultiples($Nom)]} { return [set LesBlastXDesHitsMultiples($Nom)] } if {[info exists LesBlastXDesHitsMultiples("EstCharge")]} { return {} } set LesBlastXDesHitsMultiples("EstCharge") 1 foreach Fichier [glob "[RepertoireDuGenome]/blastxmultiples/*"] { if { ! [regexp {MS[]0-9]+} $Fichier NomLu]} { continue } lappend LesBlastXDesHitsMultiples($NomLu) $Fichier } return [LesBlastXDesHitsMultiples $Nom] } proc RenommeLesBlastX {} { foreach Fichier [glob *] { if { ! [regexp {MS[]0-9]+} $Fichier Nom]} { continue } if {[file exists $Nom]} { continue } file rename $Fichier $Nom } exit } proc BlastXDesHitsMultiplesPourTous {} { foreach Nom [ListeDesPABs] { set LesBlastX [BlastXDesHitsMultiples $Nom] Espionne "$Nom $LesBlastX" } exit } proc BlastXDesHitsMultiples Nom { set MesHits [HitMultiple $Nom] if {$MesHits=={}} { return "" } set Moi $Nom set Eux {} if {[info exists DejaLui]} { unset DejaLui } foreach Hit $MesHits { scan $Hit "%s" Lui set Nous "$Moi$Lui" set FichierNous "[RepertoireDuGenome]/blastxmultiples/$Nous" if {[file exists $FichierNous]} { continue } if {[info exists DejaVu($Lui,$Moi)]} { continue } if {[info exists DejaLui($Lui)]} { continue } set DejaLui($Lui) 1 set DejaVu($Moi,$Lui) 1 set DMoi [Box $Moi debut] set FMoi [Box $Moi fin] set DLui [Box $Lui debut] set FLui [Box $Lui fin] set D [Mini $DMoi $DLui] set F [Maxi $FMoi $FLui] set ADN [BoutADN $D $F "F"] set TFA [SequenceFormatTFA $ADN "$Moi$Lui nucleic sequence from $Moi to $Lui"] set FichierTFA [Sauve $TFA dans "[TmpFile $Moi$Lui].tfa"] set LesCommuns {} foreach ReHit [HitMultiple $Nom] { scan $ReHit "%s %s" LuiLu Access if {$LuiLu!=$Lui} { continue } lappend LesCommuns "$Access $Access" } if {$LesCommuns=={}} { continue } set FichierBlast "[TmpFile $Moi$Lui].blastx" set Communs [join $LesCommuns "\n"] set BlastXDataBase "[RepertoireDeTravail]/$Moi$Lui" if {[file exists $BlastXDataBase]} { file delete $BlastXDataBase } set BlastXDataBase [CreeUneBanqueBlast $Communs $BlastXDataBase] set CommandeBlast "blastall \ -p blastx \ -i $FichierTFA \ -o $FichierBlast.encours \ -d $BlastXDataBase \ -v 50 \ -b 50 " if {[OuiOuNonMemo "Do You want to edit the Blast command ?" 0]} { set CommandeBlast [Entre $CommandeBlast] if {$CommandeBlast==""} { return "" } } if {[catch {eval exec $CommandeBlast} Message]} { Espionne $Message } if { ! [file exists "$FichierBlast.encours"]} { Espionne "No $FichierBlast" continue } file copy -force $FichierBlast.encours $FichierNous lappend Eux $Lui } return $Eux } proc TestFrappeQuUnCoup {} { Espionne [set Moi [FrappeQuUnCoup "AskWhereToBegin" "set"]] Espionne [FrappeQuUnCoup PGS015 $Moi] Espionne [FrappeQuUnCoup PGS111 $Moi] Espionne [FrappeQuUnCoup PGS018 $Moi] } proc FrappeQuUnCoup {Nom Qui {Liste ""}} { global FrappeQuUnCoup if {[info exists FrappeQuUnCoup($Qui,Indice)]} { set Indice [set FrappeQuUnCoup($Qui,Indice)] if {$Indice<0} { return 0 } set Liste [set FrappeQuUnCoup($Qui,Liste)] set IndiceDeNom [lsearch -exact $Liste $Nom] return [expr $IndiceDeNom < $Indice] } if {$Qui=="set"} { set Moi [NomDe "Frappeur"] if {$Nom=="AskWhereToBegin"} { if {[OuiOuNon "Do you want to begin with a given [PreFixe] ?"]} { if {$Liste==""} { set Liste [ListeDesPABs] } set Nom [ChoixParmi $Liste] } } if {$Nom==""} { set Indice -1 } else { if {$Liste==""} { set Liste [ListeDesPABs] } set FrappeQuUnCoup($Moi,Liste) $Liste set Indice [lsearch -exact $Liste $Nom] } set FrappeQuUnCoup($Moi,Indice) $Indice return $Moi } return 0 } proc CommenceIci CommenceIci { if {$CommenceIci=="AskWhereToBegin"} { if {[OuiOuNon "Do you want to begin with a given [Prefixe] ?"]} { set CommenceIci [Entre [PreFixe]] } } return $CommenceIci } proc HitMultiple Nom { global HitMultiple if {[info exists HitMultiple($Nom)]} { return [set HitMultiple($Nom)] } if {[info exists HitMultiple("EstCharge")]} { return {} } foreach Ligne [LesLignesDuFichier "[RepertoireDuGenome]/fiches/LesHitsMultiples"] { scan $Ligne "%s %s %s" NomLu Autre Hit lappend HitMultiple($NomLu) "$Autre $Hit" } set HitMultiple("EstCharge") 1 return [HitMultiple $Nom] } proc LesHitsDe Nom { set SeuilExpect 10. set MaxListe 10 set FichierBlast "[RepertoireDuGenome]/blastp/$Nom" if { ! [file exists $FichierBlast]} { return {} } set lAccess {} DecortiqueBlast $FichierBlast $SeuilExpect $MaxListe Query lBanqueId lAccess lDE lProfil lPN return $lAccess } proc LesHitsMultiples {} { set FichierDesHits "[RepertoireDuGenome]/fiches/LesHitsMultiples" set LesPABs [LesPABsDansLOrdre] set i 1 set LesCourants [lrange $LesPABs 0 4] foreach Nom $LesCourants { set LesHitsDe($Nom) [LesHitsDe $Nom] } foreach Suivant [lrange $LesPABs 5 end] { set Nom [lindex $LesCourants 2] foreach Autre $LesCourants { if {$Autre==$Nom} { continue } foreach MonHit [set LesHitsDe($Nom)] { foreach SonHit [set LesHitsDe($Autre)] { if { ! [string equal -nocase $MonHit $SonHit]} { continue } Espionne "$Nom $Autre $MonHit" lappend LesHitsMultiples($Nom) "$Autre $MonHit" AppendAuFichier $FichierDesHits "$Nom $Autre $MonHit" } } } set Premier [lindex $LesCourants 0] unset LesHitsDe($Premier) set LesCourants [lreplace $LesCourants 0 0] lappend LesCourants $Suivant set LesHitsDe($Suivant) [LesHitsDe $Suivant] } } proc LesZonesEnOverlapMultiple Nom { set Debut [Box $Nom debut] set Fin [Box $Nom fin] set Orient [Box $Nom orient] set Long [expr $Fin-$Debut+1] set NombreMinimumDeCopainsNecessaires 5 set LesZones [LesZonesEnOverlap $Nom] set LesZonesEtendues {} foreach Zone $LesZones { scan $Zone "%d %d %d %s" P D F Voisin if {[Fantome $Voisin]} { continue } if {[NombreDeCopainsDansBlast $Voisin]<$NombreMinimumDeCopainsNecessaires} { continue } incr D -15 incr F 15 lappend LesZonesEtendues "$P $D $F $Voisin" } set LesZonesEtendues [lsort -integer -index 1 $LesZonesEtendues] if {$LesZonesEtendues=={}} { return {} } set LesRecouvrements {} set LesZonesRestantes $LesZonesEtendues foreach ZonePremiere $LesZonesEtendues { set LesZonesRestantes [lrange $LesZonesRestantes 1 end] if {[info exists DejaVu($ZonePremiere)]} { continue } scan $ZonePremiere "%d %d %d %s" P D F Voisin set DMin $D set FMax $F foreach Zone $LesZonesRestantes { scan $Zone "%d %d %d %s" P D F Voisin if {$D>$FMax} { break } set DejaVu($Zone) 1 set FMax [Maxi $F $FMax] } set DMin [Maxi $DMin $Debut] set FMax [Mini $FMax $Fin] set PCent [expr (100*($FMax-$DMin+1))/$Long] lappend LesRecouvrements "$PCent $DMin $FMax" } return $LesRecouvrements } proc LesZonesEnOverlap {Nom {Quoi ""}} { if {$Quoi==""} { set Quoi "LesZonesTriees" } set Debut [Box $Nom debut] set Fin [Box $Nom fin] set Orient [Box $Nom orient] set Long [expr $Fin-$Debut+1] if {$Long<1} { return "" } set LesOverlaps [split [Overlap $Nom] "/"] set LesZones {} foreach Ovl $LesOverlaps { regexp "I am in|I contain|I begin in|I end in" $Ovl Type set Voisin [StringApres $Type dans $Ovl] if {[Fantome $Voisin]} { continue } set D [IntegerApres "from" dans $Ovl] set F [IntegerApres "to" dans $Ovl] set L [expr $F-$D+1] set P [expr (100*$L)/$Long] lappend LesZones "$P $D $F $Voisin" } if {$Quoi=="LesZones"} { return $LesZones } set LesZonesTriees [lsort -decreasing -integer -index 0 $LesZones] if {$Quoi=="LesZonesTriees"} { return $LesZonesTriees } FaireLire "ZonesEnOverlap wrong argument" return } proc VerifieLesOverlapsPlusGrandsQue {{LongMini 18}} { global ListeDeBoites global KanvaCourant if { ! [info exists ListeDeBoites] } { ChargeListeDeBoites } foreach Boite $ListeDeBoites { set Nom [Box $Boite nom] if {[Fantome $Nom]} { continue } foreach Ovl [split [Overlap $Nom] "/"] { if {[scan $Ovl "%d" Long] != 1} { continue } if {$Long < $LongMini} { continue } set Autre [StringApres "in" dans $Ovl] if {[Fantome $Autre]} { continue } if {[NombreDeCopainsDansBlast $Nom] >[NombreDeCopainsDansBlast $Autre]} { continue } if {[NombreDeCopainsDansBlast $Nom] > 5} { continue } if {[info exists KanvaCourant]} { RepereBox $Nom $KanvaCourant } else { Informe $Nom } } } } proc Fantome Nom { set Valeur [ExtraitInfo $Nom "Fantome"] if { $Valeur == "" } { return 0 } if {[regexp -nocase -- "oui" $Valeur]} { return 1 } else { return 0 } } proc FantomisePourTous {{Ordre ""} {CommenceIci ""}} { set Moi [FrappeQuUnCoup $CommenceIci "set"] if {$Ordre==""} { set LesChoix [list \ "Ask" "" "Ask for each" \ "AloneIsEnough" "" "All orf without ortholog become Ghost is ENOUGH" \ "AloneAndOverlapedByBetter" "" "All orf without ortholog become Ghost if OVERLAPED by better orf" \ "AloneAndOverlapedBySetOfORFs" "" "All orf without ortholog become Ghost if OVERLAPED by a set of better orfs"] set Ordre [ChoixParmiJoliDansListe $LesChoix] } foreach Nom [ListeDesPABs] { if {[FrappeQuUnCoup $Nom $Moi] } { continue } if {[Fantome $Nom]} { continue } set Status [Fantomise $Nom $Ordre] if {[JArreteDeBosser $Moi]} { return "JArreteDeBosser" } if {$Status==""} { continue } Espionne "$Nom $Status" } } proc Fantomise {Nom {Ordre ""}} { global InformeSansDemander if {$Ordre=="Ask"} { Informe $Nom "Fantome: oui " return [Fantome $Nom] } if {[regexp "ParDecret" $Ordre]} { InformeSansDemander $Nom "Fantome: oui $Ordre date [Date Nice]" return $Ordre } set Raison "" set NCops [NombreDeCopainsDansBlast $Nom] if {$NCops>3} { return "" } if {$NCops==0} { append Raison " NoOrtholog" } if {[regexp "AloneIsEnough" $Ordre] && [regexp "NoOrtholog" $Raison]} { set Rapport "$Ordre $Raison" InformeSansDemander $Nom "Fantome: oui $Rapport" return $Rapport } set Ovl [Overlap $Nom] foreach Zone [LesZonesEnOverlap $Nom] { scan $Zone "%d %d %d %s" P D F Voisin if {[Fantome $Voisin]} { continue } if {$NCops >= [NombreDeCopainsDansBlast $Voisin]} { continue } if {$P > 98} { append Raison "FullOverlapedByBetterORF" break } if {$P > 90} { append Raison "OverlapedByBetterORF" break } } if {[regexp "Alone" $Ordre] && [regexp "NoOrtholog" $Raison] \ && [regexp "FullOverlapedByBetterORF" $Raison]} { set Rapport "$Ordre $Raison" PositionneEtInforme $Nom "" "SansInforme" Informe $Nom "Fantome: oui $Rapport" return $Rapport } if {[regexp "Alone" $Ordre] && [regexp "NoOrtholog" $Raison] \ && [regexp "OverlapedByBetterORF" $Raison]} { set Rapport "$Ordre $Raison" PositionneEtInforme $Nom "" "SansInforme" Informe $Nom "Fantome: oui $Rapport" return $Rapport } foreach Multiple [LesZonesEnOverlapMultiple $Nom] { scan $Multiple "%d %d %d" P D F if {$P > 75} { append Raison "OverlapedBySetOfORFs" break } } if {[regexp "AloneAndOverlapedBySetOfORFs" $Ordre] && [regexp "NoOrtholog" $Raison] \ && [regexp "OverlapedBySetOfORFs" $Raison]} { set Rapport "$Ordre $Raison" PositionneEtInforme $Nom "" "SansInforme" Informe $Nom "Fantome: oui $Rapport" return $Rapport } if {[regexp "LessThan3Orthologs" $Ordre] && \ [NombreDeCopainsDansBlast $Nom] < 3 && [regexp "FullOverlapedByBetterORF" $Raison]} { append Raison "LessThan3Orthologs" set Rapport "$Ordre $Raison" PositionneEtInforme $Nom "" "SansInforme" Informe $Nom "Fantome: oui $Rapport" return $Rapport } return "" } proc CreeStartCodonReport {} { global RepertoireDuGenome set FichierReport "$RepertoireDuGenome/fiches/startcodon_report" if {[file exists $FichierReport]} { set Copie [Garde $FichierReport] } set AppendToIt 0 while {[file exists $FichierReport]} { if {[OuiOuNon "$FichierReport already exists. \nDo I append to it ?"]} { set AppendToIt 1 break } if {[OuiOuNon "$FichierReport already exists. \nDo I replace it ?"]} { File delete -force $FichierReport continue } if {[OuiOuNon "Do I cancel CreeStartCodonReport"]} { return "" } } set Cluster [LesLignesDuFichier "$RepertoireDuGenome/fiches/startcodon_cluster"] set LesNoms {} foreach Nom [ListeDesPABs] { set LesSummary [StartCodonSummary $Nom] if {[regexp "NoSummary" $LesSummary]} { continue } foreach Ligne $LesSummary { scan $Ligne "%s %s %s %s" iGGT AA Pos NbAccord lappend LesNoms $Nom lappend Classement($Nom) [list $AA $Pos $NbAccord] set Commentaire($Nom) [StringSuivant "=" dans $Ligne] } } set LesNoms [lsort -unique $LesNoms] #Categories Raymond # 0 Met initial conserve # 1 Met initial a egalite # 2 Autre met # 3 Autre met a egalite if {$AppendToIt} { foreach Ligne [LesLignesDuFichier $FichierReport] { scan $Ligne "%s %s %s" Nom Pos PC if {[regexp {^(Pas|Probleme)} $Pos]} { continue } set DejaVu($Nom) 1 } } foreach Nom $LesNoms { if {[info exists DejaVu($Nom)]} { continue } set MetIni($Nom) [join [lrange [lindex [set Classement($Nom)] 0] 0 1] ""] set Classement($Nom) [lsort -integer -decreasing -index 2 [set Classement($Nom)]] set liste [set Classement($Nom)] if {[llength $liste]<=1 && [lindex [lindex $liste 0] 1]==1} { set CatRay($Nom) 0 } else { set Premier [lindex $liste 0] set Second [lindex $liste 1] if {[lindex $Premier 1]==1} { if {[lindex $Premier 2]==[lindex $Second 2]} { set CatRay($Nom) 1 } else { set CatRay($Nom) 0 } } else { if {[lindex $Premier 2]==[lindex $Second 2]} { set CatRay($Nom) 3 } else { set CatRay($Nom) 2 } } } } #TRAITEMENT DES RESULTATS CLUSTERING set lesNomsCl [list] foreach Ligne $Cluster { if { ! [regexp -nocase {[a-z]} $Ligne]} continue while {[regexp " " $Ligne]} { regsub -all " " $Ligne " " Ligne } set liste [split $Ligne " "] set Nom [lindex $liste 0] set Decal [lindex $liste 1] set Percent [lindex $liste 2] lappend LesNomsCl $Nom if {[info exists Classement($Nom)]} { set MetRaymond [join [lrange [lindex [set Classement($Nom)] 0] 0 1] ""] } else { set MetRaymond "X1" } if {[regexp "Pas" $Ligne] || ! [info exists CatRay($Nom)]} { set Bilan($Nom) "white No_Value" set StartCodonProposal($Nom) "None" } else { if {[regexp "Probleme" $Ligne]} { set Bilan($Nom) "grey Problem" set StartCodonProposal($Nom) "None" } else { if {$Decal != 0 || $Percent>50} { set Bilan($Nom) "green Validated_Start_Codon" set StartCodonProposal($Nom) [set MetIni($Nom)] } else { if {$Decal < -3} { set Deb [Box $Nom debut] set Fin [Box $Nom fin] set Orient [Box $Nom orient] scan [BornesDuGeneEtendu $Nom] "%s %s %s %s" x DebEtend FinEtend OrientEtend if {$Deb==$DebEtend && $Fin==$FinEtend} { set Bilan($Nom) "green Validated_Start_Codon" set StartCodonProposal($Nom) [set MetIni($Nom)] } else { if {$Deb!=$DebEtend} { set Diff [expr $Deb-$DebEtend] } else { set Diff [expr $FinEtend-$Fin] } set NucEtendu [BoutADN $DebEtend $FinEtend $OrientEtend] set NewMet [AAduCodon [string range $NucEtendu 0 2]] set NewPos [expr $Diff/3] if {$NewPos>2} { set Bilan($Nom) "blue Truncated_Gene" set StartCodonProposal($Nom) "${NewMet}-$NewPos" } else { set Bilan($Nom) "green Validated_Start_Codon" set StartCodonProposal($Nom) [set MetIni($Nom)] } } } else { set Cat [set CatRay($Nom)] if {!$Cat} { set Bilan($Nom) "green Validated_Start_Codon" set StartCodonProposal($Nom) $MetRaymond } else { set NewDecal [expr $Decal+1] set Classe [set Classement($Nom)] set Diff 999 set MeilleurIndex -1 set Index 0 foreach el $Classe { set Pos [lindex $el 1] if {[expr abs($NewDecal-$Pos)]<$Diff} { set Diff [expr abs($NewDecal-$Pos)] set MeilleurIndex $Index if {!$Diff} break } incr Index } set MeilleurOdile [lindex $Classe $MeilleurIndex] set MetOdile [join [lrange $MeilleurOdile 0 1] ""] if {$Cat==2} { if {$Decal<0} { set Bilan($Nom) "orange Doubtful_Start_Codon" if {$MetRaymond==$MetOdile} { set StartCodonProposal($Nom) $MetRaymond } else { set StartCodonProposal($Nom) $MetRaymond$MetOdile } } else { if {!$MeilleurIndex} { set Bilan($Nom) "red Wrong_Start_Codon" set StartCodonProposal($Nom) $MetRaymond } else { set Bilan($Nom) "orange Doubtful_Start_Codon" set StartCodonProposal($Nom) $MetRaymond$MetOdile } } } else { if {[lindex $MeilleurOdile 1]==1} { set Bilan($Nom) "green Validated_Start_Codon" set StartCodonProposal($Nom) $MetOdile } else { set Bilan($Nom) "orange Doubtful_Start_Codon" set StartCodonProposal($Nom) $MetOdile set Effectif [lindex [lindex $Classe 0] 2] foreach el $Classe { if {[lindex $el 2]!=$Effectif} break if {[lindex $MeilleurOdile 1]== [lindex $el 1]} continue set StartCodonProposal($Nom) "[set StartCodonProposal($Nom)][join [lrange $el 0 1] ""]" } } } } } } } } if { ! [info exists Classement($Nom)]} { set Classement($Nom) " " } set Report "$Nom [set Bilan($Nom)] [set StartCodonProposal($Nom)] $Decal [set Classement($Nom)]" Espionne $Report AppendAuFichier $FichierReport $Report } return $FichierReport } proc StartCodonClusterPourTous {{BorneSup 250}} { global RepertoireDuGenome set Affiche 0 set FichierStartCodonCluster "$RepertoireDuGenome/fiches/startcodon_cluster" if {[file exists $FichierStartCodonCluster]} { set Copie [Garde $FichierStartCodonCluster] } set LeNouveau {} while {[file exists $FichierStartCodonCluster]} { if {[OuiOuNon "$FichierStartCodonCluster already exists.\nDo I append to it ?"]} { foreach Ligne [LesLignesDuFichier $FichierStartCodonCluster] { scan $Ligne "%s" NomLu if {[regexp -nocase "Pas de fichier msf" $Ligne]} { continue } if {[regexp -nocase "Pas de groupe secator" $Ligne]} { continue } Espionne "Je garde $Ligne" lappend LeNouveau $Ligne set DejaVu($NomLu) 1 } SauveLesLignes $LeNouveau dans $FichierStartCodonCluster break } if {[OuiOuNon "$FichierStartCodonCluster already exists.\nDo I replace it ?" 0]} { File delete -force $FichierStartCodonCluster break } if {[OuiOuNon "$FichierStartCodonCluster already exists.\n\ Do I cancel StartCodonClusterPourTous ?"]} { return "" } } foreach Nom [ListeDesPABs] { if {[info exists DejaVu($Nom)]} { continue } set Rapport [StartCodonCluster $Nom] Espionne $Rapport AppendAuFichier $FichierStartCodonCluster $Rapport } return $FichierStartCodonCluster } proc CreeLesPABsAbInitio {} { global RepertoireDuGenome global ADN TDN RAC global PrefixeDesORFs global LongueurMiniDesORFs if { ! [info exists ADN]} { ChargeADNetTDNetRAC } set LongADN [string length $ADN] foreach DebutFrame {1 2 3} { set Orient "F" set DebutPotentiel $DebutFrame while {$DebutPotentiel < $LongADN} { set TrouveStart 0 for {set i $DebutPotentiel} {$i < [expr $LongADN-3]} {} { set Codon [string range $ADN $i [expr $i+2]] if {[CodonStartPossible $Codon]} { set Debut $i set TrouveStart 1 break } incr i 3 } if { ! $TrouveStart} { break } Wup "On a trouve un Met" set TrouveStop 0 for {set i [expr $Debut+3]} {$i < [expr $LongADN-3]} {} { set Codon [string range $ADN $i [expr $i+2]] if {[CodonStopPossible $Codon]} { set Fin [expr $i-1] set TrouveStop 1 break } incr i 3 } if { ! $TrouveStop} { set Fin [expr $i-1] } if { [expr $Fin - $Debut] >= $LongueurMiniDesORFs } { lappend ListeDesBornes($Orient) "ORF $Debut $Fin $Orient" } set DebutPotentiel [expr $Fin+1] } } foreach DebutFrame {1 2 3} { set Orient "R" set DebutPotentiel $DebutFrame while {$DebutPotentiel < $LongADN} { set TrouveStart 0 for {set i $DebutPotentiel} {$i < [expr $LongADN-3]} {} { set Codon [string range $RAC $i [expr $i+2]] if {[regexp "ATG|TTG|GTG" $Codon]} { set Debut $i set TrouveStart 1 break } incr i 3 } if { ! $TrouveStart} { break } Wup "On a trouve un Met" set TrouveStop 0 for {set i [expr $Debut+3]} {$i < [expr $LongADN-3]} {} { set Codon [string range $RAC $i [expr $i+2]] if {[CodonStopPossible $Codon]} { set Fin [expr $i-1] set TrouveStop 1 break } incr i 3 } if { ! $TrouveStop} { set Fin [expr $i-1] } if { [expr $Fin - $Debut] >= $LongueurMiniDesORFs } { lappend ListeDesBornes($Orient) "ORF [expr $LongADN-$Fin] [expr $LongADN-$Debut] $Orient" } set DebutPotentiel [expr $Fin+1] } } set ListeTriee(F) [lsort -increasing -command CompareLesMilieux $ListeDesBornes(F)] set ListeTriee(R) [lsort -decreasing -command CompareLesMilieux $ListeDesBornes(R)] set Numero 0 foreach Ligne [concat $ListeTriee(F) $ListeTriee(R)] { scan $Ligne "%s %d %d %s" ORF Debut Fin Orient set Nom [format "%s%4.4d" $PrefixeDesORFs [incr Numero]] lappend ListeBornesDesPABs "$Nom $Debut $Fin $Orient" } set FichierBornesDesPABs "$RepertoireDuGenome/fiches/bornesdespabs" if {[file exists $FichierBornesDesPABs]} { if {[OuiOuNon "$FichierBornesDesPABs existe deja. Je stoppe tout ?"]} { exit } } Espionne [SauveLesLignes $ListeBornesDesPABs dans $FichierBornesDesPABs] return 1 } proc Glimmer3 {{NomNumeroDuDernier ""}} { global RepertoireDuGenome global FichierSequenceADN # set Codons "_" # if { [CodonStartPossible "ATG"] } { append Codons "M" } # if { [CodonStartPossible "GTG"] } { append Codons "V" } # if { [CodonStartPossible "TTG"] } { append Codons "L" } # if {![CodonStopPossible "TGA"] } { append Codons "_TGA" } # # if {$Codons=="_"} { set Codons "" } set Result "$RepertoireDuGenome/glimmer3/result" if { ! [file exists "$Result.coord"] || \ [OuiOuNon "$Result.coord already exists.\n Do I recalculate it ? "]} { set CommandeGlimmer "/home/perrodou/glimmer3.01/scripts/g3-iterated.csh $FichierSequenceADN $Result" while { ! [OuiOuNon "I will run \n$CommandeGlimmer\nOK ?"]} { if {[OuiOuNon "Do I abort Glimmer3 ?"]} { return "" } if {[OuiOuNon "Do I exit ?"]} { exit } set CommandeGlimmer [Entre $CommandeGlimmer] } if {$CommandeGlimmer!=""} { set RepGlimmer "$RepertoireDuGenome/glimmer3" if { ! [file exists $RepGlimmer]} { file mkdir $RepGlimmer } NousAllonsAuBoulot $RepGlimmer if {[catch {eval exec $CommandeGlimmer} Message]} { if { ! [OuiOuNon "Glimmer3 sent me following message\n$Message\n\ \nCan I scan its output ?"]} { OnRevientDuBoulot return "" } } OnRevientDuBoulot } } if {[regexp "GLIMMER" $NomNumeroDuDernier]} { SauveLesLignes [LesBornesDeGlimmer $NomNumeroDuDernier] dans "$RepertoireDuGenome/fiches/bornesdesglimmers2" } return 1 } proc Glimmer2 {{NomNumeroDuDernier ""}} { global RepertoireDuGenome global FichierSequenceADN # set Codons "_" # if { [CodonStartPossible "ATG"] } { append Codons "M" } # if { [CodonStartPossible "GTG"] } { append Codons "V" } # if { [CodonStartPossible "TTG"] } { append Codons "L" } # if {![CodonStopPossible "TGA"] } { append Codons "_TGA" } # # if {$Codons=="_"} { set Codons "" } set Result "$RepertoireDuGenome/glimmer2/result" if { ! [file exists "$Result.coord"] || \ [OuiOuNon "$Result.coord already exists.\n Do I recalculate it ? "]} { set CommandeGlimmer "/biolo/glimmer2.13/run-glimmer2 $FichierSequenceADN $Result" while { ! [OuiOuNon "I will run \n$CommandeGlimmer\nOK ?"]} { if {[OuiOuNon "Do I abort Glimmer2 ?"]} { return "" } if {[OuiOuNon "Do I exit ?"]} { exit } set CommandeGlimmer [Entre $CommandeGlimmer] } if {$CommandeGlimmer!=""} { set RepGlimmer "$RepertoireDuGenome/glimmer2" if { ! [file exists $RepGlimmer]} { file mkdir $RepGlimmer } NousAllonsAuBoulot $RepGlimmer if {[catch {eval exec $CommandeGlimmer} Message]} { if { ! [OuiOuNon "Glimmer2 sent me following message\n$Message\n\ \nCan I scan its output ?"]} { OnRevientDuBoulot return "" } } OnRevientDuBoulot } } if {[regexp "GLIMMER" $NomNumeroDuDernier]} { SauveLesLignes [LesBornesDeGlimmer $NomNumeroDuDernier] dans "$RepertoireDuGenome/fiches/bornesdesglimmers2" } return 1 } proc Glimmer {{NomNumeroDuDernier ""}} { global RepertoireDuGenome global FichierSequenceADN set Codons "_" if { [CodonStartPossible "ATG"] } { append Codons "M" } if { [CodonStartPossible "GTG"] } { append Codons "V" } if { [CodonStartPossible "TTG"] } { append Codons "L" } if {![CodonStopPossible "TGA"] } { append Codons "_TGA" } if {$Codons=="_"} { set Codons "" } set Result "$RepertoireDuGenome/glimmer/result" if { ! [file exists "$Result.coord"] || \ [OuiOuNon "$Result.coord already exists.\n Do I recalculate it ? "]} { set CommandeGlimmer "run-glimmer$Codons $FichierSequenceADN $Result" while { ! [OuiOuNon "I will run \n$CommandeGlimmer\nOK ?"]} { if {[OuiOuNon "Do I abort Glimmer ?"]} { return "" } if {[OuiOuNon "Do I exit ?"]} { exit } set CommandeGlimmer [Entre $CommandeGlimmer] } if {$CommandeGlimmer!=""} { set RepGlimmer "$RepertoireDuGenome/glimmer" if { ! [file exists $RepGlimmer]} { file mkdir $RepGlimmer } NousAllonsAuBoulot $RepGlimmer if {[catch {eval exec $CommandeGlimmer} Message]} { if { ! [OuiOuNon "Glimmer sent me following message\n$Message\n\ \nCan I scan its output ?"]} { OnRevientDuBoulot return "" } } OnRevientDuBoulot } } if {[regexp "GLIMMER" $NomNumeroDuDernier]} { SauveLesLignes [LesBornesDeGlimmer $NomNumeroDuDernier] dans "$RepertoireDuGenome/fiches/bornesdesglimmers" } return 1 } proc Enterre Nom { set Valeur [ExtraitInfo $Nom "Enterre"] if { $Valeur == "" } { return 0 } if {[regexp -nocase -- "oui" $Valeur]} { return 1 } else { return 0 } } proc Decede Nom { Wup "Cette notion n'existe plus" return 0 if {0 && [regexp "TROU" $Nom] \ && [NombreDeCopainsDansBlast $Nom] < 1} { return 1 } set Valeur [ExtraitInfo $Nom "Decede"] if { $Valeur == "" } { return 0 } if {[regexp -nocase -- "oui" $Valeur]} { return 1 } else { return 0 } } proc ItsAGene Nom { set Valeur [ExtraitInfo $Nom "CNS-Glimmer-says"] if { $Valeur == "" } { return -1 } if {[regexp "it's a gene" $Valeur]} { return 1 } if {[regexp "it's not a gene" $Valeur]} { return 0 } return 2 } proc CalculeLesOverlapsDe Moi { global LesORFsEnOverlap if { ! [info exists LesORFsEnOverlap] } { CalculeLesORFsEnOverlap } if { ! [info exists LesORFsEnOverlap($Moi)] } { return "" } set Message "" foreach Lui [set LesORFsEnOverlap($Moi)] { set Ov [CalculeOverlapEntre $Moi et $Lui] lappend ListeDesMessages $Ov } return [join $ListeDesMessages "\n"] } proc CalculeOverlapEntre {Moi et Lui} { global ListeDeBoites set MonNom [Box $Moi nom] set MonDebut [Box $Moi debut] set MonFin [Box $Moi fin] set MonOrient [Box $Moi orient] set SonNom [Box $Lui nom] set SonDebut [Box $Lui debut] set SonFin [Box $Lui fin] set SonOrient [Box $Lui orient] global OrfsAvecStop if {[info exists OrfsAvecStop]} { if {$MonOrient=="F"} { incr MonFin 3 } if {$MonOrient=="R"} { incr MonDebut -3 } if {$SonOrient=="F"} { incr SonFin 3 } if {$SonOrient=="R"} { incr SonDebut -3 } } if { \ $MonDebut <= $SonDebut && \ $SonFin <= $MonFin } { set Long [expr $SonFin - $SonDebut + 1 ] set BeauLong [format "%4d" $Long] set Message "Overlap: $BeauLong bases. I contain $Lui from $SonDebut to $SonFin" return $Message } if { \ $SonDebut <= $MonDebut && \ $MonFin <= $SonFin } { set Long [expr $MonFin - $MonDebut + 1 ] set BeauLong [format "%4d" $Long] set Message "Overlap: $BeauLong bases. I am in $Lui from $MonDebut to $MonFin" return $Message } if { \ $SonDebut <= $MonDebut && \ $MonDebut <= $SonFin } { set Long [expr $SonFin - $MonDebut + 1 ] set BeauLong [format "%4d" $Long] if {$MonOrient == "R"} { set BegEnd "end in " } else { set BegEnd "begin in" } set Message "Overlap: $BeauLong bases. I $BegEnd $Lui from $MonDebut to $SonFin" return $Message } if { \ $SonDebut <= $MonFin && \ $MonFin <= $SonFin } { set Long [expr $MonFin - $SonDebut + 1 ] set BeauLong [format "%4d" $Long] if {$MonOrient == "F"} { set BegEnd "end in " } else { set BegEnd "begin in" } set Message "Overlap: $BeauLong bases. I $BegEnd $Lui from $SonDebut to $MonFin" return $Message } return "J'en ai rate un" } proc CalculeLesORFsEnOverlap {{AvecGLIMMER ""}} { global ListeDeBoites global LesORFsEnOverlap if { ! [info exists ListeDeBoites] } { ChargeListeDeBoites } if {[info exists LesORFsEnOverlap]} {unset LesORFsEnOverlap} foreach Boite $ListeDeBoites { set Nom [Box $Boite nom] if {$AvecGLIMMER=="" && [regexp "GLIMMER" $Nom]} { continue } if {[regexp "TROU" $Nom]} { continue } if {[Fantome $Nom]} { continue } set Debut [Box $Boite debut] set Fin [Box $Boite fin] set Orient [Box $Boite orient] global OrfsAvecStop if {[info exists OrfsAvecStop]} { if {$Orient=="F"} { incr Fin 3 } if {$Orient=="R"} { incr Debut -3 } } lappend AQuiEstCeDebut($Debut) $Nom lappend AQuiEstCetteFin($Fin) $Nom lappend LesDebuts $Debut lappend LesFins $Fin } set LesDebutsTries [ListeSansDoublon [lsort -integer $LesDebuts]] set LesFinsTries [ListeSansDoublon [lsort -integer $LesFins]] for {set i 0} {$i<[llength $LesDebutsTries]} {incr i} { set D [lindex $LesDebutsTries $i] foreach Moi [set AQuiEstCeDebut($D)] { foreach X [lrange $LesDebutsTries [expr $i-6] $i] { foreach Lui [set AQuiEstCeDebut($X)] { if { $Moi == $Lui } { continue } if {[Box $Moi debut]==[Box $Lui debut] \ && [Box $Moi fin]==[Box $Lui fin]\ && [Box $Moi orient]==[Box $Lui orient]} { continue } if { [Box $Lui fin] >= $D } { lappend LesORFsEnOverlap($Moi) $Lui lappend LesORFsEnOverlap($Lui) $Moi } } } } } foreach {Qui ValLesORFsEnOverlap} [array get LesORFsEnOverlap] { set LesORFsEnOverlap($Qui) [ListeSansDoublon $ValLesORFsEnOverlap] } EspionneL [array get LesORFsEnOverlap] Espionne fin FaireLire "fin calcul" return } proc DeletedStart Nom { set Valeur [ExtraitInfo $Nom "DeletedStart"] set N [IntegerApres "il manque au moins " dans $Valeur] if {$N!=""} { set Valeur $N } else { set Valeur 0 } if {$Valeur!=""} { return $Valeur } Wup "For compatibility with older version where framshift were in codonstart2" set Valeur [ExtraitInfo $Nom "CodonStart2"] set LesFS {} foreach Champ [split $Valeur "/"] { if { ! [regexp "erreur de sequence" $Champ]} { continue } lappend LesDS $Champ } return [join $LesDS "/"] } proc CodonStart Nom { set Valeur [ExtraitInfo $Nom "CodonStart"] Wup "To remove old frameshifts" set LesCS {} foreach Champ [split $Valeur "/"] { if {[regexp "erreur de sequence" $Champ]} { continue } lappend LesCS $Champ } return [join $LesCS "/"] Wup "Je ne veux plus les vieux CodonStart1" set Valeur2 [ExtraitInfo $Nom "CodonStart1"] if { $Valeur1 == "" && $Valeur2 == ""} { return "" } return "$Valeur1 / $Valeur2" } proc OverlapAtStart Nom { set Ov [Overlap $Nom] if {$Ov=="" || ! [regexp "I begin in " $Ov]} { return 0 } set LesOvs [split $Ov "/"] foreach Ov $LesOvs { if { ! [regexp "I begin in " $Ov]} { continue } set n [IntegerApres "Overlap:" dans $Ov] return $n } return 0 } proc Overlap Nom { global RepertoireDuGenome global MemoOverlap if {[info exists MemoOverlap($Nom)]} { return [set MemoOverlap($Nom)] } if {[info exists MemoOverlap("EstCharge")]} { return [ExtraitInfo $Nom "Overlap"] } set FichierOverlap "$RepertoireDuGenome/fiches/overlap" if {[file exists $FichierOverlap]} { foreach Ligne [LesLignesDuFichier $FichierOverlap] { scan $Ligne "%s" NomLu regsub "^$NomLu " $Ligne "" Ligne set MemoOverlap($NomLu) $Ligne } set MemoOverlap("EstCharge") 1 return [Overlap $Nom] } if { ! [OuiOuNon "Do I create the file of overlaps now ?" 0] } { set MemoOverlap("EstCharge") 1 return [ExtraitInfo $Nom "Overlap"] } foreach Boite [ListeDeBoites] { if {[regexp "GLIMMER" $Boite]} { continue } set Moi [Box $Boite nom] set Ov [CalculeLesOverlapsDe $Moi] regsub -all "\n" $Ov "/" Ov lappend Sortie "$Moi $Ov" } SauveLesLignes $Sortie dans $FichierOverlap return [Overlap $Nom] } proc FusionneLesBornes {} { global RepertoireDuGenome set Ancien "$RepertoireDuGenome/fiches/bornesdespabs" set Apport "$RepertoireDuGenome/fiches/bornesdespabsarajouter" foreach Ligne [LesLignesDuFichier $Apport] { scan $Ligne "%s" A set NouvelleLigne($A) $Ligne } foreach Ligne [LesLignesDuFichier $Ancien] { scan $Ligne "%s" A if {[info exists NouvelleLigne($A)]} { lappend Sortie [set NouvelleLigne($A)] } else { lappend Sortie $Ligne } } set SortieTriee [lsort -command CompareLesMilieux $Sortie] puts [join $SortieTriee "\n"] } proc CoupeAuBonMet {Nom PositionDuMet} { global RepertoireDuGenome set Debut [Box $Nom debut] set Fin [Box $Nom fin] set Orient [Box $Nom orient] if {$Orient == "F"} { set CoupeDebut $Debut set CoupeFin [expr $PositionDuMet-1] set NouveauDebut $PositionDuMet set NouvelleFin $Fin } else { set CoupeDebut [expr $PositionDuMet+1] set CoupeFin $Fin set NouveauDebut $Debut set NouvelleFin $PositionDuMet } set CoupeNuc [BoutADN $CoupeDebut $CoupeFin $Orient] set LongCoupeNuc [string length $CoupeNuc] set CoupePro [SeqNucToSeqPro $CoupeNuc] set LongCoupePro [string length $CoupePro] if { $LongCoupePro < 30 } { set CoupeTxt "Cut $LongCoupePro aas $CoupePro" } else { set CoupeTxt "Cut $LongCoupePro aas [string range $CoupePro 0 12] to\ [string range $CoupePro [expr $LongCoupePro-13] end]" } set SeqNuc [BoutADN $NouveauDebut $NouvelleFin $Orient] set SeqPro [SeqNucToSeqPro $SeqNuc] set NUC [SequenceFormatTFA $SeqNuc "$Nom $NouveauDebut $NouvelleFin $Orient Cut $LongCoupeNuc bases" "nucbrut"] if {[file exists "$RepertoireDuGenome/nuctfa/$Nom"]} { file copy -force "$RepertoireDuGenome/nuctfa/$Nom" "$RepertoireDuGenome/nuctfaorig/$Nom" } Espionne [Sauve $NUC dans "$RepertoireDuGenome/nuctfa/$Nom"] set TFA [SequenceFormatTFA $SeqPro "$Nom $NouveauDebut $NouvelleFin $Orient $CoupeTxt" "protbrut"] if {[file exists "$RepertoireDuGenome/prottfa/$Nom"]} { file copy -force "$RepertoireDuGenome/prottfa/$Nom" "$RepertoireDuGenome/prottfaorig/$Nom" } Espionne [Sauve $TFA dans "$RepertoireDuGenome/prottfa/$Nom"] return "$Nom $NouveauDebut $NouvelleFin $Orient" } proc CoupeAuBonMetPourTous {} { set NouvellesBornesDesPABs {} set NouvellesBornesDesPABsSeules {} foreach Nom [ListeDesPABs] { set Debut [Box $Nom debut] set Fin [Box $Nom fin] set Orient [Box $Nom orient] set NewCodonStart [ExtraitInfo $Nom "NewCodonStart"] if {[regexp {^ *[A-Z] [0-9]+} $NewCodonStart]} { scan $NewCodonStart "%s %d" AA Position if {$Position==1} { lappend NouvellesBornesDesPABs "$Nom $Debut $Fin $Orient" continue } set SeqPro [QueLaSequenceDuFichierTFA "[RepertoireDuGenome]/prottfa/$Nom"] set AncienneEntamme [string range $SeqPro 0 8] set AncienStart [string index $SeqPro 0] set AnciennePosition [expr -$Position + 1] set Texte "=CuttedCodonStart: $AncienStart $AnciennePosition from $AncienneEntamme" Espionne $Texte InformeSansDemander $Nom $Texte InformeParSuppressionDuChamp $Nom "CutCodonStart" } else { lappend NouvellesBornesDesPABs "$Nom $Debut $Fin $Orient" continue } if { $Orient == "F" } { set PositionAbs [expr $Debut + ($Position-1)*3] } else { set PositionAbs [expr $Fin - ($Position-1)*3] } set NomDebutFinOrient [CoupeAuBonMet $Nom $PositionAbs] ExtraireDe $NomDebutFinOrient N D F O Box $Nom debut $D Box $Nom fin $F Box $Nom orient $O lappend NouvellesBornesDesPABsSeules $NomDebutFinOrient lappend NouvellesBornesDesPABs $NomDebutFinOrient } set FichierBornes "[RepertoireDuGenome]/fiches/bornesdespabs" Garde $FichierBornes SauveLesLignes $NouvellesBornesDesPABs dans $FichierBornes ChargeListeDeBoites return $NouvellesBornesDesPABsSeules } proc EtendAuBonMetPourTous {} { Wup "Uses 'CSP: M -18 issu de Met MTVFS' which is created by CreeExtendCodonStart" Wup " creates the line 'ExtendedCodonStart: ...'" Wup " removes the line CSP: M -18 ..." set NouvellesBornesDesPABs {} set NouvellesBornesDesPABsSeules {} foreach Nom [ListeDesPABs] { set Debut [Box $Nom debut] set Fin [Box $Nom fin] set Orient [Box $Nom orient] set NewCodonStart [ExtraitInfo $Nom "CSP"] Espionne "$Nom $NewCodonStart" if {[regexp {^ *[A-Z] \-[0-9]+( issu de )?} $NewCodonStart Match]} { scan $NewCodonStart "%s %d" AA Position set SeqPro [QueLaSequenceDuFichierTFA "[RepertoireDuGenome]/prottfa/$Nom"] set AncienneEntamme [string range $SeqPro 0 8] set AncienStart [string index $SeqPro 0] set AnciennePosition [expr -$Position + 1] set Texte "=ExtendedCodonStart: $AncienStart $AnciennePosition from $AncienneEntamme" Espionne $Texte InformeSansDemander $Nom $Texte Informe $Nom $Texte set ChampASupprimer "CSP: $NewCodonStart" regsub -all {\-} $ChampASupprimer {\-} ChampASupprimer InformeParSuppressionDuChamp $Nom $ChampASupprimer } else { lappend NouvellesBornesDesPABs "$Nom $Debut $Fin $Orient" continue } if { $Orient == "F" } { set PositionAbs [expr $Debut + ($Position)*3] } else { set PositionAbs [expr $Fin - ($Position)*3] } set NomDebutFinOrient [EtendAuBonMet $Nom $PositionAbs] ExtraireDe $NomDebutFinOrient N D F O Box $Nom debut $D Box $Nom fin $F Box $Nom orient $O lappend NouvellesBornesDesPABsSeules $NomDebutFinOrient lappend NouvellesBornesDesPABs $NomDebutFinOrient } set FichierBornes "[RepertoireDuGenome]/fiches/bornesdespabs" Garde $FichierBornes SauveLesLignes $NouvellesBornesDesPABs dans $FichierBornes ChargeListeDeBoites return $NouvellesBornesDesPABsSeules } proc EtendAuBonMet {Nom PositionDuMet} { global RepertoireDuGenome set Debut [Box $Nom debut] set Fin [Box $Nom fin] set Orient [Box $Nom orient] if {$Orient == "F"} { set EtendDebut $PositionDuMet set EtendFin [expr $Debut-1] set NouveauDebut $PositionDuMet set NouvelleFin $Fin } else { set EtendDebut [expr $Fin+1] set EtendFin $PositionDuMet set NouveauDebut $Debut set NouvelleFin $PositionDuMet } set EtendNuc [BoutADN $EtendDebut $EtendFin $Orient] set LongEtendNuc [string length $EtendNuc] set EtendPro [SeqNucToSeqPro $EtendNuc] set LongEtendPro [string length $EtendPro] if { $LongEtendPro < 30 } { set EtendTxt "Extend $LongEtendPro aas $EtendPro" } else { set EtendTxt "Extend $LongEtendPro aas [string range $EtendPro 0 12] to\ [string range $EtendPro [expr $LongEtendPro-13] end]" } set SeqNuc [BoutADN $NouveauDebut $NouvelleFin $Orient] set SeqPro [SeqNucToSeqPro $SeqNuc] set NUC [SequenceFormatTFA $SeqNuc "$Nom $NouveauDebut $NouvelleFin $Orient Extend $LongEtendNuc bases" "nucbrut"] if {0} { Espionne "$Nom $NouveauDebut $NouvelleFin $Orient Extend $LongEtendNuc bases" } else { if {[file exists "$RepertoireDuGenome/nuctfa/$Nom"]} { file copy -force "$RepertoireDuGenome/nuctfa/$Nom" "$RepertoireDuGenome/nuctfaorig/$Nom" } Espionne [Sauve $NUC dans "$RepertoireDuGenome/nuctfa/$Nom"] set TFA [SequenceFormatTFA $SeqPro "$Nom $NouveauDebut $NouvelleFin $Orient $EtendTxt" "protbrut"] if {[file exists "$RepertoireDuGenome/prottfa/$Nom"]} { file copy -force "$RepertoireDuGenome/prottfa/$Nom" "$RepertoireDuGenome/prottfaorig/$Nom" } Espionne [Sauve $TFA dans "$RepertoireDuGenome/prottfa/$Nom"] } return "$Nom $NouveauDebut $NouvelleFin $Orient" } proc CreeExtendCodonStartPourTous {} { foreach Nom [ListeDesPABs] { if {[Fantome $Nom]} {continue} CreeExtendCodonStart $Nom } } proc CreeExtendCodonStart Nom { Wup "Uses 'CSP: Met de MTVFS' from the info file" Wup " creates 'CSP: M -18 issu de Met de MTVFS" Wup " then " set CSP [ExtraitInfo $Nom "CSP"] if {[regexp -nocase "^(Ok )?(Met|Leu|Val) de " $CSP Match]} { regexp -nocase {(Met|Leu|Val)} $Match S3 set S [UT $S3] set Seq [string toupper [StringApres $Match dans $CSP]] set D [Box $Nom debut] set F [Box $Nom fin] set O [Box $Nom orient] set ExtensionMaxAA 600 if {$O=="F"} { set DE [expr $D-$ExtensionMaxAA*3] set FE $F } else { set DE $D set FE [expr $F+$ExtensionMaxAA*3] } set SeqNucEtendue [BoutADN $DE $FE $O] set SeqProEtendue [SeqNucToSeqPro $SeqNucEtendue] set PosAAEtendue [string first $Seq $SeqProEtendue] if {$PosAAEtendue>0} { set PosAA [expr -($ExtensionMaxAA-$PosAAEtendue)] if {$S!=[string index $Seq 0]} { FaireLire "$Nom $S $PosAA issu de $CSP" } TextePourInforme "=CSP: $S $PosAA issu de $CSP" Informe $Nom $TextePourInforme Espionne $TextePourInforme return $TextePourInforme } else { set MessageErreur "I can't find the sequence $Seq upstream $Nom" if {[OuiOuNon "$MessageErreur\nDo you want to see the info file ?"]} { set OldInfo [ExtraitInfo $Nom] Informe $Nom if {$OldInfo!=[ExtraitInfo $Nom] \ && [OuiOuNon "Do I use this mofification ?"]} { return [CreeExtendCodonStart $Nom] } return $MessageErreur } } } } proc CreeChangeCodonStartPourTous {} { foreach Nom [ListeDesPABs] { if {[Fantome $Nom]} {continue} CreeChangeCodonStart $Nom } } proc CreeChangeCodonStart Nom { set CSP [ExtraitInfo $Nom "CSP"] if { ! [regexp {^[MVL]} $CSP AA]} { return "" } set PositionAA [IntegerApres $AA dans $CSP] if {$PositionAA==""} { return "" } if {$PositionAA==0} { set Message "$Nom 0 que faire pour $CSP" FaireLire $Message return "" } if {$PositionAA==1} { return "" } if {$PositionAA>0} { set SeqNuc [QueLaSequenceDuFichierTFA "[RepertoireDuGenome]/nuctfa/$Nom"] set SeqProOfNuc [SeqNucToSeqPro $SeqNuc] set SeqPro [QueLaSequenceDuFichierTFA "[RepertoireDuGenome]/prottfa/$Nom"] if { ! [string equal -nocase $SeqProOfNuc $SeqPro]} { FaireLire "The translated sequence doen't correspond to prottfa/$Nom" } set SeqEnPos [string range $SeqPro [expr $PositionAA-1] [expr $PositionAA+8]] if {[string index $SeqEnPos 0]!=$AA} { set Message "$AA doesn't begin $SeqEnPos please modify the info file for $Nom\n$CSP" FaireLire $Message Informe $Nom if {[OuiOuNon "Do I rerun the test ?"]} { return [CreeChangeCodonStart $Nom] } } set PositionD [expr ($PositionAA-1)*3] set PositionF [expr $PositionD+2] set Codon [string range $SeqNuc $PositionD $PositionF] if { ! [CodonStartPossible $Codon]} { set Message "for $Nom I'm sorry; $Codon is not a possible start codon\n$CSP\n$SeqEnPos" FaireLire $Message Espionne $Message } set OldPosRel [expr -$PositionAA + 1] set OldAA [string index $SeqPro 0] set TexteInfo "=CutCodonStart: The cutted start was $OldAA $OldPosRel from [string range $SeqPro 0 9] " InformeSansDemander $Nom $TexteInfo } else { Espionne "Je rallonge $Nom a $AA $PositionAA car $CSP" } } proc TousLesMetDuPoch {{Nom ""}} { global ListeDeBoites if { ! [info exists ListeDeBoites]} { ChargeListeDeBoites } if { $Nom != ""} { set ListeATester [lrange $ListeDeBoites [lsearch $ListeDeBoites $Nom] end] } else { set ListeATester $ListeDeBoites } foreach Boite $ListeATester { set Nom [Box $Boite nom] if { ! [YaPABdans $Nom]} { continue } set Entamme [LeMetDuPoch $Nom] while {$Entamme == "On recommence"} { set Entamme [LeMetDuPoch $Nom] } puts "$Nom $Entamme" } } proc LeMetDuPoch Nom { global QueLesMetOK set CS [CodonStart $Nom] if {[regexp -nocase "ok" $CS]} { regsub {GroupeSize [0-9]+ [0-9]+ } $CS "" CS scan $CS "%s %d %s" MVL Position OK if { ! [regexp -nocase {[MVL]} $MVL]} { FaireLire "$Nom $CS Ca merde ... pas de MVL" if {[OuiOuNon "On corrige Info ?"]} { Informe $Nom return "On recommence" } else { return "Abandon" } } if { ! [regexp -nocase "ok" $OK]} { FaireLire "$Nom $CS Ca merde ... pas de OK" if {[OuiOuNon "On corrige Info ?"]} { Informe $Nom return "On recommence" } else { return "Abandon" } } if {$Position == 1} { return "M 1 OK ... on ne change rien" } set Debut [Box $Nom debut] set Fin [Box $Nom fin] set Orient [Box $Nom orient] if { $Orient == "F" } { set DebutEntamme [expr $Debut+($Position-1)*3] set FinEntamme [expr $DebutEntamme+29] set Position $DebutEntamme } else { set FinEntamme [expr $Fin-($Position-1)*3] set DebutEntamme [expr $FinEntamme-29] set Position $FinEntamme } set Entamme [BoutADN $DebutEntamme $FinEntamme $Orient] if { ! [CodonStartPossible [string range $Entamme 0 2]]} { FaireLire "$Nom $Entamme ca merde a l'entamme" if {[OuiOuNon "On corrige Info ?"]} { Informe $Nom return "On recommence" } else { return "Abandon malgre OK" } } return "Coupe a $Entamme en $Position" } else { if {[Decede $Nom]} { return "Abandon car decede" } if {$QueLesMetOK || [Informe $Nom] == "" } { return "Abandon car non OK" } else { return "On recommence" } } } proc YaCodonStartEnPosition {Touche {sPAB ""} {NomOuADN ""}} { global YCSEP_sPAB YCSEP_NomOuADN if {$sPAB==""} { set sPAB $YCSEP_sPAB } if {$NomOuADN ==""} { set NomOuADN $YCSEP_NomOuADN } set YCSEP_sPAB $sPAB set YCSEP_NomOuADN $NomOuADN regsub -all {[^\.]} [string range $sPAB 0 $Touche] "" PointsAvant set nPoints [string length $PointsAvant] set iStart [expr $Touche-$nPoints] if {[EstUnPAB $NomOuADN]} { set Nom $NomOuADN set SeqADN [BoutADN [Box $Nom debut] [Box $Nom fin] [Box $Nom orient]] if {$SeqADN==""} { set FichierNucTfa [GscopeFile $Nom nuctfa] if {[FileAbsent $FichierNucTfa]} { FaireLire "I can't find the nucleic sequence for $Nom" return 0 } set SeqADN [QueLaSequenceDuFichierTFA [GscopeFile $Nom nuctfa]] Espionne $SeqADN } } else { set SeqADN $NomOuADN } set dCodon [expr $iStart*3] set fCodon [expr $dCodon+2] set Codon [string range $SeqADN $dCodon $fCodon] return [CodonStartPossible $Codon] } proc TestCodonStartEtDeletionDuMSFPourTous {{CommenceAvec ""}} { global NePlusFaireBlastX global NePlusFaireAligne3P global InformeSansDemander global RepertoireDuGenome set NePlusFaireBlastX 1 set NePlusFaireAligne3P 1 set InformeSansDemander 1 set EtudieMSFPourTous 1 set OnAttend 0 if {$CommenceAvec!=""} { set OnAttend 1 } foreach Nom [ListeDesPABs] { if {$OnAttend && $Nom!=$CommenceAvec} { continue } set OnAttend 0 TestCodonStartEtDeletionDuMSF $Nom "TestPourTous" } set InformeSansDemander 0 CreeStartCodonSummary "Replace" } proc TestCodonStartEtDeletionDuMSF {FichierMSF {QueFaire "AfficheToujours"} {Nom ""} {ADN ""}} { global RepertoireDuGenome global PositionUltimeDuCodonStart Wup "It works for stand alone FichierMSF ... then it needs Nom (name of Query) and ADN (its ADN sequence)" if { ! [info exists PositionUltimeDuCodonStart]} { set PositionUltimeDuCodonStart 400 } if {[YaPABenDebutDe $FichierMSF]} { set FichierMSF "$RepertoireDuGenome/msf/$FichierMSF" } if {[regexp {^TROU[0-9]+[A-F]$} $FichierMSF]} { set FichierMSF "$RepertoireDuGenome/trousclustalw/$FichierMSF" } if { ! [file exists $FichierMSF]} { return "Clustalw inexistant" } set PL [PremiereLigneDuFichier $FichierMSF] if {[regexp "Clustalw inutile" $PL] || [regexp "NoSequence" $PL]} { return "Clustalw inutile" } if {$ADN==""} { set Nom [file tail $FichierMSF] set NomOuADN $Nom set Calculate "" } else { set Nom $Nom set NomOuADN [string toupper $ADN] set Calculate "ToCalculate" } set NombreDeSequences [DecortiqueUnMSF $FichierMSF LesSequencesDansLOrdre Sequences] Espionne "$FichierMSF $NombreDeSequences" if {$NombreDeSequences < 2} { return "No other sequence available" } if {[regexp "/Ms" [RepertoireDuGenome]] && [OuiOuNonMemo "Do I take all sequences in one cluster"]} { set LesSequencesDuGroupe $LesSequencesDansLOrdre } else { set LesSequencesDuGroupe [LesAccessDuGroupe $FichierMSF $Nom $LesSequencesDansLOrdre $Calculate] Espionne $LesSequencesDuGroupe } if {[llength $LesSequencesDuGroupe] > 1} { set LesSequencesDansLOrdre $LesSequencesDuGroupe } set LesRetenues {} foreach NomSeq $LesSequencesDansLOrdre { if {[EstUnAccessPDB $NomSeq]} { continue } lappend LesRetenues $NomSeq } if {[llength $LesRetenues] < 2} { return "Not enough sequence available" } set LesSequencesDansLOrdre $LesRetenues foreach NomSeq $LesSequencesDansLOrdre { Espionne "NS $NomSeq" set Seq [string toupper [set Sequences($NomSeq)]] if {[regexp "TROU" $Seq]} { set cDebut [string range [string trim $Seq "."] 0 0] set Debut($NomSeq) [string first $cDebut $Seq] } else { set iM [string first "M" "$Seq M"] set iL [string first "L" "$Seq L"] set iV [string first "V" "$Seq V"] set Debut($NomSeq) [Mini $iM [Mini $iL $iV]] } set cFin [string range [string trim $Seq "."] end end] set Fin($NomSeq) [string last $cFin $Seq] } foreach NomSeq $LesSequencesDansLOrdre { set BeauAccess [format "%-12s" $NomSeq] lappend LaPage "$BeauAccess [set Sequences($NomSeq)]" } set Page [join $LaPage "\n"] set Remarque "" set YaMieux 0 set LesCandidats {} if { ! [info exists Sequences($Nom)]} { return "" } set dPAB [set Debut($Nom)] set sPAB [string toupper [set Sequences($Nom)]] set TailleDuGroupe 0 foreach NomSeq $LesSequencesDansLOrdre { if {$NomSeq==$Nom} { continue } Espionne $NomSeq incr TailleDuGroupe set dAutre [set Debut($NomSeq)] if { $dPAB > $dAutre } { continue } set LesTouches {} foreach Ecart {-1 0 1} { if { $dPAB > [expr $dAutre+$Ecart] } { continue } if {[regexp -nocase {[MLV]} [string index $sPAB [expr $dAutre+$Ecart]] Start] } { lappend LesTouches [expr $dAutre+$Ecart] $Ecart } } if {$LesTouches=={}} { continue } foreach {Touche Ecart} $LesTouches { if { ! [YaCodonStartEnPosition $Touche $sPAB $NomOuADN]} { continue } if { $Ecart != 0 && [YaCodonStartEnPosition [expr $Touche-$Ecart]]} { continue } set Zone [string range $sPAB $dPAB $Touche] regsub -all -nocase {[^A-Z]} $Zone "" Zone set Position [expr [string length $Zone]] set Start [string index $Zone end] if {$Position>$PositionUltimeDuCodonStart} { break } lappend LesCandidats "$Position $Start $NomSeq" incr YaMieux 1 } } if { $LesCandidats != {} } { set LesCandidats [lsort -command CompareLesIntegersEnDebut $LesCandidats] set OldPosition -1 set Remarque "\n=CodonStart: GroupSize $TailleDuGroupe $NombreDeSequences" foreach PMS $LesCandidats { scan $PMS "%d %s %s" Position Start Nomseq if {$Position != $OldPosition} { append Remarque " $Start $Position $Nomseq" } else { append Remarque "/$Nomseq" } set OldPosition $Position } } set StartNom [string range $sPAB $dPAB $dPAB] set iNom [lsearch -exact $LesSequencesDansLOrdre $Nom] foreach NomSeq [lrange $LesSequencesDansLOrdre [expr $iNom-4] [expr $iNom+4]] { if {[string equal -nocase $NomSeq [Narcisse $Nom]]} { continue } lappend ListeDesDebuts [set Debut($NomSeq)] lappend ListeDesFins [set Fin($NomSeq)] } set ListeDesDebutsTries [lsort -decreasing -integer $ListeDesDebuts] set Prems [lindex $ListeDesDebutsTries 0] if {[llength $ListeDesDebutsTries]>1} { set Deuss [lindex $ListeDesDebutsTries 1] } else { set Deuss $Prems } set Derns [lindex $ListeDesDebutsTries end] set Manque [expr ($Prems-$Deuss)] set MaxManque [expr ($Prems-$Derns)] if { [expr $Manque > 10] && [set Debut($Nom)] == $Prems } { set DebutADN [Box $Nom debut] set FinADN [Box $Nom fin] set Orient [Box $Nom orient] if { $Orient == "F" } { set DebutBlastX [expr $DebutADN-($MaxManque*3)] set FinBlastX [expr $DebutADN-1] set EstLance [BlastXdeADN $Nom $DebutBlastX $FinBlastX] set EstLanceAligne3P [Aligne3PdeADN $Nom \ "Changer" $DebutBlastX $FinBlastX \ "Laisser" $DebutADN $FinADN \ $Orient] } else { set DebutBlastX [expr $FinADN+1] set FinBlastX [expr $FinADN+($MaxManque*3)] set EstLance [BlastXdeADN $Nom $DebutBlastX $FinBlastX] set EstLanceAligne3P [Aligne3PdeADN $Nom \ "Changer" $DebutBlastX $FinBlastX \ "Laisser" $DebutADN $FinADN \ $Orient] } incr YaMieux 10 append Remarque "\n=DeletedStart: je crois deviner une erreur de sequence, il manque au moins $Manque AA. BlastX $EstLance." } set ListeDesFinsTries [lsort -increasing -integer $ListeDesFins] set Prems [lindex $ListeDesFinsTries 0] if {[llength $ListeDesDebutsTries]>1} { set Deuss [lindex $ListeDesDebutsTries 1] } else { set Deuss $Prems } set Derns [lindex $ListeDesFinsTries end] set Manque [expr ($Deuss-$Prems)] set MaxManque [expr ($Derns-$Prems)] Warne "$Nom [set Fin($Nom)] $Prems $Deuss $Manque" if { [expr $Manque > 10] && [set Fin($Nom)] == $Prems } { set DebutADN [Box $Nom debut] set FinADN [Box $Nom fin] set Orient [Box $Nom orient] if { $Orient == "R" } { set DebutBlastX [expr $DebutADN-($MaxManque*3)] set FinBlastX [expr $DebutADN-1] set EstLance [BlastXdeADN $Nom $DebutBlastX $FinBlastX] set EstLanceAligne3P [Aligne3PdeADN $Nom \ "Laisser" $DebutADN $FinADN \ "Changer" $DebutBlastX $FinBlastX \ $Orient] } else { set DebutBlastX [expr $FinADN+1] set FinBlastX [expr $FinADN+($MaxManque*3)] set EstLance [BlastXdeADN $Nom $DebutBlastX $FinBlastX] set EstLanceAligne3P [Aligne3PdeADN $Nom \ "Laisser" $DebutADN $FinADN \ "Changer" $DebutBlastX $FinBlastX \ $Orient] } incr YaMieux 100 append Remarque "\n=DeletedStop: je crois deviner une erreur de sequence, il manque au moins $Manque AA. BlastX $EstLance." } if { $QueFaire == "RetourneRemarque"} { return $Remarque } Espionne "Remarque $YaMieux\n$Remarque" if { $QueFaire == "TestPourTous" && $YaMieux > 0 } { Informe $Nom $Remarque return } if { $QueFaire == "AfficheToujours" || $QueFaire == "AfficheSilFaut" && $YaMieux > 0 } { if { ! $YaMieux } { set Remarque "\n=CodonStart: GroupSize $TailleDuGroupe $NombreDeSequences $StartNom 1" } set Fenetre [AfficheVariable "$Page$Remarque" "AvecCorrInfoGrandeLargeur" $Nom ] if {[info exists LesCandidats]} { Illumine $Nom $Fenetre foreach Candidat $LesCandidats { scan $Candidat "%d %s %s" Position Start NomSeq Illumine $NomSeq $Fenetre } } return $Fenetre } } proc CreePABdesTrousCitesDans FOF { foreach Trou [LesLignesDuFichier $FOF] { CreePAB $Trou } } proc OldCreePAB Trou { global RepertoireDuGenome global ListeDeBoites global ListeDesTROUs global ADN TDN RAC if { ! [info exists ListeDeBoites]} { ChargeListeDeBoites } if { ! [info exists ListeDesTROUs]} { ChargeLesTROUs } if { ! [info exists ADN]} { ChargeADNetTDNetRAC } set LesMets [ExtraitInfo $Trou "CreePAB2"] if {[llength $LesMets] == 0} { return "" } scan [string range $Trou 4 7] "%d" n foreach sMet [split $LesMets "/"] { set Debut [Box $Trou debut] set Fin [Box $Trou fin] set Orient [Box $Trou orient] puts "$Trou $Debut $Fin $Orient" while {1} { set NomPAB [format "%s%4.4d" [PreFixe] $n] if {[Box $NomPAB nom] == ""} { break } if {[file exists "$RepertoireDuGenome/gcgs/$NomPAB"]} { if {[OuiOuNon "J'ecrase $NomPAB, si non je passe a +1000."]} { break } } incr n 1000 if { $n > 9999 } {incr n -2500} } regsub {[^A-Za-z\-]} $sMet "" Met if {[regexp {^\-} $Met]} { regsub {[^A-Za-z]} $sMet "" Met if {$Orient == "F"} { set D [expr $Debut-3] set F [expr $D + [string length $Met]*3 - 1] set AntiSens -3 } else { set F [expr $Fin+3] set D [expr $F - [string length $Met]*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 $Met devant $Trou." break } if {$Met == $SeqPro} { break } incr D $AntiSens incr F $AntiSens } if {$Orient == "F"} { set Debut $D } else { set Fin $F } set SeqNuc [BoutADN $Debut $Fin $Orient] set SeqPro [SeqNucToSeqPro $SeqNuc] set iMet 0 Wup "Ici on a donc etendu la proteine en devant." } else { regsub {[^A-Za-z]} $sMet "" Met if {$Orient == "F"} { incr Fin 99 } else { incr Debut -99 } set SeqNuc [BoutADN $Debut $Fin $Orient] set SeqPro [SeqNucToSeqPro $SeqNuc] set iMet [string first $Met $SeqPro] if {$iMet < 0} { FaireLire "Je ne trouve pas $Met dans $Trou" continue } set SeqPro [string range $SeqPro $iMet end] Wup "On a trouve le bon Met a l'interieur." } set iFin [expr [string first "*" $SeqPro]-1] if {$iFin < 0} { set iFin end } set SeqPro [string range $SeqPro 0 $iFin] if { $Orient == "F" } { set NouveauDebut [expr $Debut + (3*$iMet)] set NouvelleFin [expr $NouveauDebut + (3*[string length $SeqPro]) - 1] } else { set NouvelleFin [expr $Fin - (3*$iMet)] set NouveauDebut [expr $NouvelleFin - (3*[string length $SeqPro]) + 1] } set NUC [SequenceFormatTFA $SeqNuc "$NomPAB $NouveauDebut $NouvelleFin $Orient"] Espionne [Sauve $NUC dans "$RepertoireDuGenome/nuctfa/$NomPAB"] set TFA [SequenceFormatTFA $SeqPro "$NomPAB $NouveauDebut $NouvelleFin $Orient" "protbrut"] Espionne [Sauve $TFA dans "$RepertoireDuGenome/prottfa/$NomPAB"] Box $NomPAB nom $NomPAB Box $NomPAB debut $NouveauDebut Box $NomPAB fin $NouvelleFin Box $NomPAB orient $Orient if {$Orient == "F" } { puts "$NomPAB $NouveauDebut $NouvelleFin" } else { puts "$NomPAB $NouvelleFin $NouveauDebut" } } } proc CreePABPourTous {} { foreach Trou [ListeDesTROUs] { set PABCree [CreePAB $Trou] if {$PABCree!=""} { Espionne $PABCree } } } proc CreePAB Trou { Wup "uses something like 'CreePAB: de MTVRD a KRTFS' in the info file of TROU" Wup " it replaces 'CreePAB' with 'PABcree' to avoid to do it twice." if {[set TexteCreePAB [ExtraitInfo $Trou "CreePAB"]]==""} { return ""} set AAsDebut "" set AAsFin "" if { ! [regexp {^ *de ([A-Z]+) a ([A-Z]+)} $TexteCreePAB Matche AAsDebut AAsFin]} { return "" } set AAsDebut [string toupper $AAsDebut] set AAsFin [string toupper $AAsFin] set DTrou [Box $Trou debut] set FTrou [Box $Trou fin] if {$DTrou==""} { FaireLire "$Trou doesn't exist" ; return "" } set Extension 99 set BonneOrient "" foreach Orient {"F" "R"} { set BonneFrame "" foreach Frame {0 1 2} { set ADNCouvrant [BoutADN [expr $DTrou-$Extension+$Frame] [expr $FTrou+$Extension+$Frame] $Orient] set ADNCouvrant [string toupper $ADNCouvrant] set SeqPro [SeqNucToSeqPro $ADNCouvrant] if {[regexp -indices $AAsDebut $SeqPro IndicesDeb]} { set BonneFrame $Frame ; break } } if {$BonneFrame!=""} { set BonneOrient $Orient ; break } } if {$BonneFrame==""} { FaireLire "I cannot find $AAsDebut in $Trou" ; return "" } if { ! [regexp -indices $AAsFin $SeqPro IndicesFin]} { FaireLire "I cannot find $AAsFin in $Trou" ; return "" } Espionne "$SeqPro\n$AAsDebut $IndicesDeb $AAsFin $IndicesFin" scan $IndicesDeb "%d %d" DDeb FDeb scan $IndicesFin "%d %d" DFin FFin set DDebNuc [expr $DDeb*3] set FFinNuc [expr $FFin*3 + 2] if {$BonneOrient=="F"} { set VraiDeb [expr $DTrou - $Extension + $BonneFrame + $DDebNuc] set VraiFin [expr $DTrou - $Extension + $BonneFrame + $FFinNuc] } else { set VraiDeb [expr $FTrou + $Extension + $BonneFrame - $FFinNuc] set VraiFin [expr $FTrou + $Extension + $BonneFrame - $DDebNuc] } Espionne "$Trou $DTrou $FTrou $AAsDebut $AAsFin $VraiDeb $VraiFin $BonneOrient" set Bout [BoutADN [expr $VraiDeb-3] [expr $VraiFin+3] $BonneOrient] Espionne "$BonneOrient $BonneFrame [string range $Bout 0 9] ... [string range $Bout end-9 end]" Espionne "[SeqNucToSeqPro [string range $Bout 0 17]] ... [SeqNucToSeqPro [string range $Bout end-17 end]]" Espionne "$AAsDebut ... $AAsFin" Espionne "" regsub -all {[^0-9]} $Trou "" NumeroDuTrou set N 3 while 1 { set Numero "${N}$NumeroDuTrou" set PAB "[PreFixe]$Numero" if {[Box $PAB nom]==""} { break } if {[OuiOuNon "During CreePAB $Trou I wanted to create $PAB\n It already exists. Do I overwrite"]} { break } } set Nom $PAB set Debut $VraiDeb set Fin $VraiFin set Orient $BonneOrient set SeqNuc [BoutADN $Debut $Fin $Orient] set NucTFA [SequenceFormatTFA $SeqNuc "$Nom $Debut $Fin $Orient created from $Trou $AAsDebut $AAsFin"] Sauve $NucTFA dans "[RepertoireDuGenome]/nuctfa/$Nom" set SeqPro [SeqNucToSeqPro $SeqNuc] set ProTFA [SequenceFormatTFA $SeqPro "$Nom $Debut $Fin $Orient created from $Trou $AAsDebut $AAsFin"] Sauve $ProTFA dans "[RepertoireDuGenome]/prottfa/$Nom" set NouvellesBornes "$Nom $Debut $Fin $Orient" MiseAJourBornesDesPABs $NouvellesBornes "SansReCharge" set ToutTexteCreePAB "CreePAB: $TexteCreePAB" InformeParSuppressionDuChamp $Trou $ToutTexteCreePAB regsub "CreePAB" $ToutTexteCreePAB "PABCree" TextePABCree InformeSansDemander $Trou $TextePABCree Box $Nom nom $Nom Box $Nom debut $Debut Box $Nom fin $Fin Box $Nom orient $Orient InformeSansDemander $Nom "DuTrou: $Trou $AAsDebut $AAsFin $BonneOrient $BonneFrame" return $NouvellesBornes } proc CroqueMorts {} { global RepertoireDuGenome global ListeDeBoites global InformeSansDemander set InformeSansDemander 1 if { ! [info exists ListeDeBoites] } { ChargeListeDeBoites } foreach Boite $ListeDeBoites { set Nom [Box $Boite nom] if { [ItsAGene $Nom] } { continue } if { ! [Decede $Nom]} { continue } set Rapport "" foreach OrgaProche [LesOrganismesTresProches] { append Rapport "\t[OrthologueDansTBlastN $Nom $Banque]" } if { ! [regexp "Orthologue" $Rapport] } { set Message "Enterre: oui $Rapport" Informe $Nom $Message puts "$Nom $Message" } else { set Message "Vivant $Rapport" puts "$Nom $Message" } } } proc BlastNDesTrousPourTous {{Banques ""}} { set ListeDesTrous [ListeDesTROUs] BlastNPourTous $Banques $ListeDesTrous "" F 1 } proc TrousLaTotale {} { global RepertoireDuGenome set OldIntergenes "$RepertoireDuGenome/fiches/bornesdesintergenes" set Concorde [expr [file exists $OldIntergenes] && \ [OuiOuNon "Do I correct numbering according to existing intergenes ?"]] if {$Concorde} { # Espionne "Concorde" set KeepOldIntergenes "OldIntergenes.[pid]" File rename $OldIntergenes $KeepOldIntergenes } set FichierIntergenes [CreeLeFichierBornesDesIntergenes "Replace"] if {$Concorde} { set LesTous [ConcordanceNumerotationDesIntergenes $KeepOldIntergenes $FichierIntergenes] if { ! [OuiOuNon "OK to delete bad files in \nnuctfa nucembl trousblastx trouxsapns ?"]} { FaireLire "Please recover the correct names. I'll exit." exit } foreach Rep {nuctfa nucembl trousblastx trouxsapns} { foreach Fichier [glob -nocomplain "$RepertoireDuGenome/$Rep/TROU*"] { File delete -force $Fichier } } SauveLesLignes $LesTous dans $FichierIntergenes } CreeLesFichiersSequencesDesTrous "Replace" BlastXDesTROUsPourTous CreeLesFichiersApns "trouxs" CreeLeFichierNombreDeCopainsDansBlast NombreDeCopainsDansBlast "Reload" return [ListeDesTROUs] } proc CreeLesFichiersSequencesDesTrous {{AskToKeep "Ask"}} { global ADN TDN RAC global ListeDeBoites global ListeDesTROUs global ListeDesInterGenes global RepertoireDuGenome global IlFautRecreerLesFichiersSequencesDesTrous if {$AskToKeep=="Replace"} { set AskToKeep 0 } else { set AskToKeep 1 } set OnlyNuc 1 set FichierBornes "$RepertoireDuGenome/fiches/bornesdestrous" if {$AskToKeep && \ [file exists $FichierBornes] && \ [OuiOuNon "Do I keep existing $FichierBornes" 0]} { return $FichierBornes } if { ! [info exists ListeDesInterGenes]} { ChargeLesInterGenes } if { ! [info exists ADN]} { ChargeADNetTDNetRAC } set lADN [string length $ADN] set OD(A,1) 0 ; set OD(A,2) 1 ; set OD(A,0) 2 set OD(B,1) 2 ; set OD(B,2) 0 ; set OD(B,0) 1 set OD(C,1) 1 ; set OD(C,2) 2 ; set OD(C,0) 0 set OD(D,1) 0 ; set OD(D,2) 1 ; set OD(D,0) 2 set OD(E,1) 2 ; set OD(E,2) 0 ; set OD(E,0) 1 set OD(F,1) 1 ; set OD(F,2) 2 ; set OD(F,0) 0 set OF(A,1) 2 ; set OF(A,2) 1 ; set OF(A,0) 0 set OF(B,1) 0 ; set OF(B,2) 2 ; set OF(B,0) 1 set OF(C,1) 1 ; set OF(C,2) 0 ; set OF(C,0) 2 set OF(D,1) 2 ; set OF(D,2) 1 ; set OF(D,0) 0 set OF(E,1) 0 ; set OF(E,2) 2 ; set OF(E,0) 1 set OF(F,1) 1 ; set OF(F,2) 0 ; set OF(F,0) 2 foreach InterGene $ListeDesInterGenes { Espionne $InterGene set NomIG [Box $InterGene nom] set Debut [Box $InterGene debut] set Fin [Box $InterGene fin] set Orient [Box $InterGene orient] regsub -nocase "INTERGENE" $NomIG "" Numero set Nom "TROU${Numero}N" set Entete "$Nom $Debut $Fin F" Espionne $Entete set Sequence [SequenceFormatTFA [BoutADN $Debut $Fin "F"] $Entete] Sauve $Sequence dans "$RepertoireDuGenome/nuctfa/$Nom" lappend BornesDesTrous "$Nom $Debut $Fin $Orient" if {$OnlyNuc} { continue } Wup "Rest is obsolete ... it creates the 6 proteins (for each frame)" foreach Frame {A B C D E F} Orient {F F F R R R} { set DebutFrame [expr $Debut - [set OD($Frame,[expr $Debut%3])] ] set FinFrame [expr $Fin + [set OF($Frame,[expr $Fin%3])] ] if { $DebutFrame < 1 } { incr DebutFrame 3} if { $FinFrame > [expr $lADN-1] } { incr FinFrame -3} set Nom "TROU${Numero}$Frame" if { $IlFautRecreerLesFichiersSequencesDesTrous } { set Entete "$Nom $DebutFrame $FinFrame $Orient" set SeqNuc [BoutADN $DebutFrame $FinFrame $Orient] set SeqPro [SeqNucToSeqPro $SeqNuc] if {0 && [regexp {\*} $SeqPro]} { set LesBonsBouts [split $SeqPro "*"] set Long 0 foreach BonBout $LesBonsBouts { set Long [string length $BonBout] if { $Long > 10 } { break } } if { $Long <= 10 } { Warne "Je jette $SeqPro" continue } } set TFA [SequenceFormatTFA $SeqNuc "$Entete" "nucbrut"] Sauve $TFA dans "$RepertoireDuGenome/nuctfa/$Nom" } lappend BornesDesTrous "$Nom $DebutFrame $FinFrame" } } SauveLesLignes $BornesDesTrous dans $FichierBornes if {[info exists ListeDesTROUs]} { unset ListeDesTROUs } ChargeLesTROUs return $FichierBornes } proc CreeLeFichierBornesDesIntergenes {{AskToKeep "Ask"} {LongueurMinimaleDesIntergenes ""}} { global RepertoireDuGenome global ADN TDN RAC global ListeDeBoites global ListeDesTROUs if {$LongueurMinimaleDesIntergenes==""} { set LongueurMinimaleDesIntergenes 90 } if {$AskToKeep=="Replace"} { set AskToKeep 0 } else { set AskToKeep 1 } set Fichier "$RepertoireDuGenome/fiches/bornesdesintergenes" if {$AskToKeep && \ [file exists $Fichier] && \ [OuiOuNon "$Fichier already exists.\nDo I keep it?" 0]} { return $Fichier } set ListeDesTROUs "BidonPourFaireCroireQuIlExisteDeja" set LesBornesDesInterGenes {} if { ! [info exists ListeDeBoites] } { ChargeListeDeBoites } if { ! [info exists ADN]} { ChargeADNetTDNetRAC } foreach Boite [ListeDeBoites] { set Nom [Box $Boite nom] if {[regexp "GLIMMER" $Nom]} { continue } if { [Fantome $Nom] } { continue } # if { [Decede $Nom] } { continue } # if { [FiabiliteFonction $Nom] == 0 } { continue } # if { [FiabiliteFonction $Nom] == 1 } { continue } set Debut [Box $Boite debut] set Fin [Box $Boite fin] set Orient [Box $Boite orient] lappend LesDebuts [expr $Debut*2] lappend LesFins [expr $Fin*2+1] } set LeToutTrie [lsort -integer [concat $LesDebuts $LesFins]] set Niveau 0 set i 0 set FinCourante 1 foreach X $LeToutTrie { if {[expr $X%2 == 0]} { set DebutCourant [expr $X/2-1] incr Niveau 1 if { $Niveau == 1 } { # set Debut [expr ($FinCourante/3)*3+3] # set Fin [expr (($DebutCourant+1)/3)*3] set Debut [expr $FinCourante+1] set Fin [expr $DebutCourant-1] set Long [expr $Fin-$Debut+1] set Orient "F" set Frame [NomDeLaFrame TROU $Orient] if { $Long >= $LongueurMinimaleDesIntergenes } { set Num [format "%4.4d" [incr i]] set Nom "INTERGENE$Num" set Boite $Nom Box $Boite nom $Nom Box $Boite orient $Orient Box $Boite frame $Frame Box $Boite debut $Debut Box $Boite fin $Fin Box $Boite $Long Espionne "$Nom $Debut $Fin $Orient $Long" lappend LesBornesDesInterGenes "$Nom $Debut $Fin $Orient $Long" if {[info exists CompteParLong($Long)]} { incr CompteParLong($Long) } else { set CompteParLong($Long) 1 } } } } else { set FinCourante [expr $X/2+1] incr Niveau -1 } } foreach Long [lsort -decreasing -integer [array names CompteParLong]] { puts "$Long [set CompteParLong($Long)]" } return [SauveLesLignes $LesBornesDesInterGenes dans $Fichier] }