Skip to content

Commit

Permalink
Changes passing anchor reference from using index to text
Browse files Browse the repository at this point in the history
  • Loading branch information
alhsu committed Oct 21, 2013
1 parent fdead12 commit d601b9c
Show file tree
Hide file tree
Showing 38 changed files with 103 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .gitignore
@@ -1,6 +1,6 @@
# Test data
MS0465*
results_*
130423*
results_Socrates_*
sample_*
do_all.sh
Expand Down
131 changes: 83 additions & 48 deletions Socrates

Large diffs are not rendered by default.

Binary file modified bin/net/wehi/socrates/AnnotatePairedClusters.class
Binary file not shown.
Binary file modified bin/net/wehi/socrates/BAMStratifier$AlignmentInfo.class
Binary file not shown.
Binary file modified bin/net/wehi/socrates/BAMStratifier$MergeWorker.class
Binary file not shown.
Binary file modified bin/net/wehi/socrates/BAMStratifier$OutputFiles.class
Binary file not shown.
Binary file modified bin/net/wehi/socrates/BAMStratifier$StratifyWorker.class
Binary file not shown.
Binary file modified bin/net/wehi/socrates/BAMStratifier.class
Binary file not shown.
Binary file modified bin/net/wehi/socrates/Cluster.class
Binary file not shown.
Binary file modified bin/net/wehi/socrates/PairedCluster.class
Binary file not shown.
Binary file modified bin/net/wehi/socrates/RealignmentBAM$Info.class
Binary file not shown.
Binary file modified bin/net/wehi/socrates/RealignmentBAM.class
Binary file not shown.
Binary file not shown.
Binary file modified bin/net/wehi/socrates/RealignmentClustering$ResultCounter.class
Binary file not shown.
Binary file modified bin/net/wehi/socrates/RealignmentClustering.class
Binary file not shown.
Binary file modified bin/net/wehi/socrates/SOCRATES.class
Binary file not shown.
Binary file modified bin/net/wehi/socrates/util/ConsensusMaker.class
Binary file not shown.
Binary file modified bin/net/wehi/socrates/util/FindSeqByName.class
Binary file not shown.
Binary file modified bin/net/wehi/socrates/util/GenomicIndexInterval.class
Binary file not shown.
Binary file modified bin/net/wehi/socrates/util/GenomicIntervalList.class
Binary file not shown.
Binary file modified bin/net/wehi/socrates/util/GenomicIntervalListMap.class
Binary file not shown.
Binary file modified bin/net/wehi/socrates/util/MemoryMappedFile.class
Binary file not shown.
Binary file modified bin/net/wehi/socrates/util/ProgressVerbose.class
Binary file not shown.
Binary file modified bin/net/wehi/socrates/util/RealignmentCluster.class
Binary file not shown.
Binary file modified bin/net/wehi/socrates/util/RealignmentRecordSummary.class
Binary file not shown.
Binary file modified bin/net/wehi/socrates/util/SAMFileInfo.class
Binary file not shown.
Binary file modified bin/net/wehi/socrates/util/SAMRecordSummary.class
Binary file not shown.
Binary file modified bin/net/wehi/socrates/util/SeekableMemoryStream.class
Binary file not shown.
Binary file modified bin/net/wehi/socrates/util/TabixReader$Iterator.class
Binary file not shown.
Binary file modified bin/net/wehi/socrates/util/TabixReader$TIndex.class
Binary file not shown.
Binary file modified bin/net/wehi/socrates/util/TabixReader$TIntv.class
Binary file not shown.
Binary file modified bin/net/wehi/socrates/util/TabixReader$TPair64.class
Binary file not shown.
Binary file modified bin/net/wehi/socrates/util/TabixReader.class
Binary file not shown.
Binary file modified bin/net/wehi/socrates/util/Utilities.class
Binary file not shown.
Binary file modified bin/net/wehi/socrates/util/Values.class
Binary file not shown.
14 changes: 7 additions & 7 deletions src/net/wehi/socrates/BAMStratifier.java
Expand Up @@ -471,7 +471,7 @@ private void flush(int keepInBuffer) {
boolean clip3p = (aln.getReadNegativeStrandFlag()) ? true : false;
boolean ideal = ((proper&&!clip3p) || (!proper&&clip3p));

String header = RealignmentRecordSummary.makeFastqHeader(aln, summary, aln.getReferenceIndex(), summary.getHeadClipPos(), ideal,
String header = RealignmentRecordSummary.makeFastqHeader(aln, summary, sourceBAMInfo.getSequenceName(aln.getReferenceIndex()), summary.getHeadClipPos(), ideal,
Utilities.sequenceByteToString(summary.getHeadClipAlignedSequence(), false), '-');
String clipSeq = Utilities.sequenceByteToString(head, false); // make breakpoint at 3' end
String clipQual = Utilities.qualityByteToString(summary.getHeadClipQuality(), false);
Expand All @@ -484,7 +484,7 @@ private void flush(int keepInBuffer) {
boolean clip3p = (aln.getReadNegativeStrandFlag()) ? false : true;
boolean ideal = ((proper&&!clip3p) || (!proper&&clip3p));

String header = RealignmentRecordSummary.makeFastqHeader(aln, summary, aln.getReferenceIndex(), summary.getTailClipPos(), ideal,
String header = RealignmentRecordSummary.makeFastqHeader(aln, summary, sourceBAMInfo.getSequenceName(aln.getReferenceIndex()), summary.getTailClipPos(), ideal,
Utilities.sequenceByteToString(summary.getTailClipAlignedSequence(), false), '+');
String clipSeq = Utilities.sequenceByteToString(tail, false); // make breakpoint at 3' end
String clipQual = Utilities.qualityByteToString(summary.getTailClipQuality(), false);
Expand Down Expand Up @@ -664,20 +664,20 @@ public void delete_empty() {
private class AlignmentInfo {
public int refIdx, pos5p, mrefIdx, mpos5p;
public String strands;
public boolean singleEnd;
public boolean paired;

public AlignmentInfo(SAMRecord aln) {
refIdx = aln.getReferenceIndex();
pos5p = aln.getReadNegativeStrandFlag() ? aln.getUnclippedEnd() : aln.getUnclippedStart();
String strand = aln.getReadNegativeStrandFlag() ? "-" : "+";

if (aln.getReadPairedFlag()) {
singleEnd = true;
paired = true;
mrefIdx = aln.getMateReferenceIndex();
mpos5p = aln.getMateNegativeStrandFlag() ? aln.getMateAlignmentStart()+aln.getReadLength() : aln.getMateAlignmentStart();
strands = strand + (aln.getMateNegativeStrandFlag() ? "-" : "+");
} else {
singleEnd = false;
paired = false;
mrefIdx = -1;
mpos5p = -1;
strands = strand;
Expand All @@ -686,7 +686,7 @@ public AlignmentInfo(SAMRecord aln) {

@Override
public int hashCode() {
if (this.singleEnd) {
if (! this.paired) {
return new HashCodeBuilder(17,31).
append( refIdx ).
append( pos5p ).
Expand All @@ -709,7 +709,7 @@ public boolean equals(Object other) {
if (other==this) return true;

AlignmentInfo oinfo = (AlignmentInfo)other;
if (singleEnd) {
if (!paired) {
return new EqualsBuilder().
append( refIdx, oinfo.refIdx ).
append( pos5p, oinfo.pos5p ).
Expand Down
12 changes: 11 additions & 1 deletion src/net/wehi/socrates/RealignmentBAM.java
Expand Up @@ -22,6 +22,7 @@
import net.sf.samtools.util.SortingCollection;
import net.sf.samtools.util.CloseableIterator;
import net.wehi.socrates.util.ProgressVerbose;
import net.wehi.socrates.util.SAMFileInfo;
//import net.wehi.socrates.util.Utilities;

/**
Expand All @@ -41,6 +42,7 @@ public static void makeRealignmentBAM(String inputBAMFilename, String outputBamF
try {
SortingCollection<SAMRecord> buffer = SortingCollection.newInstance(SAMRecord.class, new BAMRecordCodec(sam.getFileHeader()),
new SAMRecordCoordinateComparator(), 500000, new File("."));
SAMFileInfo info = new SAMFileInfo(sam);

SAMRecordIterator iter = sam.iterator();
while (iter.hasNext()) {
Expand All @@ -53,11 +55,19 @@ public static void makeRealignmentBAM(String inputBAMFilename, String outputBamF
String[] tokens = readName.split("&");
assert tokens.length == 5;

int mateRefId = info.getSequenceIndex(tokens[1]);
if (mateRefId < 0) {
System.err.println("Read: " + tokens[0]);
System.err.println("\tAnchor reference sequence " + tokens[1] + " does not exist in realignment BAM file.");
System.err.println("\tSkipped");
continue;
}

aln.setReadName( tokens[0] );
aln.setFirstOfPairFlag(true);
aln.setProperPairFlag(false);
aln.setReadPairedFlag(true);
aln.setMateReferenceIndex( Integer.parseInt(tokens[1]) );
aln.setMateReferenceIndex( mateRefId );
aln.setMateAlignmentStart( Integer.parseInt(tokens[2]) );
aln.setMateNegativeStrandFlag( tokens[3].equals("-") );
aln.setMateUnmappedFlag( !(tokens[4].equals("1")) );
Expand Down
2 changes: 1 addition & 1 deletion src/net/wehi/socrates/util/RealignmentRecordSummary.java
Expand Up @@ -59,7 +59,7 @@ public RealignmentRecordSummary(SAMRecord realign) {
}

public static String makeFastqHeader(SAMRecord aln, SAMRecordSummary summary,
int bpChr, int bpPos, boolean isIdeal, String alignSeq, char clipStrand) {
String bpChr, int bpPos, boolean isIdeal, String alignSeq, char clipStrand) {
StringBuilder name;
if (aln.getReadPairedFlag())
name = new StringBuilder(aln.getReadName() + (aln.getFirstOfPairFlag()?"/1":"/2"));
Expand Down

0 comments on commit d601b9c

Please sign in to comment.