text
stringlengths
0
828
for subline in indexqc:
straindata = [x.rstrip() for x in subline.rstrip().split(""\t"")]
# Try and replicate the Illumina rules to create file names from ""Sample_Name""
samplename = samplenamer(straindata, 1)
# Use the sample number -1 as the index in the list of objects created in parsesamplesheet
strainindex = int(straindata[0]) - 1
# Set run to the .run object of self.samples[index]
run = self.samples[strainindex].run
# An assertion that compares the sample computer above to the previously entered sample name
# to ensure that the samples are the same
assert self.samples[strainindex].name == samplename, \
""Sample name {} does not match object name {}"" \
.format(self.samples[strainindex].name, samplename)
# Extract and format the percent of reads (passing filter) associated with each sample
# noinspection PyTypeChecker
percentperstrain = float(""{:.2f}"".format(float(straindata[5])))
# Calculate the number of reads passing filter associated with each sample:
# percentage of reads per strain times the total reads passing filter divided by 100
numberofclusterspf = int(percentperstrain * tclusterspf / 100)
# Update the object with the variables
run.SampleNumber = straindata[0]
run.NumberofClustersPF = numberofclusterspf
run.TotalClustersinRun = tclusterspf
run.PercentOfClusters = percentperstrain
run.flowcell = self.flowcell
run.instrument = self.instrument
else:
strainindex = 0
for i in range(len(self.samples)):
# Set run to the .run object of self.samples[index]
run = self.samples[strainindex].run
# Update the object with the variables
run.SampleNumber = strainindex + 1
run.NumberofClustersPF = 'NA'
run.TotalClustersinRun = 'NA'
run.PercentOfClusters = 'NA'
run.flowcell = self.flowcell
run.instrument = self.instrument
strainindex += 1"
5,"def fix_raw_path(path):
""""""Prettify name of path
:param path: path to fix
:return: Good name for path
""""""
double_path_separator = PATH_SEPARATOR + PATH_SEPARATOR
while path.find(
double_path_separator) >= 0: # there are double separators
path = path.replace(double_path_separator,
PATH_SEPARATOR) # remove double path separator
if is_folder(path) and not path.endswith(""/""):
path = path + ""/""
return path"
6,"def remove_year(name):
""""""Removes year from input
:param name: path to edit
:return: inputs with no years
""""""
for i in range(len(
name) - 3): # last index is length - 3 - 1 = length - 4
if name[i: i + 4].isdigit():
name = name[:i] + name[i + 4:]
return remove_year(
name) # if there is a removal, start again
return name"
7,"def remove_brackets(name):
""""""Removes brackets form input
:param name: path to fix
:return: inputs with no brackets
""""""
name = re.sub(
r""([(\[]).*?([)\]])"",
r""\g<1>\g<2>"",
name
) # remove anything in between brackets
brackets = ""()[]{}"" # list of brackets
for bracket in brackets:
name = name.replace(bracket, """")
return name"
8,"def extract_name_max_chars(name, max_chars=64, blank="" ""):
""""""Extracts max chars in name truncated to nearest word
:param name: path to edit
:param max_chars: max chars of new name
:param blank: char that represents the blank between words
:return: Name edited to contain at most max_chars
""""""
new_name = name.strip()
if len(new_name) > max_chars:
new_name = new_name[:max_chars] # get at most 64 chars
if new_name.rfind(blank) > 0:
new_name = new_name[:new_name.rfind(blank)] # nearest word
return new_name"
9,"def prettify(name, blank="" ""):
""""""Prettify name of path