コード例 #1
0
ファイル: igv.py プロジェクト: promodel/nesoni
 def run(self):
     genome = self.genome
     if os.path.isdir(genome):
         genome = os.path.join(genome, os.path.split(genome)[1]+'.genome')
         print genome
     
     #pref_filename = os.path.join(os.path.expanduser('~'),'igv','prefs.properties')
     #if os.path.exists(pref_filename):
     #    with open(pref_filename,'rb') as f:
     #        lines = f.readlines()
     #    with open(pref_filename,'wb') as f:
     #        for line in lines:
     #            if line.startswith('DEFAULT_GENOME_KEY='):
     #                #line = 'DEFAULT_GENOME_KEY=\n'
     #                continue
     #            f.write(line)
     
     with workspace.tempspace() as temp:
         with open(temp/'batch.txt','wb') as f:
             print >> f, 'new'
             print >> f, 'preference LAST_TRACK_DIRECTORY', os.getcwd()
             print >> f, 'preference LAST_GENOME_IMPORT_DIRECTORY', os.getcwd()
             print >> f, 'genome '+os.path.abspath(genome)
             for filename in self.files:
                 print >> f, 'load '+os.path.abspath(filename)
         
         io.execute(['java','-Xmx32000m',
                     #Flags from igb.sh script:
                     '-Dproduction=true','-Dapple.laf.useScreenMenuBar=true','-Djava.net.preferIPv4Stack=true',
                     '-jar',io.find_jar('igv.jar'),'-b',temp/'batch.txt'])
コード例 #2
0
 def build_snpeff(self):
     jar = io.find_jar('snpEff.jar')
     
     with open(self/'snpeff.config','wb') as f:
         print >> f, 'data_dir = snpeff'
         print >> f, 'genomes : ' + self.name
         print >> f, self.name + '.genome : ' + self.name 
     
     snpwork = io.Workspace(self/'snpeff',must_exist=False)
     snpwork_genome = io.Workspace(snpwork/self.name,must_exist=False)
     snpwork_genomes = io.Workspace(snpwork/'genomes',must_exist=False)
     
     annotations = self.annotations_filename()
     assert annotations
     with open(snpwork_genome/'genes.gff','wb') as f:
         for record in annotation.read_annotations(annotations):
             if record.end <= record.start: continue
             if not record.attr:
                 record.attr['attributes'] = 'none'
             print >> f, record.as_gff()
     
     with open(snpwork_genomes/(self.name+'.fa'),'wb') as f:
         for name, seq in io.read_sequences(self.reference_fasta_filename()):
             io.write_fasta(f, name, seq)
             
     io.execute('java -jar JAR build NAME -gff3 -c CONFIG',
         JAR=jar, NAME=self.name, CONFIG=self/'snpeff.config')
コード例 #3
0
ファイル: sam.py プロジェクト: simonalpha/nesoni
 def run(self):
     assert self.sort in ('queryname', 'coordinate')
     
     jar = io.find_jar('MergeSamFiles.jar', 'MergeSamFiles is part of the Picard package.')
     io.execute([
         'java','-jar',jar,
         'USE_THREADING=true',
         'TMP_DIR='+tempfile.gettempdir(), #Force picard to use same temp dir as Python
         'SORT_ORDER='+self.sort,
         'OUTPUT='+self.prefix+'.bam'
         ] + [ 'INPUT='+item for item in self.bams ])
     
     if self.sort == 'coordinate' and self.index:
         jar = io.find_jar('BuildBamIndex.jar', 'BuildBamIndex is part of the Picard package.')
         io.execute([
             'java','-jar',jar,
             'INPUT='+self.prefix+'.bam'
             ])
コード例 #4
0
ファイル: sam.py プロジェクト: promodel/nesoni
 def run(self):
     assert self.sort in ('queryname', 'coordinate')
     
     jar = io.find_jar('MergeSamFiles.jar', 'MergeSamFiles is part of the Picard package.')
     io.execute([
         'java','-jar',jar,
         'USE_THREADING=true',
         'TMP_DIR='+tempfile.gettempdir(), #Force picard to use same temp dir as Python
         'SORT_ORDER='+self.sort,
         'OUTPUT='+self.prefix+'.bam'
         ] + [ 'INPUT='+item for item in self.bams ])
     
     if self.sort == 'coordinate' and self.index:
         jar = io.find_jar('BuildBamIndex.jar', 'BuildBamIndex is part of the Picard package.')
         io.execute([
             'java','-jar',jar,
             'INPUT='+self.prefix+'.bam'
             ])
コード例 #5
0
ファイル: igv.py プロジェクト: drpowell/nesoni
 def run(self):
     with workspace.tempspace() as temp:
         with open(temp/'batch.txt','wb') as f:
             print >> f, 'new'
             print >> f, 'genome '+os.path.abspath(self.genome)
             for filename in self.files:
                 print >> f, 'load '+os.path.abspath(filename)
         
         io.execute(['java','-jar',io.find_jar('igv.jar'),'-b',temp/'batch.txt'])
コード例 #6
0
ファイル: variant.py プロジェクト: simonalpha/nesoni
    def run(self):
        reference = reference_directory.Reference(self.reference, must_exist=True)
        
        jar = io.find_jar('snpEff.jar')
        
        with open(self.prefix + '.vcf','wb') as f:
            io.execute('java -jar JAR eff GENOME VCF -c CONFIG',
                JAR=jar, GENOME=reference.name, VCF=self.vcf, CONFIG=reference/'snpeff.config',
                stdout=f)

        index_vcf(self.prefix+'.vcf')
コード例 #7
0
ファイル: igv.py プロジェクト: simonalpha/nesoni
 def run(self):
     with workspace.tempspace() as temp:
         with open(temp/'batch.txt','wb') as f:
             print >> f, 'new'
             print >> f, 'preference LAST_TRACK_DIRECTORY', os.getcwd()
             print >> f, 'preference LAST_GENOME_IMPORT_DIRECTORY', os.getcwd()
             print >> f, 'genome '+os.path.abspath(self.genome)
             for filename in self.files:
                 print >> f, 'load '+os.path.abspath(filename)
         
         io.execute(['java','-jar',io.find_jar('igv.jar'),'-b',temp/'batch.txt'])
コード例 #8
0
    def run(self):
        reference = reference_directory.Reference(self.reference,
                                                  must_exist=True)

        jar = io.find_jar('snpEff.jar')

        with open(self.prefix + '.vcf', 'wb') as f:
            io.execute('java -jar JAR eff GENOME VCF -c CONFIG',
                       JAR=jar,
                       GENOME=reference.name,
                       VCF=self.vcf,
                       CONFIG=reference / 'snpeff.config',
                       stdout=f)

        index_vcf(self.prefix + '.vcf')