I have a list of sam files that were created using HISAT2. I need to convert all of them into bam files for downstream analysis and I do so using the following (so it runs on all sam files in the directory)
samtools view -@ 7 -b -S -o *.sam > *.bam
the operation runs but nothing happens in the output files (I can't even see them). Ideally I would want a bam file being in the output titled as the sam file that was used for input.
You're not going to do this with shell globbing (i.e., *.sam and *.bam). You're either going to write a little for loop in bash or something like python or snakemake. I find snakemake quite simple to use, in which case you'd do:
Thanks Devon & Jorge!!
Jorge's approach was more straightforward as I'm new to ubuntu. I tried Devon's but it kept running into different issues and trying to run a "Yagi=Uda antenna analysis program" for some reason. Probably a mistake I did on my end even though I only copied and pasted the command.
When I actually paste your code in the first thing that happens is that my pointer turns into a target looking thing and I have to click somewhere (and then everything crashes) what is it that the import glob actually does??
This is python/snakemake code, so you would need to write this to a file. import glob imports the glob python module, which allows things like "give me all files ending in '.sam' in the current directory" (glob.glob("*.sam")).