• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Clinical-Genomics / demultiplexing / 4627485829

pending completion
4627485829

push

github-actions

karlnyr
remova conda stuff, expand aliases

501 of 941 relevant lines covered (53.24%)

0.53 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

35.48
/demux/utils/hiseq2500_samplesheet.py
1
"""
2
    Create a samplesheet for 2500 flowcells
3
"""
4

5
from ..constants.constants import DASH, COMMA, LIMS_KEYS
1✔
6
from .samplesheet import Samplesheet
1✔
7

8

9
class Create2500Samplesheet:
1✔
10
    """Create a raw sample sheet for 2500 flowcells"""
11

12
    def __init__(self, flowcell: str, index_length: int, raw_samplesheet: list):
1✔
13
        self.flowcell = flowcell
×
14
        self.index_length = index_length
×
15
        self.raw_samplesheet = raw_samplesheet
×
16

17
    @property
1✔
18
    def header(self) -> list:
1✔
19
        """Create the sample sheet header"""
20
        return list(Samplesheet.header_map.values())
×
21

22
    @staticmethod
1✔
23
    def is_dual_index(index: str, delimiter=DASH) -> bool:
1✔
24
        """Determines if an index in the raw samplesheet is dual index or not"""
25
        return delimiter in index
×
26

27
    def remove_unwanted_indexes(self, raw_samplesheet: list) -> list:
1✔
28
        """Remove indexes with length unequal to index_length"""
29
        raw_samplesheet = [
×
30
            line
31
            for line in raw_samplesheet
32
            if len(line["index"].replace("-", "")) == self.index_length
33
        ]
34

35
        return raw_samplesheet
×
36

37
    def split_dual_indexes(self, raw_samplesheet: list) -> list:
1✔
38
        """Splits dual indexes"""
39
        for line in raw_samplesheet:
×
40
            if self.is_dual_index(line["index"]):
×
41
                index1, index2 = line["index"].split("-")
×
42
                line["index"], line["index2"] = index1, index2
×
43
        return raw_samplesheet
×
44

45
    def construct_samplesheet(self, end="\n", delimiter=COMMA) -> str:
1✔
46
        """Construct the sample sheet"""
47
        demux_samplesheet = [delimiter.join(self.header)]
×
48
        raw_samplesheet = self.raw_samplesheet
×
49
        raw_samplesheet = self.remove_unwanted_indexes(raw_samplesheet)
×
50
        raw_samplesheet = self.split_dual_indexes(raw_samplesheet)
×
51
        for line in raw_samplesheet:
×
52
            line["sample_name"] = line["project"]
×
53
            demux_samplesheet.append(
×
54
                delimiter.join([str(line[lims_key]) for lims_key in LIMS_KEYS])
55
            )
56

57
        return end.join(demux_samplesheet)
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc