text stringlengths 81 112k |
|---|
Main entry-point for calling layouts directly as a program.
def main(argv=None):
'''
Main entry-point for calling layouts directly as a program.
'''
# Prep argparse
ap = argparse.ArgumentParser(
description='Basic query options for Python HID-IO Layouts repository',
)
ap.add_argumen... |
Retrieves a cache of the layouts git repo from GitHub
@param github_path: Location of the git repo on GitHub (e.g. hid-io/layouts)
@param version: git reference for the version to download (e.g. master)
@param cache_dir: Directory to operate on external cache from
@param token: GitHub a... |
Returns the layout with the given name
def get_layout(self, name):
'''
Returns the layout with the given name
'''
layout_chain = []
# Retrieve initial layout file
try:
json_data = self.json_files[self.layout_names[name]]
except KeyError:
... |
Recursively merges two dicts
Overwrites any non-dictionary items
merge_to <- merge_in
Modifies merge_to dictionary
@param merge_to: Base dictionary to merge into
@param merge_in: Dictionary that may overwrite elements in merge_in
def dict_merge(self, merge_to, merge_in):
... |
Returns a squashed layout
The first element takes precedence (i.e. left to right).
Dictionaries are recursively merged, overwrites only occur on non-dictionary entries.
[0,1]
0:
test: 'my data'
1:
test: 'stuff'
Result:
test: 'my data'
... |
Returns a JSON dict
@key_caps: Converts all dictionary keys to uppercase
@value_caps: Converts all dictionary values to uppercase
@return: JSON item (may be a variable, list or dictionary)
def dict(self, name, key_caps=False, value_caps=False):
'''
Returns a JSON dict
... |
Do a lookup for the locale code that is set for this layout.
NOTE: USB HID specifies only 35 different locales. If your layout does not fit, it should be set to Undefined/0
@return: Tuple (<USB HID locale code>, <name>)
def locale(self):
'''
Do a lookup for the locale code that is set... |
Returns the sequence of combinations necessary to compose given text.
If the text expression is not possible with the given layout an ComposeException is thrown.
Iterate over the string, converting each character into a key sequence.
Between each character, an empty combo is inserted to handle... |
Run the necessary methods in the correct order
def main(self):
"""
Run the necessary methods in the correct order
"""
logging.info('Starting {at} analysis pipeline'.format(at=self.analysistype))
# Create the objects to be used in the analyses
objects = Objectprep(self)
... |
For genus-specific targets, MLST and serotyping, determine if the closest refseq genus is known - i.e. if 16S
analyses have been performed. Perform the analyses if required
def genus_specific(self):
"""
For genus-specific targets, MLST and serotyping, determine if the closest refseq genus is kn... |
Tell iTunes to pause
def pause():
"""Tell iTunes to pause"""
if not settings.platformCompatible():
return False
(output, error) = subprocess.Popen(["osascript", "-e", PAUSE], stdout=subprocess.PIPE).communicate() |
Tell iTunes to resume
def resume():
"""Tell iTunes to resume"""
if not settings.platformCompatible():
return False
(output, error) = subprocess.Popen(["osascript", "-e", RESUME], stdout=subprocess.PIPE).communicate() |
Tell iTunes to skip a song
def skip():
"""Tell iTunes to skip a song"""
if not settings.platformCompatible():
return False
(output, error) = subprocess.Popen(["osascript", "-e", SKIP], stdout=subprocess.PIPE).communicate() |
Tells iTunes to play a given song/artist/album - MACOSX ONLY
def play(song, artist=None, album=None):
"""Tells iTunes to play a given song/artist/album - MACOSX ONLY"""
if not settings.platformCompatible():
return False
if song and not artist and not album:
(output, error) = subprocess.Popen(["osascript", "-e... |
This is a class decorator that declares a class to provide a set of services.
It is expected that the class has a no-arg constructor and will be instantiated
as a singleton.
def service_provider(*services):
"""
This is a class decorator that declares a class to provide a set of services.
It is expe... |
Syllabify the given word, whether simplex or complex.
def syllabify(word):
'''Syllabify the given word, whether simplex or complex.'''
compound = bool(re.search(r'(-| |=)', word))
syllabify = _syllabify_compound if compound else _syllabify_simplex
syllabifications = list(syllabify(word))
for word,... |
There is a syllable boundary within a VV sequence of two nonidentical
vowels that are not a genuine diphthong, e.g., [ta.e], [ko.et.taa].
def apply_T2(word):
'''There is a syllable boundary within a VV sequence of two nonidentical
vowels that are not a genuine diphthong, e.g., [ta.e], [ko.et.taa].'''
W... |
If a (V)VVV sequence contains a VV sequence that could be an /i/-final
diphthong, there is a syllable boundary between it and the third vowel,
e.g., [raa.ois.sa], [huo.uim.me], [la.eis.sa], [sel.vi.äi.si], [tai.an],
[säi.e], [oi.om.me].
def apply_T5(word):
'''If a (V)VVV sequence contains a VV sequence... |
If a VVV-sequence contains a long vowel, there is a syllable boundary
between it and the third vowel, e.g. [kor.ke.aa], [yh.ti.öön], [ruu.an],
[mää.yt.te].
def apply_T6(word):
'''If a VVV-sequence contains a long vowel, there is a syllable boundary
between it and the third vowel, e.g. [kor.ke.aa], [yh.... |
If a VVV-sequence does not contain a potential /i/-final diphthong,
there is a syllable boundary between the second and third vowels, e.g.
[kau.an], [leu.an], [kiu.as].
def apply_T7(word):
'''If a VVV-sequence does not contain a potential /i/-final diphthong,
there is a syllable boundary between the se... |
Split /ie/, /uo/, or /yö/ sequences in syllables that do not take
primary stress.
def apply_T8(word):
'''Split /ie/, /uo/, or /yö/ sequences in syllables that do not take
primary stress.'''
WORD = word
offset = 0
for vv in tail_diphthongs(WORD):
i = vv.start(1) + 1 + offset
WOR... |
Return the number of unstressed heavy syllables.
def wsp(word):
'''Return the number of unstressed heavy syllables.'''
HEAVY = r'[ieaAoO]{1}[\.]*(u|y)[^ieaAoO]+(\.|$)'
# # if the word is not monosyllabic, lop off the final syllable, which is
# # extrametrical
# if '.' in word:
# word = wor... |
Return the number of stressed light syllables.
def pk_prom(word):
'''Return the number of stressed light syllables.'''
LIGHT = r'[ieaAoO]{1}[\.]*(u|y)(\.|$)'
# # if the word is not monosyllabic, lop off the final syllable, which is
# # extrametrical
# if '.' in word:
# word = word[:word.ri... |
Match files with an extension - e.g. 'js', 'txt'
def ext(self, extension):
"""
Match files with an extension - e.g. 'js', 'txt'
"""
new_pathq = copy(self)
new_pathq._pattern.ext = extension
return new_pathq |
Split /ie/ sequences in syllables that do not take primary stress.
def apply_T8(word):
'''Split /ie/ sequences in syllables that do not take primary stress.'''
WORD = word
offset = 0
for ie in ie_sequences(WORD):
i = ie.start(1) + 1 + offset
WORD = WORD[:i] + '.' + WORD[i:]
off... |
Split /iu/ sequences that do not appear in the first, second, or final
syllables.
def apply_T9(word):
'''Split /iu/ sequences that do not appear in the first, second, or final
syllables.'''
WORD = word
index = 0
offset = 0
for iu in iu_sequences(WORD):
if iu.start(1) != index:
... |
Returns a class from a string including module and class.
def import_class(import_str):
"""Returns a class from a string including module and class."""
mod_str, _sep, class_str = import_str.rpartition('.')
try:
__import__(mod_str)
return getattr(sys.modules[mod_str], class_str)
except (... |
Tries to import object from default namespace.
Imports a class and return an instance of it, first by trying
to find the class in a default namespace, then failing back to
a full path if not found in the default namespace.
def import_object_ns(name_space, import_str, *args, **kwargs):
"""Tries to impo... |
install virtualbox
def install_virtualbox(distribution, force_setup=False):
""" install virtualbox """
if 'ubuntu' in distribution:
with hide('running', 'stdout'):
sudo('DEBIAN_FRONTEND=noninteractive apt-get update')
sudo("sudo DEBIAN_FRONTEND=noninteractive apt-get -y -o "
... |
install vagrant plugin
def install_vagrant_plugin(plugin, use_sudo=False):
""" install vagrant plugin """
cmd = 'vagrant plugin install %s' % plugin
with settings(hide('running', 'stdout')):
if use_sudo:
if plugin not in sudo('vagrant plugin list'):
sudo(cmd)
e... |
Run the necessary methods in the correct order
def runner(self):
"""
Run the necessary methods in the correct order
"""
printtime('Starting mashsippr analysis pipeline', self.starttime)
if not self.pipeline:
# Create the objects to be used in the analyses
... |
Create widgets and store them in self.widgets
def cree_widgets(self):
"""Create widgets and store them in self.widgets"""
for t in self.FIELDS:
if type(t) is str:
attr, kwargs = t, {}
else:
attr, kwargs = t[0], t[1].copy()
self.champs.... |
Alternative to create read only widgets. They should be set after.
def cree_ws_lecture(self, champs_ligne):
"""Alternative to create read only widgets. They should be set after."""
for c in champs_ligne:
label = ASSOCIATION[c][0]
w = ASSOCIATION[c][3](self.acces[c], False)
... |
Function for splitting a string into a list of characters, preserving surrogate pairs.
In python 2, unicode characters above 0x10000 are stored as surrogate pairs. For example, the Unicode character
u"\U0001e900" is stored as the surrogate pair u"\ud83a\udd00":
s = u"AB\U0001e900CD"
len(s) -> 6
l... |
Helper function for taking a Unicode scalar value and returning a Unicode character.
:param s: Unicode scalar value to convert.
:return: Unicode character
def _unichr(i):
"""
Helper function for taking a Unicode scalar value and returning a Unicode character.
:param s: Unicode scalar value to con... |
Helper function for taking an integer and returning a hex string. The string will be padded on the left with zeroes
until the string is of the specified width. For example:
_padded_hex(31, pad_width=4, uppercase=True) -> "001F"
:param i: integer to convert to a hex string
:param pad_width: (int spec... |
Helper function for taking a string (i.e. a Unicode character name) and transforming it via UAX44-LM2 loose matching
rule. For more information, see <https://www.unicode.org/reports/tr44/#UAX44-LM2>.
The rule is defined as follows:
"UAX44-LM2. Ignore case, whitespace, underscore ('_'), and all medial hyp... |
Helper function for converting a character or surrogate pair into a Unicode scalar value e.g.
"\ud800\udc00" -> 0x10000
The algorithm can be found in older versions of the Unicode Standard.
https://unicode.org/versions/Unicode3.0.0/ch03.pdf, Section 3.7, D28
Unicode scalar value: a number N from 0 to... |
Helper function for looking up the derived name prefix associated with a Unicode scalar value.
:param i: Unicode scalar value.
:return: String with the derived name prefix.
def _get_nr_prefix(i):
"""
Helper function for looking up the derived name prefix associated with a Unicode scalar value.
:p... |
Function for performing case folding. This function will take the input
string s and return a copy of the string suitable for caseless comparisons.
The input string must be of type 'unicode', otherwise a TypeError will be
raised.
For more information on case folding, see section 3.13 of the Unicode St... |
Function for parsing the Unicode character data from the Unicode Character
Database (UCD) and generating a lookup table. For more info on the UCD,
see the following website: https://www.unicode.org/ucd/
def _build_unicode_character_database(self):
"""
Function for parsing the Unicode c... |
Function for retrieving the UnicodeCharacter associated with a name. The name lookup uses the loose matching
rule UAX44-LM2 for loose matching. See the following for more info:
https://www.unicode.org/reports/tr44/#UAX44-LM2
For example:
ucd = UnicodeData()
ucd.lookup_by_nam... |
Similar to lookup_by_name(name), this method uses loose matching rule UAX44-LM2 to attempt to find the
UnicodeCharacter associated with a name. However, it attempts to permit even looser matching by doing a
substring search instead of a simple match. This method will return a generator that yields ins... |
Function for parsing the Unicode block info from the Unicode Character
Database (UCD) and generating a lookup table. For more info on the UCD,
see the following website: https://www.unicode.org/ucd/
def _load_unicode_block_info(self):
"""
Function for parsing the Unicode block info fro... |
Function for parsing the case folding data from the Unicode Character
Database (UCD) and generating a lookup table. For more info on the UCD,
see the following website: https://www.unicode.org/ucd/
def _build_casefold_map(self):
"""
Function for parsing the case folding data from the U... |
Function to lookup a character in the casefold map.
The casefold map has four sub-tables, the 'C' or common table, the 'F' or
full table, the 'S' or simple table and the 'T' or the Turkic special
case table. These tables correspond to the statuses defined in the
CaseFolding.txt file. ... |
Load a :class:`RegistryReponse` from a dictionary or a string (that
will be parsed as json).
def load_from_json(data):
"""
Load a :class:`RegistryReponse` from a dictionary or a string (that
will be parsed as json).
"""
if isinstance(data, str):
data = json.l... |
Load a :class:`ApplicationResponse` from a dictionary or string (that
will be parsed as json).
def load_from_json(data):
"""
Load a :class:`ApplicationResponse` from a dictionary or string (that
will be parsed as json).
"""
if isinstance(data, str):
data = js... |
Load a :class:`Item` from a dictionary ot string (that will be parsed
as json)
def load_from_json(data):
"""
Load a :class:`Item` from a dictionary ot string (that will be parsed
as json)
"""
if isinstance(data, str):
data = json.loads(data)
return It... |
If a VVV sequence contains a /u, y/-final diphthong and the third vowel
is /i/, there is a syllable boundary between the diphthong and /i/.
def apply_T11(word):
'''If a VVV sequence contains a /u, y/-final diphthong and the third vowel
is /i/, there is a syllable boundary between the diphthong and /i/.'''
... |
There is a syllable boundary within a VV sequence of two nonidentical
vowels that are not a genuine diphthong, e.g., [ta.e], [ko.et.taa].
def apply_T12(word):
'''There is a syllable boundary within a VV sequence of two nonidentical
vowels that are not a genuine diphthong, e.g., [ta.e], [ko.et.taa].'''
... |
Syllabify the given word.
def _syllabify_simplex(word):
'''Syllabify the given word.'''
word, rules = apply_T1(word)
if re.search(r'[^ieAyOauo]*([ieAyOauo]{2})[^ieAyOauo]*', word):
word, T2 = apply_T2(word)
word, T8 = apply_T8(word)
word, T9 = apply_T9(word)
rules += T2 + T... |
Split /iu/ sequences that do not appear in the first or second
syllables. Split /iu/ sequences in the final syllable iff the final
syllable would receive stress.
def apply_T9(word):
'''Split /iu/ sequences that do not appear in the first or second
syllables. Split /iu/ sequences in the final syllable i... |
Any /iou/ sequence contains a syllable boundary between the first and
second vowel.
def apply_T10(word):
'''Any /iou/ sequence contains a syllable boundary between the first and
second vowel.'''
WORD = word
offset = 0
for iou in iou_sequences(WORD):
i = iou.start(1) + 1 + offset
... |
Insert a syllable boundary in front of every CV sequence.
def T1(word):
'''Insert a syllable boundary in front of every CV sequence.'''
# split consonants and vowels: 'balloon' -> ['b', 'a', 'll', 'oo', 'n']
WORD = [i for i in re.split(r'([ieaouäöy]+)', word, flags=FLAGS) if i]
# keep track of which s... |
Split any VV sequence that is not a genuine diphthong or long vowel.
E.g., [ta.e], [ko.et.taa]. This rule can apply within VVV+ sequences.
def T2(word, rules):
'''Split any VV sequence that is not a genuine diphthong or long vowel.
E.g., [ta.e], [ko.et.taa]. This rule can apply within VVV+ sequences.'''
... |
Optionally split /u,y/-final diphthongs that do not take primary stress.
E.g., [lau.ka.us], [va.ka.ut.taa].
def T4(word, rules):
'''Optionally split /u,y/-final diphthongs that do not take primary stress.
E.g., [lau.ka.us], [va.ka.ut.taa].'''
WORD = re.split(
r'([ieaouäöy]+[^ieaouäöy]+\.*[ieaoä... |
If a VVV-sequence contains a long vowel, insert a syllable boundary
between it and the third vowel. E.g. [kor.ke.aa], [yh.ti.öön], [ruu.an],
[mää.yt.te].
def T6(word, rules):
'''If a VVV-sequence contains a long vowel, insert a syllable boundary
between it and the third vowel. E.g. [kor.ke.aa], [yh.ti.... |
Join /ie/, /uo/, or /yö/ sequences in syllables that take primary
stress.
def T8(word, rules):
'''Join /ie/, /uo/, or /yö/ sequences in syllables that take primary
stress.'''
WORD = word
try:
vv = tail_diphthongs(WORD)
i = vv.start(1) + 1
WORD = WORD[:i] + word[i + 1:]
... |
If a VVV sequence contains a /u,y/-final diphthong, insert a syllable
boundary between the diphthong and the third vowel.
def T11(word, rules):
'''If a VVV sequence contains a /u,y/-final diphthong, insert a syllable
boundary between the diphthong and the third vowel.'''
WORD = word
offset = 0
... |
Return the number of stressed light syllables.
def pk_prom(word):
'''Return the number of stressed light syllables.'''
violations = 0
stressed = []
for w in extract_words(word):
stressed += w.split('.')[2:-1:2] # odd syllables, excl. word-initial
# (CVV = light)
for syll in stressed:... |
Rank syllabifications.
def rank(syllabifications):
'''Rank syllabifications.'''
# def key(s):
# word = s[0]
# w = wsp(word)
# p = pk_prom(word)
# n = nuc(word)
# t = w + p + n
# print('%s\twsp: %s\tpk: %s\tnuc: %s\ttotal: %s' % (word, w, p, n, t))
# ret... |
Return the ANSI escape sequence to render the image.
x_start
Offset from the left of the image data to render from. Defaults to 0.
y_start
Offset from the top of the image data to render from. Defaults to 0.
width
Width of the image data to render. Defaults... |
Return the ANSI escape sequence to render the image.
x_start
Offset from the left of the image data to render from. Defaults to 0.
y_start
Offset from the top of the image data to render from. Defaults to 0.
width
Width of the image data to render. Defaults... |
Purge a single fastly url
def main():
"""
Purge a single fastly url
"""
parser = OptionParser(description=
"Purge a single url from fastly.")
parser.add_option("-k", "--key", dest="apikey",
default="", help="fastly api key")
parser.add_option("-H", "--hos... |
Register callbacks needed by the interface object
def set_callbacks(self, **dic_functions):
"""Register callbacks needed by the interface object"""
for action in self.interface.CALLBACKS:
try:
f = dic_functions[action]
except KeyError:
pass
... |
Set attributes in ``obj`` with ``setattr`` from the all values in
``section``.
def populate(self, obj=None, section=None, parse_types=True):
"""Set attributes in ``obj`` with ``setattr`` from the all values in
``section``.
"""
section = self.default_section if section is None e... |
Get the last module in the call stack that is not this module or ``None`` if
the call originated from this module.
def _get_calling_module(self):
"""Get the last module in the call stack that is not this module or ``None`` if
the call originated from this module.
"""
for frame ... |
Return a resource based on a file name. This uses the ``pkg_resources``
package first to find the resources. If it doesn't find it, it returns
a path on the file system.
:param: resource_name the file name of the resource to obtain (or name
if obtained from an installed module)
... |
Load the configuration file.
def parser(self):
"Load the configuration file."
if not hasattr(self, '_conf'):
cfile = self.config_file
logger.debug('loading config %s' % cfile)
if os.path.isfile(cfile):
conf = self._create_config_parser()
... |
Get all options for a section. If ``opt_keys`` is given return
only options with those keys.
def get_options(self, section='default', opt_keys=None, vars=None):
"""
Get all options for a section. If ``opt_keys`` is given return
only options with those keys.
"""
vars = ... |
Return an option from ``section`` with ``name``.
:param section: section in the ini file to fetch the value; defaults to
constructor's ``default_section``
def get_option(self, name, section=None, vars=None, expect=None):
"""Return an option from ``section`` with ``name``.
:param secti... |
Just like ``get_option`` but parse as a list using ``split``.
def get_option_list(self, name, section=None, vars=None,
expect=None, separator=','):
"""Just like ``get_option`` but parse as a list using ``split``.
"""
val = self.get_option(name, section, vars, expect)
... |
Just like ``get_option`` but parse as a boolean (any case `true`).
def get_option_boolean(self, name, section=None, vars=None, expect=None):
"""Just like ``get_option`` but parse as a boolean (any case `true`).
"""
val = self.get_option(name, section, vars, expect)
val = val.lower() if... |
Just like ``get_option`` but parse as an integer.
def get_option_int(self, name, section=None, vars=None, expect=None):
"""Just like ``get_option`` but parse as an integer."""
val = self.get_option(name, section, vars, expect)
if val:
return int(val) |
Just like ``get_option`` but parse as a float.
def get_option_float(self, name, section=None, vars=None, expect=None):
"""Just like ``get_option`` but parse as a float."""
val = self.get_option(name, section, vars, expect)
if val:
return float(val) |
Just like ``get_option`` but return a ``pathlib.Path`` object of
the string.
def get_option_path(self, name, section=None, vars=None, expect=None):
"""Just like ``get_option`` but return a ``pathlib.Path`` object of
the string.
"""
val = self.get_option(name, section, vars, exp... |
Wrapper for property reads which auto-dereferences Refs if required.
prop
A Ref (which gets dereferenced and returned) or any other value (which gets returned).
instance
The context object used to dereference the Ref.
def property_get( prop, instance, **kwargs ):
"""Wrapper for property r... |
Wrapper for property writes which auto-deferences Refs.
prop
A Ref (which gets dereferenced and the target value set).
instance
The context object used to dereference the Ref.
value
The value to set the property to.
Throws AttributeError if prop is not a Ref.
def property_se... |
Wrapper for attributes of a View class which auto-dereferences Refs.
Equivalent to setting a property on the class with the getter wrapped
with property_get(), and the setter wrapped with property_set().
prop
A string containing the name of the class attribute to wrap.
def view_property( prop... |
Return an attribute from an object using the Ref path.
instance
The object instance to traverse.
def get( self, instance, **kwargs ):
"""Return an attribute from an object using the Ref path.
instance
The object instance to traverse.
"""
target = instan... |
Set an attribute on an object using the Ref path.
instance
The object instance to traverse.
value
The value to set.
Throws AttributeError if allow_write is False.
def set( self, instance, value, **kwargs ):
"""Set an attribute on an object using the Ref path.
... |
Traverses the tree again and again until it is not modified.
def traverse_until_fixpoint(predicate, tree):
"""Traverses the tree again and again until it is not modified."""
old_tree = None
tree = simplify(tree)
while tree and old_tree != tree:
old_tree = tree
tree = tree.traverse(predi... |
Run the necessary methods in the correct order
def runner(self):
"""
Run the necessary methods in the correct order
"""
logging.info('Starting {} analysis pipeline'.format(self.analysistype))
# Initialise the GenObject
for sample in self.runmetadata.samples:
... |
Create FASTA files of the PointFinder results to be fed into PointFinder
def fasta(self):
"""
Create FASTA files of the PointFinder results to be fed into PointFinder
"""
logging.info('Extracting FASTA sequences matching PointFinder database')
for sample in self.runmetadata.samp... |
Run PointFinder on the FASTA sequences extracted from the raw reads
def run_pointfinder(self):
"""
Run PointFinder on the FASTA sequences extracted from the raw reads
"""
logging.info('Running PointFinder on FASTA files')
for i in range(len(self.runmetadata.samples)):
... |
:param genus: Non-supported genus to be added to the dictionary
:param key: section of dictionary to be populated. Supported keys are: prediction, table, and results
Populate self.summary_dict as required. If the genus is not provided, populate the dictionary for Salmonella
Escherichia and Campy... |
Create summary reports for the PointFinder outputs
def parse_pointfinder(self):
"""
Create summary reports for the PointFinder outputs
"""
# Create the nested dictionary that stores the necessary values for creating summary reports
self.populate_summary_dict()
# Clear ou... |
Parse the PointFinder outputs, and write the summary report for the current analysis type
:param summary_dict: nested dictionary containing data such as header strings, and paths to reports
:param seqid: name of the strain,
:param genus: MASH-calculated genus of current isolate
:param ke... |
Parse the PointFinder table output, and write a summary report
:param summary_dict: nested dictionary containing data such as header strings, and paths to reports
:param seqid: name of the strain,
:param genus: MASH-calculated genus of current isolate
def write_table_report(summary_dict, seqid,... |
Search the targets folder for FASTA files, create the multi-FASTA file of all targets if necessary, and
populate objects
def targets(self):
"""
Search the targets folder for FASTA files, create the multi-FASTA file of all targets if necessary, and
populate objects
"""
lo... |
Create a dictionary of SEQID: OLNID from the supplied
def strains(self):
"""
Create a dictionary of SEQID: OLNID from the supplied
"""
with open(os.path.join(self.path, 'strains.csv')) as strains:
next(strains)
for line in strains:
oln, seqid = li... |
Create metadata objects for all PacBio assembly FASTA files in the sequencepath.
Create individual subdirectories for each sample.
Relative symlink the original FASTA file to the appropriate subdirectory
def sequence_prep(self):
"""
Create metadata objects for all PacBio assembly FAST... |
Write the metadata object to file
:param metadata: Metadata object
def write_json(metadata):
"""
Write the metadata object to file
:param metadata: Metadata object
"""
# Open the metadata file to write
with open(metadata.jsonfile, 'w') as metadatafile:
... |
Read the metadata object from file
:param json_metadata: Path and file name of JSON-formatted metadata object file
:return: metadata object
def read_json(json_metadata):
"""
Read the metadata object from file
:param json_metadata: Path and file name of JSON-formatted metadata ob... |
Use SeqIO.parse to extract the total number of bases in each assembly file
def assembly_length(self):
"""
Use SeqIO.parse to extract the total number of bases in each assembly file
"""
for sample in self.metadata:
# Only determine the assembly length if is has not been previ... |
Use the PacBio assembly FASTA files to generate simulated reads of appropriate forward and reverse lengths
at different depths of sequencing using randomreads.sh from the bbtools suite
def simulate_reads(self):
"""
Use the PacBio assembly FASTA files to generate simulated reads of appropriate f... |
Trim the reads to the correct length using reformat.sh
:param analysistype: current analysis type. Will be either 'simulated' or 'sampled'
def read_length_adjust(self, analysistype):
"""
Trim the reads to the correct length using reformat.sh
:param analysistype: current analysis type. W... |
Perform quality trim, and toss reads below appropriate thresholds
def read_quality_trim(self):
"""
Perform quality trim, and toss reads below appropriate thresholds
"""
logging.info('Quality trim')
for sample in self.metadata:
sample.sampled_reads = GenObject()
... |
For each PacBio assembly, sample reads from corresponding FASTQ files for appropriate forward and reverse
lengths and sequencing depths using reformat.sh from the bbtools suite
def sample_reads(self):
"""
For each PacBio assembly, sample reads from corresponding FASTQ files for appropriate forw... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.