Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bam2emase error when reference is not defined "*" #1

Open
dantaki opened this issue Nov 27, 2018 · 1 comment
Open

bam2emase error when reference is not defined "*" #1

dantaki opened this issue Nov 27, 2018 · 1 comment

Comments

@dantaki
Copy link

dantaki commented Nov 27, 2018

For reads like these:

NS500146:205:H2WC7BGX2:1:11101:6081:1104	141	*	0	0	*	*	0	0	GTGGAGAGATCCAGGGATGGGAATCTCAGGACAATTAACCTGGACCAGACTCCCACAGGGTTTCAAAAACAGTCCC	AAAAAEEEEEEEEEEEEEEEEEEEEEEEEEAEEEEEEEEEEEEEEEEEEEEEEEEEAEEEEEEEEEEEEEEEEEEE	XM:i:0

I get this error when running bam2emase

(gbrs) $ gbrs bam2emase -i test.bam -m R84-REL1505/ref.transcripts.info  -s A,B,C,D,E,F,G,H -o test.emase

Traceback (most recent call last):
  File "anaconda3/envs/gbrs/bin/gbrs", line 4, in <module>
    __import__('pkg_resources').run_script('gbrs==0.1.5', 'gbrs')
  File "anaconda3/envs/gbrs/lib/python2.7/site-packages/pkg_resources/__init__.py", line 664, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "anaconda3/envs/gbrs/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1444, in run_script
    exec(code, namespace, namespace)
  File "anaconda3/envs/gbrs/lib/python2.7/site-packages/gbrs-0.1.5-py2.7.egg-info/scripts/gbrs", line 199, in <module>
    sys.exit(main())
  File "anaconda3/envs/gbrs/lib/python2.7/site-packages/gbrs-0.1.5-py2.7.egg-info/scripts/gbrs", line 195, in main
    args.func(**kws)
  File "anaconda3/envs/gbrs/lib/python2.7/site-packages/gbrs/emase_utils.py", line 101, in bam2emase
    alignmat_factory.prepare(haplotypes, loci, outdir=os.path.dirname(outfile))
  File "anaconda3/envs/gbrs/lib/python2.7/site-packages/emase/AlignmentMatrixFactory.py", line 48, in prepare
    locus, hap = fh.getrname(aln.tid).split(delim)
AttributeError: 'NoneType' object has no attribute 'split'

I fixed the error by adding this line above line 48 in AlignmentMatrixFactory.py

                if aln.flag != 4 and aln.flag != 8:
                    if aln.tid==-1: continue
                    locus, hap = fh.getrname(aln.tid).split(delim)

These were the commands I used before on a small test case

$ bowtie -q -a --best --strata --sam -v 3 bowtie_ref/transcripts -1 fq/PB357_04_NPC-44200414_R1.fastq.gz -2 fq/PB357_04_NPC-44200414_R2.fastq.gz | samtools view -bS - > test.bam

$ gbrs bam2emase -i test.bam -m /oasis/projects/nsf/ddp195/dantakli/organoid/R84-REL1505/ref.transcripts.info -s 1,2,3,4,5,6,7,8 -o test.emase

Thanks!

@dantaki
Copy link
Author

dantaki commented Nov 27, 2018

Also I believe to compare the bitwise flags this is the proper method

def is_unmapped(flag):
    if flag & 4 or flag & 8: return True
    else: return False

so now is_unmapped(143) will return True and you can skip it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant