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
| check_for_venv() { | |
| DIR_NAME=$PWD | |
| VENVLOC= | |
| while [ "$DIR_NAME" != "/" ]; do | |
| if [ -e "$DIR_NAME/bin/python" ] && [ -e "$DIR_NAME/bin/activate" ]; then | |
| VENVLOC="$DIR_NAME" | |
| _VENV_NAME=$(basename $DIR_NAME) | |
| break | |
| elif [ -e "$DIR_NAME/.venv/bin/python" ] && [ -e "$DIR_NAME/.venv/bin/activate" ] ; then |
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
| """Defines a fixture that does the following: | |
| - Create an asymmetric way to read and write files. | |
| If to write files, redirect to TEST_DATA_DIRS corresponding folder. | |
| If to read files, check whether TEST_DATA_DIRS corresponding file exists there and read from there, else read from DATA_DIR. | |
| TEST_DATA_ONLY_DIRS are directly read from the TEST_DATA_DIR | |
| If files end with IGNORE_EXTENSIONS, read from DATA_DIRS | |
| Only path strings are currenly supported, not Path variables! | |
| (**NOTICE**: System builtins are also overriden) |
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
| from typing import List, Union, cast | |
| from torch import nn | |
| from torch.nn import BCEWithLogitsLoss, MaxPool2d, functional | |
| class ResBlock(nn.Module): | |
| def __init__(self, in_channels, out_channels, doShortcut=True): | |
| super().__init__() | |
| inter_channels = round((in_channels + out_channels) / 2) |
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
| form typing import List | |
| from patch import Patch | |
| def iou(patch, patches: List[Patch]): | |
| # commpute IoU between a patch and a list of patches | |
| ref_mask = patch.mask | |
| ref_box = patch.bbox | |
| ref_mask_size = np.sum(ref_mask > 0) | |
| seg_ious = [] | |
| for patch in patches: | |
| reg_box = patch.bbox |
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
| # Assumes ffmpeg has been installed in conda environment | |
| # Assumes Linux environment. | |
| import os | |
| import shutil | |
| import subprocess | |
| import cv2 | |
| import numpy as np |
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 numpy as np | |
| import cv2 | |
| import math | |
| from bezier.curve import Curve | |
| def generate_curved_polygon( | |
| num_sides: int, | |
| radius: float, | |
| orientation: int = 0, | |
| side_curvature=0.1, |
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
| #!/usr/bin/env python | |
| # %% | |
| import pandas as pd | |
| import numpy as np | |
| import requests | |
| import tarfile | |
| import tempfile | |
| import os | |
| from math import ceil | |
| from tqdm.auto import tqdm |
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
| #!/bin/bash | |
| # required: bedtools in $PATH | |
| print_help(){ | |
| echo -e " | |
| 1st pos. argument: the bed path to annotate | |
| 2nd pos. argument: the bed path to get the annotations from | |
| 3rd pos. argument: the output filename | |
| 4th pos. argument: whether the output has headers (1) or not (0) | |
| 5th optional pos. argument: the prefix to add to the annotated columns, if header to be output | |
| " |
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
| #!/bin/bash | |
| # required: bedtools and bedops in $PATH | |
| print_help(){ | |
| echo -e " | |
| 1st pos. argument: the bed paths space separated | |
| 2nd pos. argument: the bed paths ids, space separated, with size equal to bed paths | |
| 3rd pos. argument: the output filename | |
| 4rth pos.argument: whether the inputs have headers (1) or not (0) | |
| " | |
| } |
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
| #!/usr/bin/env python | |
| from tqdm import tqdm | |
| import sys | |
| import contextlib | |
| import logging | |
| from typing import Literal | |
| LOGGER = logging.getLogger("bed_annotate") | |
OlderNewer