Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/allpy/rev/ea55c27e165f
Дата изменения: Unknown
Дата индексирования: Tue Oct 2 00:13:35 2012
Кодировка:
allpy: ea55c27e165f

allpy

changeset 144:ea55c27e165f

fixes. GC: input msf added
author boris <bnagaev@gmail.com>
date Sun, 24 Oct 2010 20:31:07 +0400
parents 004c2f6c45ac
children a5de1fb132a6
files geometrical_core/geometrical_core.py lib/project.py
diffstat 2 files changed, 21 insertions(+), 10 deletions(-) [+]
line diff
     1.1 --- a/geometrical_core/geometrical_core.py	Sun Oct 24 19:05:31 2010 +0400
     1.2 +++ b/geometrical_core/geometrical_core.py	Sun Oct 24 20:31:07 2010 +0400
     1.3 @@ -8,6 +8,7 @@
     1.4  Project = project.Project
     1.5  import argparse
     1.6  import os
     1.7 +from tempfile import mkstemp
     1.8  
     1.9  r = argparse.FileType('r')
    1.10  w = argparse.FileType('w')
    1.11 @@ -118,12 +119,18 @@
    1.12          print 'Error: provide both pdb and spt file or none of them'
    1.13          exit()
    1.14      
    1.15 -    #TODO: msf treating
    1.16 +    try:
    1.17 +        project = Project(args.i)
    1.18 +    except:
    1.19 +        args.i.close()
    1.20 +        tmp_file, tmp_filename = mkstemp()
    1.21 +        os.close(tmp_file) # this is file descriptor, not normal file object.
    1.22 +        
    1.23 +        os.system('seqret %(msf)s %(fasta)s' % \
    1.24 +        {'fasta': tmp_filename, 'msf': args.i.name})
    1.25 +        args.i = open(tmp_filename)
    1.26 +        project = Project(args.i)
    1.27      
    1.28 -    in_str = args.i.read()
    1.29 -    args.i.seek(0)
    1.30 -    
    1.31 -    project = Project(args.i)
    1.32      project.pdb_auto_add(args.c)
    1.33      block = Block(project)
    1.34      GCs = block.geometrical_cores(max_delta=args.d, timeout=args.t, 
    1.35 @@ -154,8 +161,11 @@
    1.36          args.f = args.g
    1.37      
    1.38      if args.f:
    1.39 +        args.i.seek(0)
    1.40          f = args.f
    1.41 -        f.write(in_str)
    1.42 +        f.write(args.i.read()) # write sequences
    1.43 +        
    1.44 +        # write GCs
    1.45          for i, GC in enumerate(GCs):
    1.46              f.write('\n\n')
    1.47              if i == 0:
     2.1 --- a/lib/project.py	Sun Oct 24 19:05:31 2010 +0400
     2.2 +++ b/lib/project.py	Sun Oct 24 20:31:07 2010 +0400
     2.3 @@ -109,7 +109,7 @@
     2.4  
     2.5          raw_sequences = file.read().split(">")
     2.6          if len(raw_sequences) <= 1:
     2.7 -            raise "Wrong format of fasta-file %s" % file.name
     2.8 +            raise Exception("Wrong format of fasta-file %s" % file.name)
     2.9          
    2.10          raw_sequences = raw_sequences[1:] #ignore everything before the first >
    2.11          for raw in raw_sequences:
    2.12 @@ -124,11 +124,12 @@
    2.13                  name = name_and_description[0]
    2.14                  description = ''
    2.15              else:
    2.16 -                raise "Wrong name of sequence in fasta file"
    2.17 +                raise Exception("Wrong name of sequence %(name)$ fasta-file %(file)s" % \
    2.18 +                {'name': name, 'file': file.name})
    2.19              
    2.20              if len(parsed_raw_sequence) <= 1:
    2.21 -                raise "Wrong format of sequence %(name)$ fasta-file %(file)s" % \
    2.22 -                {'name': name, 'file': file.name}
    2.23 +                raise Exception("Wrong format of sequence %(name)$ fasta-file %(file)s" % \
    2.24 +                {'name': name, 'file': file.name})
    2.25              string = ""
    2.26              for piece in parsed_raw_sequence[1:]:
    2.27                  piece_without_whitespace_chars = re.sub("\s", "", piece)