If files already exist in your directory, the python "glob" module may have a higher limit than the bash command line.
From the command line:
python -c "import glob; print glob.glob('ERR_*_1_*.fastq')"
To do all this in python, you can try something like this:
import glob files = glob.glob("ERR_*_1_*.fastq") trimmedfiles = [x.replace(".fastq","") for x in files] trimmedfiles.sort() for f in trimmedfiles: print f
This solution will sort the files in alphabetical order, not in numbers. To do this, you can add several keys to the sort () method: lambda magic:
trimmedfiles.sort(key=lambda f: int(f.split("_")[2]))
source share