This program calculates the percentage of reads in a BAM file that contain soft clipping (CIGAR 'S'). It is designed to leverage HTSlib for efficient processing, making it especially beneficial for large BAM files.
First clone the repository, then set the HTSlib path, then compile the program and give executable permissions:
git clone https://github.com/Enthusiasm23/BamSCPercent.git
cd BamSCPercent
export HTSLIB_PATH=/path/to/htslib
make
chmod +x bamSCPercentReplace "/path/to/htslib" with the actual path where HTSlib is installed on your system.
bamSCPercent <BAM file> [threads]<BAM file>: Path to the BAM file.[threads]: Optional. Number of threads to use for processing. The default value is 8.- Note: Excessive threads may not improve performance due to I/O limitations.
- This program depends on HTSlib. Ensure HTSlib is properly installed and accessible on your system.
- For small BAM files, using 'samtools view' might be faster and more straightforward.
You can calculate the percentage of soft-clipped reads using samtools and awk with the following command:
samtools view -@ [threads] <BAM file> | awk '{ total_lines++; if ($6 ~ /S/) lines_with_s++ } END { printf "%.2f\n", lines_with_s / total_lines * 100 }'This command can also be executed using a script named bamSCPercent.sh. Save the above command in a file named bamSCPercent.sh, and replace and [threads] with the appropriate parameters. To run the script, use:
./bamSCPercent.sh <BAM file> [threads]Make sure that your bamSCPercent.sh script has execution permissions. You can grant execution permissions using the command chmod +x bamSCPercent.sh.
Ensure that samtools is in your environment path. If samtools is not found, you can add it to your path using the following command:
export PATH=/path/to/samtools:$PATHReplace "/path/to/samtools" with the actual path where SamTools is installed on your system.
- If you encounter an error like "error while loading shared libraries: libhts.so.2to3part12: cannot open shared object file: No such file or directory", it indicates that the HTSlib shared library is not found in your library path. To resolve this, you can add the HTSlib path to your
LD_LIBRARY_PATHenvironment variable. For example:
export LD_LIBRARY_PATH=/path/to/htslib:$LD_LIBRARY_PATHReplace "/path/to/htslib" with the actual path where HTSlib is installed on your system.
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions to this project are welcome. To contribute:
- Fork the repository.
- Create a new branch for your feature (
git checkout -b feature/AmazingFeature). - Make your changes.
- Commit your changes (
git commit -am 'Add some AmazingFeature'). - Push to the branch (
git push origin feature/AmazingFeature). - Open a pull request.
😄🎉 Hey there! This is my first-ever C program. It's simple and relies a lot on HTSLIB, but hey, we all start somewhere, right? 🚀
🙌 I'm super excited to share it with the community. Feel free to use it, break it, fix it, and tell me all about it! Every bit of feedback, or even a simple "Hello", is like a high-five for me in my coding journey. 🌟
Thanks for stopping by and being part of my programming adventure! 😊👍