Commit f03e1ffa authored by yy1533's avatar yy1533
Browse files

🍻 release 0.5.0 : Fully avoid the memory limitation by server

parent 7d3a8429
......@@ -77,7 +77,8 @@ def main_new_experiment_table():
def get_workflow_file_string(mode='multiple'):
if mode == 'multiple':
fname = 'celseq2.snakemake'
# fname = 'celseq2.snakemake'
fname = 'celseq2_beta.snakemake'
else:
fname = 'celseq2_single_lib.snakemake'
fstring = resource_string('celseq2', 'workflow/{}'.format(fname))
......@@ -86,7 +87,8 @@ def get_workflow_file_string(mode='multiple'):
def get_workflow_file_fpath(mode='multiple'):
if mode == 'multiple':
fname = 'celseq2.snakemake'
# fname = 'celseq2.snakemake'
fname = 'celseq2_beta.snakemake'
else:
fname = 'celseq2_single_lib.snakemake'
fpath = resource_filename('celseq2', 'workflow/{}'.format(fname))
......
#!/usr/bin/env python3
import pysam
import argparse
from celseq2.helper import print_logger
from celseq2.helper import join_path
def _cell_seq (name, length=6):
# BC-TCTGAG_UMI-CGTTAC => TCTGAG
try:
out = name.split('_')[0][3:3 + length]
except Exception as e:
raise(e)
return(out)
def demultiplex_sam (samfile, outdir, bc_length):
if not samfile:
return
samobj = pysam.AlignmentFile(samfile, 'rb')
dict_samout = {}
for aln in samobj:
bc = _cell_seq(aln.query_name, length=bc_length)
fh = dict_samout.get(bc, None)
if not fh:
outsam = join_path(outdir, bc + '.sam1')
fh = pysam.AlignmentFile(outsam, 'w', template=samobj)
dict_samout[bc] = fh
fh.write(aln)
for _, fh in dict_samout.items():
fh.close()
def main():
parser = argparse.ArgumentParser(add_help=True)
parser.add_argument('--sbam', type=str, metavar='FILENAME',
help='File path to SAM/BAM file')
parser.add_argument('--savetodir', type=str, metavar='DIRNAME',
help='Directory path to save the demultiplexed SAMs.',
default='.')
parser.add_argument('--bc-length', type=int, metavar='N',
help='Length of cell barcode.', default=6)
args = parser.parse_args()
print_logger('Demultiplexing SAM/BAM starts {} ...'.format(args.sbam))
demultiplex_sam(samfile=args.sbam, outdir=args.savetodir,
bc_length=args.bc_length)
print_logger('Demultiplexing SAM/BAM ends. See: {}.'.format(args.savetodir))
if __name__ == "__main__":
main()
__version__ = '0.4.8'
__version__ = '0.5.0'
This diff is collapsed.
......@@ -140,6 +140,8 @@ setup(
('bc_demultiplex = '
'celseq2.demultiplex:main'),
('sam-demultiplex = '
'celseq2.demultiplex_sam:main'),
('cook-annotation = '
'celseq2.prepare_annotation_model:main'),
('count-umi = '
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment