I’m trying to use porechop on several data with a Snakemake workflow. In my Snakefile, there are three rules, a fastqc rule and a porechop rule, in addition to the all rule. The fastqc rule works very well, I have all three out for my three fastq. But for porechop, instead of running the command three t…
create request with python requests (translation from another language to python)
This piece of code is from the api documentation. I can’t figure out how to perform this action in python. Please help me to complete this query using python. Answer A simple translation:
Calculate the average of list of lists based on two elements in the list?
I have the following list: I want to calculate the average of the items which have the same “first and the second elements”. E.g., from the below example, I want to take the average of the elements which have ‘5’ and ‘1’ in the first two elements of the list. So, my desired…
python: get percentage from collection counter
I have two lists like the following: I have tried to get the counts of elements in the first list based on a condition: the output is: instead of counts, I would like to get their percentage like the following I have tried adding Counter(100/([a for a,b in zip(l1,l2) if b==’f’])), but I get an err…
Align image center pysimpleGui
I use image (and button) as so: How do I align the myImg to center? I tried google can’t find anything on how to do it. I read somebody suggested justification=’center’ but I don’t know where to put that. I tried [myImg, justification=’center’] didn’t work just crash …
Iterating SQL query inside python loop and changing the value of date function in SQL query with every loop
I have a SQL query which I want to iterate using python for loop. Is there a way where I can define a variable inside the sql query and update it’s value with each python loop? date1 = datetime.date(2017, 1, 1) date2 = datetime.date(2017, 12, 31) for d in daterange(date1, date2): SQL = “SELECT * F…
Make Pandas `df.get()` behave gracefully whether column or row key is incorrect
I have a Pandas dataframe and a function that pulls entries from the dataframe. If the requested entry is not present in the dataframe—whether because the requested column does not exist, because the requested row/index does not exist, or both—I would like to return the string ‘entry not found’ in…
accessing nested dictionary, that holds empty entries in python with get method and for loop that
Assume you’ve got the following dictionary: All good with that But if some of the keys don’t hold a threshold section I got the keyError. The keyError as often described comes. I tried to solve it this way: But key is not known then. How would you solve it. Answer One option is to add a check if &…
Concatenate strings (‘not float’)
Hello I have 3 different dataframes whose values I want to add. I have the following dataframes below and the code I used to add the values all together but I encountered an error. I would appreciate any help, thank you very much. I used this code to add the values in the dataframes: However I got this Error:…
Loop through folder and subfolders and merge pdf
I tried to create a script to loop through parent folder and subfolders and merge all of the pdfs into one. Below if the code I wrote so far, but I don’t know how to combine them into one script. Reference: Merge PDF files The first function is to loop through all of the subfolders under parent folder a…