text
stringlengths 0
828
|
---|
.format(sample=sample.name,
|
total=num_reads,
|
paired=num_pairs))
|
# If the report exists, open it to determine which samples have already been added - useful if re-running
|
# the analysis
|
else:
|
lines = list()
|
with open(report, 'r') as report_file:
|
for line in report_file:
|
lines.append(line.split(',')[0])
|
# Add the results to the report
|
if sample.name not in lines:
|
with open(report, 'a+') as report_file:
|
report_file.write('{sample},{total},{paired}\n'
|
.format(sample=sample.name,
|
total=num_reads,
|
paired=num_pairs))"
|
66,"def reads(err_log):
|
""""""
|
Parse the outputs from bbmerge to extract the total number of reads, as well as the number of reads that
|
could be paired
|
:param err_log: bbmerge outputs the stats in the error file
|
:return: num_reads, the total number of reads, paired_reads, number of paired readds
|
""""""
|
# Initialise variables
|
num_reads = 0
|
paired_reads = 0
|
# Open the log file
|
with open(err_log, 'r') as error_log:
|
# Extract the necessary information
|
for line in error_log:
|
if 'Pairs:' in line:
|
num_reads = line.split('\t')[-1].rstrip()
|
elif 'Joined:' in line:
|
paired_reads = line.split('\t')[-2].rstrip()
|
return num_reads, paired_reads"
|
67,"def best_assemblyfile(self):
|
""""""
|
Determine whether the contigs.fasta output file from the assembler is present. If not, set the .bestassembly
|
attribute to 'NA'
|
""""""
|
for sample in self.metadata:
|
try:
|
# Set the name of the filtered assembly file
|
filtered_outputfile = os.path.join(self.path, 'raw_assemblies', '{}.fasta'.format(sample.name))
|
# Set the name of the unfiltered spades assembly output file
|
if os.path.isfile(sample.general.assemblyfile):
|
size = os.path.getsize(sample.general.assemblyfile)
|
# Ensure that the assembly isn't just an empty file
|
if size == 0:
|
sample.general.bestassemblyfile = 'NA'
|
else:
|
sample.general.bestassemblyfile = sample.general.assemblyfile
|
shutil.copyfile(sample.general.bestassemblyfile, filtered_outputfile)
|
else:
|
sample.general.bestassemblyfile = 'NA'
|
# Add the name and path of the filtered file to the metadata
|
sample.general.filteredfile = filtered_outputfile
|
except AttributeError:
|
sample.general.assemblyfile = 'NA'
|
sample.general.bestassemblyfile = 'NA'"
|
68,"def groups(self):
|
""""""Component groups
|
Special property which point to a :class:`~pylls.cachet.ComponentGroups`
|
instance for convenience. This instance is initialized on first call.
|
""""""
|
if not self._groups:
|
self._groups = ComponentGroups(self.api_client)
|
return self._groups"
|
69,"def get(self, component_id=None, **kwargs):
|
""""""Get components
|
:param component_id: Component ID (optional)
|
:return: Components data (:class:`Generator`)
|
Additional named arguments may be passed and are directly transmitted
|
to API. It is useful to use the API search features.
|
.. seealso:: https://docs.cachethq.io/reference#get-components
|
.. seealso:: https://docs.cachethq.io/docs/advanced-api-usage
|
""""""
|
path = 'components'
|
if component_id is not None:
|
path += '/%s' % component_id
|
return self.paginate_get(path, data=kwargs)"
|
70,"def create(self, name, status, description="""", link="""", order=0,
|
group_id=0, enabled=True):
|
""""""Create a new component
|
:param str name: Name of the component
|
:param int status: Status of the component; 1-4
|
:param str description: Description of the component (optional)
|
:param str link: A hyperlink to the component (optional)
|
:param int order: Order of the component (optional)
|
:param int group_id: The group ID of the component (optional)
|
:param bool enabled: Whether the component is enabled (optional)
|
:return: Created component data (:class:`dict`)
|
.. seealso:: https://docs.cachethq.io/reference#components
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.