Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a new function(umi_skipb) to the program to skip the specified bp number before trim the UMI sequence. #550

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ int main(int argc, char* argv[]){
cmd.add<string>("umi_loc", 0, "specify the location of UMI, can be (index1/index2/read1/read2/per_index/per_read, default is none", false, "");
cmd.add<int>("umi_len", 0, "if the UMI is in read1/read2, its length should be provided", false, 0);
cmd.add<string>("umi_prefix", 0, "if specified, an underline will be used to connect prefix and UMI (i.e. prefix=UMI, UMI=AATTCG, final=UMI_AATTCG). No prefix by default", false, "");
cmd.add<int>("umi_skip", 0, "if the UMI is in read1/read2, fastp can skip several bases following UMI, default is 0", false, 0);
cmd.add<int>("umi_skip", 0, "if the UMI is in read1/read2, fastp can skip several bases following UMI, default is 0", false, 0, cmdline::range(0, 100));
cmd.add<int>("umi_skipb", 0, "if the UMI is in read1/read2, fastp can skip several bases before trim UMI, default is 0", false, 0, cmdline::range(0, 100));
cmd.add<string>("umi_delim", 0, "delimiter to use between the read name and the UMI, default is :", false, ":");

// overrepresented sequence analysis
Expand Down Expand Up @@ -384,6 +385,7 @@ int main(int argc, char* argv[]){
opt.umi.length = cmd.get<int>("umi_len");
opt.umi.prefix = cmd.get<string>("umi_prefix");
opt.umi.skip = cmd.get<int>("umi_skip");
opt.umi.skipb = cmd.get<int>("umi_skipb");
opt.umi.delimiter = cmd.get<string>("umi_delim");
if(opt.umi.enabled) {
string umiLoc = cmd.get<string>("umi_loc");
Expand Down
2 changes: 2 additions & 0 deletions src/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,15 @@ class UMIOptions {
location = UMI_LOC_NONE;
length = 0;
skip = 0;
skipb = 0;
delimiter= ":";
}
public:
bool enabled;
int location;
int length;
int skip;
int skipb;
string prefix;
string separator;
string delimiter;
Expand Down
16 changes: 8 additions & 8 deletions src/umiprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ void UmiProcessor::process(Read* r1, Read* r2) {
else if(mOptions->umi.location == UMI_LOC_INDEX2 && r2)
umi = r2->lastIndex();
else if(mOptions->umi.location == UMI_LOC_READ1){
umi = r1->mSeq->substr(0, min(r1->length(), mOptions->umi.length));
r1->trimFront(umi.length() + mOptions->umi.skip);
umi = r1->mSeq->substr(mOptions->umi.skipb, min(r1->length(), mOptions->umi.length));
r1->trimFront(mOptions->umi.skipb + umi.length() + mOptions->umi.skip);
}
else if(mOptions->umi.location == UMI_LOC_READ2 && r2){
umi = r2->mSeq->substr(0, min(r2->length(), mOptions->umi.length));
r2->trimFront(umi.length() + mOptions->umi.skip);
umi = r2->mSeq->substr(mOptions->umi.skipb, min(r2->length(), mOptions->umi.length));
r2->trimFront(mOptions->umi.skipb + umi.length() + mOptions->umi.skip);
}
else if(mOptions->umi.location == UMI_LOC_PER_INDEX){
string umiMerged = r1->firstIndex();
Expand All @@ -37,13 +37,13 @@ void UmiProcessor::process(Read* r1, Read* r2) {
}
}
else if(mOptions->umi.location == UMI_LOC_PER_READ){
string umi1 = r1->mSeq->substr(0, min(r1->length(), mOptions->umi.length));
string umi1 = r1->mSeq->substr(mOptions->umi.skipb, min(r1->length(), mOptions->umi.length));
string umiMerged = umi1;
r1->trimFront(umi1.length() + mOptions->umi.skip);
r1->trimFront(mOptions->umi.skipb + umi1.length() + mOptions->umi.skip);
if(r2){
string umi2 = r2->mSeq->substr(0, min(r2->length(), mOptions->umi.length));
string umi2 = r2->mSeq->substr(mOptions->umi.skipb, min(r2->length(), mOptions->umi.length));
umiMerged = umiMerged + "_" + umi2;
r2->trimFront(umi2.length() + mOptions->umi.skip);
r2->trimFront(mOptions->umi.skipb + umi2.length() + mOptions->umi.skip);
}

addUmiToName(r1, umiMerged);
Expand Down