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
| # generate output file name | |
| def generate_output_file_name(id_of_seq_element,id_of_seq_scanned): | |
| ''' | |
| Takes a file name as an argument and returns string for the name of the | |
| output file. The generated name is based on a prefix that can be adjusted | |
| under the section ' USER ADJUSTABLE VALUES ', plus the provided text in |
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
| # see https://gist.github.com/fomightez/ef57387b5d23106fabd4e02dab6819b4 for | |
| # the main ones dealing with BLAST and dataframes, search `blast` to find | |
| # see two Jupyter notebooks in https://github.com/fomightez/blast-binder | |
| # SEE MOE FUNCTIONAL VERSION OF THIS FUNCTION AT https://github.com/fomightez/sequencework/tree/master/blast-utilities | |
| def BLAST_to_df(results_file): | |
| ''' | |
| BLAST results to Pandas dataframe |
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
| # This is not presently all encompassing as it was started well after my sequence work repo | |
| # at https://github.com/fomightez/sequencework , where much of this related code is. | |
| # For making FASTA files/entriees out of dataframes, see 'specific dataframe contents saved as formatted text file example' | |
| # in my useful pandas snippets gist https://gist.github.com/fomightez/ef57387b5d23106fabd4e02dab6819b4 | |
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 time | |
| def executeSomething(): | |
| #code here | |
| print ('.') | |
| time.sleep(480) #60 seconds times 8 minutes | |
| while True: | |
| executeSomething() |
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
| # I like the example at https://inventwithpython.com/blog/2019/06/05/pythonic-ways-to-use-dictionaries/ better than this one I had found earlier> | |
| ## | |
| ## | |
| def dispatch_dict(operator, x, y): | |
| ''' | |
| Python to emulate switch/case statements | |
| based on https://books.google.com/books?id=C0VKDwAAQBAJ&pg=PT226&lpg=PT226&dq=%22dispatch_dict+(operator%22&source=bl&ots=Ja0bhOYv9A&sig=j7OZGsWpps97z8jHByquiYIuRBY&hl=en&sa=X&ved=2ahUKEwjW4siOl8fcAhWKTN8KHSa3ApYQ6AEwAnoECAMQAQ#v=onepage&q=%22dispatch_dict%20(operator%22&f=false | |
| https://twitter.com/w_cazzola/status/1023917802627973126 | |
| https://gist.github.com/carlessanagustin/6d7584b963338426a3691d355fe28f55 |
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
| # Use `%%capture` to hush 'noisy' stdout and stderr streams, but still combine with getting `%%time` after | |
| %%capture out_stream | |
| %%time | |
| ---rest of a cell that does something with LOTS of output-- | |
| #In cell after, put following to get time of completion from that: | |
| #time it took to run cell above | |
| for x in out_stream.stdout.split("\n")[-3:]: | |
| print(x) | |
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
| CLUSTAL multiple sequence alignment by MUSCLE (3.8) | |
| STV1 -MNQEEAIFRSADMTYVQLYIPLEVIREVTFLLGKMSVFMVMDLNKDLTAFQRGYVNQLR | |
| VPH1 MAEKEEAIFRSAEMALVQFYIPQEISRDSAYTLGQLGLVQFRDLNSKVRAFQRTFVNEIR | |
| ::********:*: **:*** *: *: :: **::.:. . ***..: **** :**::* | |
| STV1 RFDEVERMVGFLNEVVEKHAAETW-----KYILHIDDEGNDIAQPDMADLINTMEPLSLE | |
| VPH1 RLDNVERQYRYFYSLLKKHDIKLYEGDTDKYL----DGSGELYVPPSGSVI--------- | |
| *:*:*** :: .:::** : : **: * ..:: * ..:* |
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 `get_seq_following_seq_from_FASTA.py` | |
| if __name__ == "__main__" and '__file__' in globals(): | |
| """ This is executed when run from the command line """ | |
| # Code with just `if __name__ == "__main__":` alone will be run if pasted | |
| # into a notebook. The addition of ` and '__file__' in globals()` is based | |
| # on https://stackoverflow.com/a/22923872/8508004 | |
| # See also https://stackoverflow.com/a/22424821/8508004 for an option to | |
| # provide arguments when prototyping a full script in the notebook. | |
| ###-----------------for parsing command line arguments-------------------### | |
| import argparse |
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 difflib | |
| from wasabi import color | |
| def diff_strings(a, b): | |
| output = [] | |
| matcher = difflib.SequenceMatcher(None, a, b) | |
| for opcode, a0, a1, b0, b1 in matcher.get_opcodes(): | |
| if opcode == "equal": | |
| output.append(a[a0:a1]) | |
| elif opcode == "insert": |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.