@ Override public ArrayList < Read > getUnmappedMates ( Read read ) { if ( read . getNumberReads ( ) < 2 || ( read . hasNextMatePosition ( ) && read . getNextMatePosition ( ) != null ) || ! read . hasAlignment ( ) || read . getAlignment ( ) == null || ! read . getAlignment ( ) . hasPosition ( ) || read . getAlignment ( ) . getPosition ( ) == null || read . getAlignment ( ) . getPosition ( ) . getReferenceName ( ) == null || read . getAlignment ( ) . getPosition ( ) . getReferenceName ( ) . isEmpty ( ) || read . getFragmentName ( ) == null || read . getFragmentName ( ) . isEmpty ( ) ) { return null ; } final String reference = read . getAlignment ( ) . getPosition ( ) . getReferenceName ( ) ; final String key = getReadKey ( read ) ; Map < String , ArrayList < Read > > reads = unmappedReads . get ( reference ) ; if ( reads != null ) { final ArrayList < Read > mates = reads . get ( key ) ; if ( mates != null && mates . size ( ) > 1 ) { Collections . sort ( mates , matesComparator ) ; } return mates ; } return null ; }
Checks if the passed read has unmapped mates that need to be injected and if so - returns them . The returned list is sorted by read number to handle the case of multi - read fragments .