Exemplo n.º 1
0
 def test_uniquereads_empty_sequence(self, mpopen, msys, mpool):
     mpopen.return_value.stdout = self.headers
     r = subsamplebam.make_subselected_bam('foo.bam', self.uniquereads)
     ecalls = []
     for c in self.headers:
         ecalls.append(mock.call(c))
     msys.stdout.write.assert_has_calls(ecalls)
Exemplo n.º 2
0
 def test_uniquereads_empty_sequence(self, mpopen, msys, mpool):
     mpopen.return_value.stdout = self.headers
     r = subsamplebam.make_subselected_bam('foo.bam', self.uniquereads)
     ecalls = []
     for c in self.headers:
         ecalls.append(mock.call(c))
     msys.stdout.write.assert_has_calls(ecalls)
Exemplo n.º 3
0
def main(): 
    '''
    Parse the sam view, initialize the DepthMatrix, and trim the sequence matrix using minimize_depths.
    Then, ouptut the results (as a sam view) to stdout.
    '''
    #TODO: need to handle case where fasta file does not span entire reference genome; depth array should be limited in that case to the largest overlap
    args = subsamplebam.parse_args(wrapper=False)
    sys.stderr.write(str(args)+'\n') 
#    ref_length = int(args.regionstr.split(':')[-1].split('-')[-1])
#    region_str = args.regionstr.split(':')[0]
    matrix = DepthMatrix(args.subsample, allow_orphans=args.count_orphans, more_random=args.more_random)
    matrix.make_seq_matrix(args.bamfile, args.refseq)
    matrix.minimize_depths()
    ''' Flatten the matrix '''
    sampled_seqs = flatten_and_filter_matrix(matrix.seq_matrix)
    '''Print results to stdout as a sam view (.sam file)'''
    subsamplebam.make_subselected_bam(args.bamfile, sampled_seqs) 
def main():
    '''
    Parse the sam view, initialize the DepthMatrix, and trim the sequence matrix using minimize_depths.
    Then, ouptut the results (as a sam view) to stdout.
    '''
    #TODO: need to handle case where fasta file does not span entire reference genome; depth array should be limited in that case to the largest overlap
    args = subsamplebam.parse_args(wrapper=False)
    sys.stderr.write(str(args) + '\n')
    #    ref_length = int(args.regionstr.split(':')[-1].split('-')[-1])
    #    region_str = args.regionstr.split(':')[0]
    matrix = DepthMatrix(args.subsample,
                         allow_orphans=args.count_orphans,
                         more_random=args.more_random)
    matrix.make_seq_matrix(args.bamfile, args.refseq)
    matrix.minimize_depths()
    ''' Flatten the matrix '''
    sampled_seqs = flatten_and_filter_matrix(matrix.seq_matrix)
    '''Print results to stdout as a sam view (.sam file)'''
    subsamplebam.make_subselected_bam(args.bamfile, sampled_seqs)
Exemplo n.º 5
0
 def test_contains_bam_header_and_samviewrows(self, mpopen, msys, mpool):
     mpool.return_value.map = map
     mpopen.return_value.stdout = self.headers
     r = subsamplebam.make_subselected_bam('foo.bam', self.uniquereads)
     msys.stdout.write.assert_has_calls([
         mock.call(self.headers[0]),
         mock.call(self.headers[1]),
         mock.call(self.headers[2]),
         mock.call(self.uniquereads[0])
     ])
Exemplo n.º 6
0
 def test_contains_bam_header_and_samviewrows(self, mpopen, msys, mpool):
     mpool.return_value.map = map
     mpopen.return_value.stdout = self.headers
     r = subsamplebam.make_subselected_bam('foo.bam', self.uniquereads)
     msys.stdout.write.assert_has_calls([
         mock.call(self.headers[0]),
         mock.call(self.headers[1]),
         mock.call(self.headers[2]),
         mock.call(self.uniquereads[0])
     ])