ó
šxTc           @   s4	  d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d a e	 e j
 ƒ a d „  Z d „  Z e d k r0	t d k rµ x e j
 D] Z e GHq£ Wn  d GHe d ƒ Z d	 Z d	 Z d	 Z d	 Z d	 Z d	 Z d	 Z d
 Z e Z d
 Z d
 Z d Z e d ƒ j ƒ  Z e d k sDe d k sDe d k r‚e  e d ƒ ƒ Z! e  e d ƒ ƒ Z" e  e d ƒ ƒ Z# d GHe d ƒ Z$ e$ d k r¦e d ƒ Z n  e d ƒ Z e	 e ƒ d k rÓe d ƒ Z n  e	 e ƒ d k rùd GHe d ƒ Z n e j j% d k rd Z n  e d ƒ Z e	 e ƒ d k rAe d ƒ Z n  e	 e ƒ d k rgd GHe d  ƒ Z n  e d! ƒ Z e d" ƒ Z n  e d k rÆd# GHe& e d$ ƒ ƒ j' ƒ  j( d% ƒ d k rÆe) Z qÆn  e d k söe d& k söe d k söe d k r+e d' ƒ Z e	 e ƒ d k r+d( GHe d) ƒ Z q+n  e d k sOe d k sOe d k rãe d* ƒ Z e	 e ƒ d k r|e d+ ƒ Z n  e	 e ƒ d k r¢d, GHe d- ƒ Z n  e d. ƒ Z* e d/ ƒ Z e	 e ƒ d k rãd0 GHe d1 ƒ Z qãn  e d& k se d k se d k r@e+ e d2 ƒ ƒ Z, e+ e d3 ƒ ƒ Z- e  e d4 ƒ ƒ Z. n  e d k spe d& k spe d k spe d k r‹d5 e e e e e f GHn  e d6 ƒ Z d g Z/ e j0 e e e e e e e e e e e e/ ƒ Z1 e d k rèe e1 _2 n  e d& k se d k se d k r!e. e1 _. e- e1 _- n  e d7 k rue d& k rue d8 ƒ Z3 e3 j' ƒ  j( d% ƒ d k rue d9 ƒ e1 _4 qun  e d k s¥e d& k s¥e d k s¥e d k rÛe d: ƒ Z3 e3 j' ƒ  j( d% ƒ d k rÛe) e1 _5 qÛn  e d k sÿe d k sÿe d k r5e d; ƒ Z3 e3 j' ƒ  j( d% ƒ d k r5e) e1 _6 q5n  yFd< e j7 e j8 e j ƒ  ƒ ƒ e1 _9 e d k sue d k r—e1 j: e! e" e# e  e* ƒ e ƒ n  e d& k r³e1 j; e, ƒ n  e d k ráe1 j< e! e" e# e, e  e* ƒ ƒ n  e d7 k sùe d= k r<d
 Z= e Z> e d7 k r e d> ƒ Z? n  e d= k rAe d? ƒ Z? e) Z> n  e d@ ƒ Z3 e3 j' ƒ  j( d% ƒ d k rwe dA ƒ Z= n  d
 d
 g g Z@ e dB ƒ Z3 e3 j' ƒ  j( d% ƒ d k r#e+ e dC ƒ ƒ ZA eA d k r#xR eB eA ƒ D]A ZC e dD eC d ƒ ZD e dE eC d ƒ ZE e@ jF eD eE g ƒ qØWq#n  e1 jG e? e= e> e@ ƒ n  e1 jH jI e jJ dF e j7 e j8 e j ƒ  ƒ ƒ dG e/ d ƒ Wn¡ eK k
 r	ZL e/ d c d 7<e1 jH jI e jM e& eL ƒ dH e jN ƒ  dF e j7 e j8 e j ƒ  ƒ ƒ dG e/ d ƒ e1 jH jO d jP ƒ  e1 jH jO d jP ƒ  n XeQ e/ d ƒ n  d S(I   so   
Run from command line to get help with input
phenix.python cctbx_sources\Develop\phaser\phaser\BLASTrunner.py
iÿÿÿÿNi   c         C   sB   t  d k r2 t t  k  r2 t j t } t d a n t |  ƒ } | S(   Ni   (   t   argct   argnt   syst   argvt	   raw_input(   t   varnamet   myvar(    (    s@   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/BLASTrunner.pyt   Inputarg   s
    c         C   s“   d } t  } t j j d k r' d } n  t j d | |  f d | d t j d t j ƒj ƒ  \ } } t | ƒ d k r‰ | j	 ƒ  d } n d	 } | S(
   Nt   whicht   win32t   wheres   %s %st   shellt   stdoutt   stderri    t    (
   t   Truet   osR   t   platformt
   subprocesst   Popent   PIPEt   communicatet   lent
   splitlines(   t   exefnamet   whichcmdt	   osdepboolt	   stdoutstrt	   stderrstrt   fullpathexe(    (    s@   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/BLASTrunner.pyt   GetFullPathExe   s    	't   __main__sï  You can either 

a) Do a BLAST homology search for a particular pdb id to set up folders and
   input files to be used in subsequent MR calculations.
b) Do MR calculations on an existing set of folders and input files.
c) Combine (a) and (b).
d) Gather results from folders with finished MR calculations.
e) Generate an empty database only containing the table and column layout.
f) Use an existing BLAST output to set up folders and input files to be used
   in subsequent MR calculations.
    s'   What do you want to do? (a,b,c,d,e,f): t   notusedR   s   Enter the target pdbid: t   at   ct   fs2   Enter maximum allowed value of sequence identity: s2   Enter minimum allowed value of sequence identity: s2   Enter permitted number of pdb ids to be returned: sK   Using ulysses and zeus for BLAST homology searches and your PC for MR runs.sP   Do you have passwordless authentication to ulysses and zeus through ssh? (Y/N): t   Ys   OK, so what is your password?: t   sshi    t   plinks4   Enter fully qualified file paths for the ssh client:s   ssh: R	   s   -ssht   scpt   pscps5   Enter fully qualified file paths for the scp program:s   scp: s   Enter path for the mtz files: s(   Enter your userid for ulysses and zeus: sM   Do you only want to collect the homolouges without doing subsequent RNP jobs?s   yes/no: t   yt   bs   phenix.phasers7   Enter fully qualified file path for the phaser program:s   phaser: t   clustalwt	   clustalw2s9   Enter fully qualified file path for the clustalw program:s
   clustalw: sx   Specify the smallest difference in sequence identities between different models from the BLAST search to be permitted?: t	   superposes>   Enter the fully qualified file path for the superpose program:s   superpose: s8   Enter the number of Phaser MR jobs to run concurrently: s<   Enter maximum number of solutions for each MR calculation : s:   Enter maximum duration of hours for each MR calculation : sC   Paths for ssh, scp, phaser, clustalw, superpose are:
%s
%s
%s
%s
%ss'   Enter a name tag for the calculations: t   ds=   Use a protocol other than default for sculpting models (y/n) s8   Which protocol should be used for sculpting the models? sa   Seed multicomponent calculations on components a,b,c with refined template solution of a,b (y/n) s=   Use intensities instead of amplitudes in the mtz file? (y/n) s   
Run started on t   es=   Enter the database file name that will hold all the results: sV   Enter name of the empty database file that will only contain table and column layout: sQ   Do you supply a list of filenames and label names for PDB codes to label? (Y/N): sy   Enter filenames with PDB codes of special PDBs and a corresponding name to label each MR model matching those PDB codes: sC   Do you have additional solution files with common prefixes? (Y/N): s
   How many? s3   Enter database column suffix for the %d. solution: s,   Enter filename prefix for the %d. solution: s   
Run finished on s    with return value of %d
s   
(R   t   __doc__t   BLASTnMRfuncR   t	   tracebackR   t   loggingR   t   timeR   R   R   R    R   R   t   __name__t   argt   answert   sshexet   scpexet   useridt	   mtzfoldert	   phaserexet   clustalwexet   superposeexet   passwdt   Falset   noRNPt   targetpdbidt	   calclabelt   Nonet	   winoptssht   uppert   floatt   maxseqidt   minseqidt   maxpdbst	   usepasswdR   t   strt   lowert   findR   t   myinct   intt   njobst   nmaxsolst	   fmaxhourst	   errorcodet   BLASTrunnert   myobjt   writeBLASTxmlt   st   sculptprotocolt   busecurrenttmplt   buseIntensitiest   asctimet	   localtimet   pretextt   BLASTnSetupMRrunst   RunMRautoFromlistFilet   BLASTnMRrunt   TaggedPDBfileliststrt   OnlyDBLayoutt   DBfnamet	   othersolst   Nt   ranget   it   suffixt   solnamet   appendt    CollateMRautoResultsFromlistFilet   loggert   logt   INFOt	   Exceptiont   mt   ERRORt
   format_exct   handlerst   closet   exit(    (    (    s@   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/BLASTrunner.pyt   <module>   s   		$	'0$$0	$	0$%""	7