Skip to content

Commit

Permalink
Merge pull request #303 from liulab-dfci/dev
Browse files Browse the repository at this point in the history
Fix several compatibility issues on linus arm64 system
  • Loading branch information
mourisl authored Aug 14, 2024
2 parents 81c0811 + 96b4050 commit 213413a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 35 deletions.
16 changes: 8 additions & 8 deletions AlignAlgo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class AlignAlgo
return false ;
}
public:
static double GlobalAlignment_PosWeight( struct _posWeight *tWeights, int lent, char *p, int lenp, char *align )
static double GlobalAlignment_PosWeight( struct _posWeight *tWeights, int lent, char *p, int lenp, signed char *align )
{
if ( lent == 0 || lenp == 0 )
{
Expand Down Expand Up @@ -215,7 +215,7 @@ class AlignAlgo
return ret ;
}

static int GlobalAlignment( char *t, int lent, char *p, int lenp, char *align )
static int GlobalAlignment( char *t, int lent, char *p, int lenp, signed char *align )
{
if ( lent == 0 || lenp == 0 )
{
Expand Down Expand Up @@ -423,7 +423,7 @@ class AlignAlgo
return ret ;
}

static int GlobalAlignment_PosWeight_Affine( struct _posWeight *tWeights, int lent, char *p, int lenp, char *align )
static int GlobalAlignment_PosWeight_Affine( struct _posWeight *tWeights, int lent, char *p, int lenp, signed char *align )
{
if ( lent == 0 || lenp == 0 )
{
Expand Down Expand Up @@ -624,7 +624,7 @@ class AlignAlgo

// Semi-global alignment where one end is matched, the other side is free.
// the alignment score should be at least threshold
static int GlobalAlignment_OneEnd( char *t, int lent, char *p, int lenp, int threshold, double scoreThresholdFactor, char *align )
static int GlobalAlignment_OneEnd( char *t, int lent, char *p, int lenp, int threshold, double scoreThresholdFactor, signed char *align )
{
int *m, *e, *f ;
if ( lent == 0 || lenp == 0 )
Expand Down Expand Up @@ -812,7 +812,7 @@ class AlignAlgo



static int GlobalAlignment_classic( char *t, int lent, char *p, int lenp, char *align )
static int GlobalAlignment_classic( char *t, int lent, char *p, int lenp, signed char *align )
{
int i, j ;
int *score = new int[ ( lenp + 1 ) * ( lent + 1 ) ] ;
Expand Down Expand Up @@ -881,12 +881,12 @@ class AlignAlgo
return score[lenp * bmax + lent] ;
}

// static int GlobalAlignment_WFA(char *t, int lent, char *p, int lenp, char *align)
// static int GlobalAlignment_WFA(char *t, int lent, char *p, int lenp, signed char *align)
// {
// int i, j ;
// }

static int LocalAlignment( char *t, int lent, char *p, int lenp, int &tstart, int &pstart, char *align )
static int LocalAlignment( char *t, int lent, char *p, int lenp, int &tstart, int &pstart, signed char *align )
{
int i, j ;
int *m = new int[ ( lenp + 1 ) * ( lent + 1 ) ] ;
Expand Down Expand Up @@ -979,7 +979,7 @@ class AlignAlgo
return maxScore ;
}

static void VisualizeAlignment( char *t, int lent, char *p, int lenp, char *align )
static void VisualizeAlignment( char *t, int lent, char *p, int lenp, signed char *align )
{
int i, k, j;
int taga ;
Expand Down
2 changes: 1 addition & 1 deletion FileLineReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class FileLineReader
return NULL ;

int len = 0 ;
while ((c = fgetc(fp)) != EOF)
while ((c = fgetc(fp)) != (char)EOF)
{
buffer[len] = c ;
++len ;
Expand Down
49 changes: 24 additions & 25 deletions SeqSet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ class SeqSet
return ret ;
}

void GetAlignStats( char *align, bool update, int &matchCnt, int &mismatchCnt, int &indelCnt)
void GetAlignStats( signed char *align, bool update, int &matchCnt, int &mismatchCnt, int &indelCnt)
{
int k ;
if ( !update )
Expand Down Expand Up @@ -1010,7 +1010,7 @@ class SeqSet
// Extend the overlap to include the overhang parts and filter the overlaps if the overhang does not match well.
// return: whether this is a valid extension or not
int ExtendOverlap( char *r, int len, struct _seqWrapper &seq, double mismatchThresholdFactor,
char *align, struct _overlap &overlap, struct _overlap &extendedOverlap )
signed char *align, struct _overlap &overlap, struct _overlap &extendedOverlap )
{
// Check whether the overhang part is compatible with each other or not.
// Extension to 5'-end ( left end )
Expand Down Expand Up @@ -1672,7 +1672,7 @@ class SeqSet
}*/

matchCnt += 2 * kmerLength ;
char *align = new char[ overlaps[i].readEnd - overlaps[i].readStart + 1 +
signed char *align = new signed char[ overlaps[i].readEnd - overlaps[i].readStart + 1 +
overlaps[i].seqEnd - overlaps[i].seqStart + 1 + 1] ;
for ( j = 1 ; j < hitCnt ; ++j )
{
Expand Down Expand Up @@ -2093,11 +2093,11 @@ class SeqSet
int i, j ;
int seqCnt = seqs.size() ;
int maxLen = 0 ;
char *align ;
signed char *align ;
for ( i = 0 ; i < seqCnt ; ++i )
if ( seqs[i].consensusLen > maxLen )
maxLen = seqs[i].consensusLen ;
align = new char[2 * maxLen + 2] ;
align = new signed char[2 * maxLen + 2] ;
for ( i = 0 ; i < seqCnt ; ++i )
{
if ( seqs[i].consensus == NULL )
Expand Down Expand Up @@ -2152,11 +2152,11 @@ class SeqSet
int i, j, k ;
int seqCnt = seqs.size() ;
int maxLen = 0 ;
char *align ;
signed char *align ;
for ( i = 0 ; i < seqCnt ; ++i )
if ( seqs[i].consensusLen > maxLen )
maxLen = seqs[i].consensusLen ;
align = new char[2 * maxLen + 2] ;
align = new signed char[2 * maxLen + 2] ;
SimpleVector<bool> use ; // Buffer to represent whether to use the seq when computing overlaps
use.ExpandTo( seqCnt ) ;
for ( i = 0 ; i < seqCnt ; ++i )
Expand Down Expand Up @@ -3070,7 +3070,7 @@ class SeqSet
if ( i < overlapCnt )
{
// Incorporate to existing sequence.
char *align = new char[3 * len] ;
signed char *align = new signed char[3 * len] ;
char *rcRead = strdup( read ) ;
ReverseComplement( rcRead, read, len ) ;

Expand Down Expand Up @@ -4205,7 +4205,7 @@ class SeqSet
r = rc ;

struct _overlap extendedOverlap ;
char *align = new char[ 2 * len + 2 ] ;
signed char *align = new signed char[ 2 * len + 2 ] ;
/*for ( j = 0 ; j < overlapCnt ; ++j )
{
printf( "+ %d %d: %d %d %d %lf\n", i, j, overlaps[j].seqIdx, overlaps[j].seqStart, overlaps[j].seqEnd, overlaps[j].similarity) ;
Expand Down Expand Up @@ -5457,7 +5457,7 @@ class SeqSet
seqCnt = dGeneSeqIdx.Size() ;
std::vector<struct _overlap> dOverlaps ;
int cdr3Len = cdr[2].readEnd - cdr[2].readStart + 1 ;
char *align = new char[ cdr3Len ] ;
signed char *align = new signed char[ cdr3Len ] ;
for ( i = 0 ; i < seqCnt ; ++i )
{
int seqStart ;
Expand Down Expand Up @@ -5906,7 +5906,7 @@ class SeqSet

if ( detailLevel >= 1 )
{
char *align = new char[ 2 * len + 2 ] ;
signed char *align = new signed char[ 2 * len + 2 ] ;
char *rvr = new char[len + 1] ;
int size = allOverlaps.size() ;
for ( i = 0 ; i < size ; ++i )
Expand Down Expand Up @@ -6196,15 +6196,15 @@ class SeqSet
// Infer CDR1,2,3.
char *cdr1 = NULL ;
char *cdr2 = NULL ;
char *vAlign = NULL ;
signed char *vAlign = NULL ;


if ( detailLevel >= 2 && geneOverlap[0].seqIdx != -1
&& ( geneOverlap[2].seqIdx == -1 || geneOverlap[0].readStart < geneOverlap[2].readStart ) )
{
// Infer CDR1, 2
struct _overlap vgene = geneOverlap[0] ; // Overlap with v-gene
vAlign = new char[ len + seqs[ vgene.seqIdx ].consensusLen + 2 ] ;
vAlign = new signed char[ len + seqs[ vgene.seqIdx ].consensusLen + 2 ] ;
AlignAlgo::GlobalAlignment( seqs[ vgene.seqIdx ].consensus + vgene.seqStart, vgene.seqEnd - vgene.seqStart + 1,
read + vgene.readStart, vgene.readEnd - vgene.readStart + 1, vAlign ) ;
//AlignAlgo::VisualizeAlignment( seqs[ vgene.seqIdx ].consensus + vgene.seqStart, vgene.seqEnd - vgene.seqStart + 1,
Expand Down Expand Up @@ -6477,7 +6477,7 @@ class SeqSet
if ( vAlign == NULL )
{
struct _overlap vgene = geneOverlap[0] ; // Overlap with v-gene
vAlign = new char[ len + seqs[vgene.seqIdx].consensusLen + 2 ] ;
vAlign = new signed char[ len + seqs[vgene.seqIdx].consensusLen + 2 ] ;
AlignAlgo::GlobalAlignment( seqs[ vgene.seqIdx ].consensus + vgene.seqStart,
vgene.seqEnd - vgene.seqStart + 1,
read + vgene.readStart, vgene.readEnd - vgene.readStart + 1, vAlign ) ;
Expand Down Expand Up @@ -6720,14 +6720,14 @@ class SeqSet
// Use sequence to infer locateE ;
if ( geneOverlap[2].seqIdx != -1 )
{
char *align ;
signed char *align ;

int dest = seqs[ geneOverlap[2].seqIdx ].info[2].a ;
if ( dest != -1 /*&& dest >= geneOverlap[2].seqStart*/)
{
// Right to left scan should be more stable.
struct _overlap jgene = geneOverlap[2] ; // Overlap with j-gene
align = new char[ len + seqs[ jgene.seqIdx ].consensusLen + 2 ] ;
align = new signed char[ len + seqs[ jgene.seqIdx ].consensusLen + 2 ] ;
AlignAlgo::GlobalAlignment( seqs[ jgene.seqIdx ].consensus + jgene.seqStart,
jgene.seqEnd - jgene.seqStart + 1,
read + jgene.readStart, jgene.readEnd - jgene.readStart + 1, align ) ;
Expand Down Expand Up @@ -7972,8 +7972,8 @@ class SeqSet

int matchCnt = 0, mismatchCnt = 0, indelCnt = 0 ;
int len = strlen( seq ) ;
char *align ;
align = new char[ 3 * len + 102] ;
signed char *align ;
align = new signed char[ 3 * len + 102] ;
len = 0 ;
int seqStart, seqEnd, readStart, readEnd ;
for ( i = 0 ; i < 3 ; ++i )
Expand Down Expand Up @@ -8134,7 +8134,7 @@ class SeqSet
//if ( i == 1 )
// continue ;

char *align = GetGeneOverlapAlignment( read, geneOverlap[i] ) ;
signed char *align = GetGeneOverlapAlignment( read, geneOverlap[i] ) ;
if ( align != NULL )
{
int k, l ;
Expand Down Expand Up @@ -8192,7 +8192,7 @@ class SeqSet
if (geneOverlap[i].seqIdx != -1)
bufferSize += geneOverlap[i].seqEnd - geneOverlap[i].seqStart + 1 ;

char *align[4] ; // align part for v, d, j, c genes.
signed char *align[4] ; // align part for v, d, j, c genes.
char *buffer = (char *)malloc(sizeof(char) * 6 * bufferSize) ;
char *buffer2 = new char[2 * bufferSize] ; // sequence_align
char *buffer3 = new char[2 * bufferSize] ; // germline_align
Expand Down Expand Up @@ -8423,21 +8423,20 @@ class SeqSet
return buffer ;
}

char *GetGeneOverlapAlignment(char *read, const struct _overlap gene )
signed char *GetGeneOverlapAlignment(char *read, const struct _overlap gene )
{
if ( gene.seqIdx == -1 )
return NULL ;

int len = strlen( read ) ;
char *align ;
align = new char[ len + seqs[gene.seqIdx].consensusLen + 2 ] ;
signed char *align = new signed char[ len + seqs[gene.seqIdx].consensusLen + 2 ] ;
AlignAlgo::GlobalAlignment( seqs[ gene.seqIdx ].consensus + gene.seqStart,
gene.seqEnd - gene.seqStart + 1,
read + gene.readStart, gene.readEnd - gene.readStart + 1, align ) ;
return align ;
}

void GetGeneAlignmentAirrCigar(const char *read, const struct _overlap &gene, const char *align, char *cigar)
void GetGeneAlignmentAirrCigar(const char *read, const struct _overlap &gene, const signed char *align, char *cigar)
{
int i, j ;
cigar[0] = '\0' ;
Expand Down Expand Up @@ -8521,7 +8520,7 @@ class SeqSet
char *r = reads[i].seq ;
if ( overlaps[0].strand == -1 )
r = rc ;
char *align = new char[ 2 * len + 2 ] ;
signed char *align = new signed char[ 2 * len + 2 ] ;
for ( j = 0 ; j < overlapCnt ; ++j )
{
if ( ExtendOverlap( r, len, seqs[ overlaps[j].seqIdx ], 1.0, align,
Expand Down
2 changes: 1 addition & 1 deletion run-trust4
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use Cwd qw(cwd abs_path) ;
use File::Basename ;
use File::Path qw(make_path) ;

my $version = "v1.1.4-r530" ;
my $version = "v1.1.4-r534" ;

die "TRUST4 $version usage: ./run-trust4 [OPTIONS]:\n".
"Required:\n".
Expand Down

0 comments on commit 213413a

Please sign in to comment.