Skip to content

Commit

Permalink
api.parse: rearrange code
Browse files Browse the repository at this point in the history
  • Loading branch information
golobor committed Mar 25, 2024
1 parent f61451b commit e472c97
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions pairtools/lib/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,28 @@ def flip_alignment(hic_algn):
return hic_algn


def flip_orientation(hic_algn):
"""
Flip orientation of a single alignment
:param hic_algn: Alignment to be modified
:return:
"""
hic_algn = dict(hic_algn) # overwrite the variable with the copy of dictionary
hic_algn["strand"] = "+" if (hic_algn["strand"] == "-") else "-"
return hic_algn


def flip_position(hic_algn):
"""
Flip ends of a single alignment
:param hic_algn: Alignment to be modified
:return:
"""
hic_algn = dict(hic_algn) # overwrite the variable with the copy of dictionary
hic_algn["pos5"], hic_algn["pos3"] = hic_algn["pos3"], hic_algn["pos5"]
return hic_algn



def _convert_gaps_into_alignments(sorted_algns, max_inter_align_gap):
"""
Expand Down Expand Up @@ -451,27 +473,6 @@ def normalize_alignment_list(algns, side, sort_by="dist_to_5", max_inter_align_g
return algns


def flip_orientation(hic_algn):
"""
Flip orientation of a single alignment
:param hic_algn: Alignment to be modified
:return:
"""
hic_algn = dict(hic_algn) # overwrite the variable with the copy of dictionary
hic_algn["strand"] = "+" if (hic_algn["strand"] == "-") else "-"
return hic_algn


def flip_position(hic_algn):
"""
Flip ends of a single alignment
:param hic_algn: Alignment to be modified
:return:
"""
hic_algn = dict(hic_algn) # overwrite the variable with the copy of dictionary
hic_algn["pos5"], hic_algn["pos3"] = hic_algn["pos3"], hic_algn["pos5"]
return hic_algn


####################
### Parsing utilities:
Expand Down

0 comments on commit e472c97

Please sign in to comment.