Skip to content

Commit

Permalink
Merge branch 'master' of github.com:RabadanLab/arcasHLA
Browse files Browse the repository at this point in the history
  • Loading branch information
abuendia committed Feb 8, 2024
2 parents 79c2d0d + aeff463 commit 5404a70
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
16 changes: 8 additions & 8 deletions scripts/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,25 +78,25 @@ def convert_allele(allele, resolution):

# Output: P-group allele
elif resolution == 'p-group':
if allele[:-1] in p_group[i]:
allele = p_group[i][allele[:-1]]
if allele[:-1] in p_group[str(i)]:
allele = p_group[str(i)][allele[:-1]]

elif process_allele(allele[:-1], i - 1) in p_group[i]:
allele = p_group[i][process_allele(allele[:-1], i -1)]
elif process_allele(allele[:-1], i - 1) in p_group[str(i)]:
allele = p_group[str(i)][process_allele(allele[:-1], i -1)]

# Input: ungrouped allele
# Output: G-group allele
elif resolution == 'g-group':
if allele in g_group[i]:
allele = g_group[i][allele]
if allele in g_group[str(i)]:
allele = g_group[str(i)][allele]
elif allele[-1] != 'N':
allele = process_allele(allele,3)

# Input: ungrouped allele
# Output: P-group allele
elif resolution == 'p-group':
if allele in p_group[i]:
allele = p_group[i][allele]
if allele in p_group[str(i)]:
allele = p_group[str(i)][allele]

# Input: ungrouped allele
# Output: reduced resolution, ungrouped allele
Expand Down
14 changes: 2 additions & 12 deletions scripts/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ def extract_reads(bam, outdir, paired, unmapped, alts, temp, threads):

hla_filtered = ''.join([temp, sample, '.hla.sam'])
file_list.append(hla_filtered)
hla_filtered_bam = ''.join([temp, sample, '.hla.bam'])
file_list.append(hla_filtered_bam)

# Get bam header to check for chromosome nomenclature
output = run_command(['samtools', 'view', '-@'+threads, '-H', bam])
Expand Down Expand Up @@ -115,21 +113,13 @@ def extract_reads(bam, outdir, paired, unmapped, alts, temp, threads):
command.extend([bam, alt+':', '>>', hla_filtered])
run_command(command)


# Convert SAM to BAM
message = '[extract] Converting SAM to BAM: '
command = ['samtools', 'view', '-Sb', '-@'+threads,
hla_filtered, '>', hla_filtered_bam]
run_command(command, message)


# Sort BAM
# Sort and convert to BAM
hla_sorted = ''.join([temp, sample, '.hla.sorted.bam'])
file_list.append(hla_sorted)
file_list.append(hla_sorted + '.bai')
message = '[extract] Sorting bam: '
command = ['samtools', 'sort', '-n', '-@'+threads,
hla_filtered_bam, '-o', hla_sorted]
hla_filtered, '-o', hla_sorted]
run_command(command, message)

# Convert BAM to FASTQ and compress
Expand Down

0 comments on commit 5404a70

Please sign in to comment.