Created
October 6, 2014 16:52
-
-
Save olgabot/90fa8f02d06c9b51ca37 to your computer and use it in GitHub Desktop.
Using sj2psi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sj2psi | |
from glob import iglob | |
stepsize = 100 | |
def i_to_range(i, stepsize): | |
if i % stepsize == 0: | |
return ((i/stepsize)-1)*stepsize + 1, i | |
else: | |
return (i/stepsize)*stepsize + 1, i | |
def filter_and_write(i, dfs, stepsize=stepsize): | |
summary = pd.concat(dfs) | |
csv = 'sj_{}-{}.csv'.format(*i_to_range(i, stepsize)) | |
summary.to_csv(csv) | |
print 'wrote {}'.format(csv) | |
dfs = [] | |
for i, filename in enumerate(iglob('/home/obotvinnik/scratch/mn_diff_singlecell/fastq/sj_out_tab/*SJ.out.tab')): | |
sample_id = os.path.basename(filename).split('.')[0] | |
if i % 10 == 0: | |
print i, 'on sample id {}'.format(sample_id) | |
sj = sj2psi.read_sj_out_tab(filename) | |
sj['sample_id'] = sample_id | |
sj = sj2psi.get_psis(sj) | |
dfs.append(sj) | |
if i % stepsize == 0 and i > 0: | |
filter_and_write(i, dfs) | |
dfs = [] | |
filter_and_write(i, dfs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment