Skip to content

Commit

Permalink
shorten mutid
Browse files Browse the repository at this point in the history
  • Loading branch information
adamewing committed Mar 23, 2018
1 parent c6e3f55 commit daa1f85
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
3 changes: 2 additions & 1 deletion bin/addsv.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,8 @@ def makemut(args, bedline, alignopts):

if args.seed is not None: random.seed(int(args.seed) + int(bedline.strip().split()[1]))

mutid = '_'.join(map(str, bedline.strip().split()))
mutid = '_'.join(map(str, bedline.strip().split()[:4]))

try:
bamfile = pysam.Samfile(args.bamFileName, 'rb')
reffile = pysam.Fastafile(args.refFasta)
Expand Down
4 changes: 2 additions & 2 deletions scripts/postprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ def makebam(sam, fai, threads, mem):
cmd = ['samtools', 'view', '-bt', fai, '-o', outbam, sam]
sys.stderr.write(sam + ' --> ' + outbam + ': ' + ' '.join(cmd) + '\n')
call(cmd)
remove(sam)
#remove(sam)

outsort = sub('.bam$', '.sorted.bam', outbam)
cmd = ['samtools', 'sort', '-m', str(mem), '-@', str(threads), '-T', outsort, '-o', outsort, outbam]
outsort += '.bam'
sys.stderr.write(outbam + ' --> ' + outsort + ': ' + ' '.join(cmd) + '\n')
call(cmd)

remove(outbam)
#remove(outbam)


def main(args):
Expand Down
21 changes: 11 additions & 10 deletions scripts/remove_unpaired.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@
reads = {}

for read in inbam.fetch(until_eof=True):
if read.qname in reads:
reads[read.qname].append(read)
else:
reads[read.qname] = []
reads[read.qname].append(read)

if len(reads[read.qname]) == 2:
for outread in reads[read.qname]:
outbam.write(outread)
del reads[read.qname]
if not read.is_secondary and not read.is_supplementary:
if read.qname in reads:
reads[read.qname].append(read)
else:
reads[read.qname] = []
reads[read.qname].append(read)

if len(reads[read.qname]) == 2:
for outread in reads[read.qname]:
outbam.write(outread)
del reads[read.qname]

inbam.close()
outbam.close()
Expand Down
2 changes: 1 addition & 1 deletion test/test_snv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ then
exit 65
fi

addsnv.py -v ../test_data/random_snvs.txt -f ../test_data/testregion_realign.bam -r $3 -o ../test_data/testregion_mut.bam -n $1 -p $2 --ignoresnps --ignorepileup --seed 1234
addsnv.py -z 100 -v ../test_data/random_snvs.txt -f ../test_data/testregion_realign.bam -r $3 -o ../test_data/testregion_mut.bam -n $1 -p $2 --ignoresnps --ignorepileup --seed 1234
if [ $? -ne 0 ]
then
echo "addsnv.py failed. Are all the prequisites installed?"
Expand Down
3 changes: 2 additions & 1 deletion test_data/random_snvs.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
22 34166720 34166721 1.0
22 34166720 34166720 1.0
22 34166721 34166721 1.0
22 33908770 33908771 0.15
22 33714964 33714965 0.5
22 33769483 33769484 0.75
Expand Down

0 comments on commit daa1f85

Please sign in to comment.