Entering edit mode
7.4 years ago
bio90029
▴
10
Hi, I need a little bit of help. I have a script that contains four different functions. Three of the function have a common pathway but they deal with different type of data, example below:
def One():
#do something
One()
def Two(path_to_folder_H*,something_else):
#do something with files
folders=glob.glob(path_to_folder_H*)
for folder in folders:
my_file=glob.glob(file.fastqs)
Two(path_to_folder_H*,something_else)
def Third(path_to_folder_H*, someting_else_2):
#do something
folders=glob.glob(path_to_folder_H*)
for folder in folders:
my_file=glob.glob(file.fa)
Third(path_to_folder_H*,something_else_2)
def Fouth(path_to_folder_H*,something_else_3):
#do someething
folders=glob.glob(path_to_folder_H*)
for folder in folders:
my_file=glob.glob(file.xml)
Fourth(path_to_folder_H*,something_else_3)
I would like to tidy up the 'for loops' but I don't know how to manage that. Can anyone help me in this matter, please? Thanks
maybe I am missing the point of the question. first I do not know If this a bioinformatic question. But why you do not write only one function with three argument one of them is a condition based on it you decide what to do?
But the for loops do nothing... They just. I can't. Hrm. And what's up with my_file? I believe OP needs to rethink the code.
that is why I commented
Hello bio90029!
We believe that this post does not fit the main topic of this site.
This is a programming question. Please either show us how this is bioinformatics or search/ask StackOverflow.
For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.
If you disagree please tell us why in a reply below, we'll be happy to talk about it.
Cheers!
I think that is pretty mean.
No it's pretty standard, we don't specialize in pure programming here.
It is more about coherence of the form to bioinformatics, and he also gave you a good place for programming issues stack-overflow. Otherwise you could explain how this is much related to bioinformtics and people here will be more than happy to help :)
As others have said this is a pure programming question, not bioinformatics so doesn't really belong here. It's also not very clear what you're trying to do?
If each function is supposed to find a different file/filetype I'd use something like:
But you could find the various files outside of each function, and just pass the necessary file to each function, rather than finding it all over again every time.