{"action":"created","comment":{"url":"https://api.github.com/repos/samtools/htsjdk/pulls/comments/49126928","id":49126928,"diff_hunk":"@@ -486,20 +456,14 @@ else if (null != mHeader) {\n      * sequence, or if the mate reference name is not found in the sequence index, NO_ALIGNMENT_REFERENCE_INDEX (-1)\n      * is returned.\n      *\n-     * @throws IllegalStateException if the mate reference index cannot be resolved because the SAMFileHeader for the\n-     * record is null.\n+     * @throws IllegalStateException if the mate reference index must be resolved but cannot be because the\n+     * SAMFileHeader for the record is null.\n      */\n     public Integer getMateReferenceIndex() {\n-        if (null == mMateReferenceIndex) {\n-            // try to resolve the reference index\n-            if (NO_ALIGNMENT_REFERENCE_NAME.equals(mMateReferenceName)) {\n-                mMateReferenceIndex = NO_ALIGNMENT_REFERENCE_INDEX;\n-            }\n-            else if (null != mHeader) {\n-                mMateReferenceIndex = mHeader.getSequenceIndex(mMateReferenceName);\n-            }\n-            else {\n-                throw new IllegalStateException(\"A non-null SAMFileHeader is required to resolve the mate reference index\");\n+        if (null == mMateReferenceIndex) { // try to resolve the mate reference index\n+            mMateReferenceIndex = resolveIndexFromName(mMateReferenceName, mHeader, false);\n+            if (null == mMateReferenceIndex) {\n+                return NO_ALIGNMENT_REFERENCE_INDEX;","path":"src/java/htsjdk/samtools/SAMRecord.java","position":165,"original_position":165,"commit_id":"c0f147867cdd12ce8d882ff70f2fcdecabd4c863","original_commit_id":"c0f147867cdd12ce8d882ff70f2fcdecabd4c863","user":{"login":"droazen","id":798637,"avatar_url":"https://avatars.githubusercontent.com/u/798637?v=3","gravatar_id":"","url":"https://api.github.com/users/droazen","html_url":"https://github.com/droazen","followers_url":"https://api.github.com/users/droazen/followers","following_url":"https://api.github.com/users/droazen/following{/other_user}","gists_url":"https://api.github.com/users/droazen/gists{/gist_id}","starred_url":"https://api.github.com/users/droazen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/droazen/subscriptions","organizations_url":"https://api.github.com/users/droazen/orgs","repos_url":"https://api.github.com/users/droazen/repos","events_url":"https://api.github.com/users/droazen/events{/privacy}","received_events_url":"https://api.github.com/users/droazen/received_events","type":"User","site_admin":false},"body":"Same comment as for `getReferenceIndex()` -- This new code leaves mMateReferenceIndex set to null in the case where the lookup failed, whereas the previous version would leave it set to `NO_ALIGNMENT_REFERENCE_INDEX`. Do we care?","created_at":"2016-01-07T21:16:57Z","updated_at":"2016-01-07T21:16:57Z","html_url":"https://github.com/samtools/htsjdk/pull/406#discussion_r49126928","pull_request_url":"https://api.github.com/repos/samtools/htsjdk/pulls/406","_links":{"self":{"href":"https://api.github.com/repos/samtools/htsjdk/pulls/comments/49126928"},"html":{"href":"https://github.com/samtools/htsjdk/pull/406#discussion_r49126928"},"pull_request":{"href":"https://api.github.com/repos/samtools/htsjdk/pulls/406"}}},"pull_request":{"url":"https://api.github.com/repos/samtools/htsjdk/pulls/406","id":52998844,"html_url":"https://github.com/samtools/htsjdk/pull/406","diff_url":"https://github.com/samtools/htsjdk/pull/406.diff","patch_url":"https://github.com/samtools/htsjdk/pull/406.patch","issue_url":"https://api.github.com/repos/samtools/htsjdk/issues/406","number":406,"state":"open","locked":false,"title":"SAM/BAM writers should always call setHeader on alignment records.","user":{"login":"cmnbroad","id":10062863,"avatar_url":"https://avatars.githubusercontent.com/u/10062863?v=3","gravatar_id":"","url":"https://api.github.com/users/cmnbroad","html_url":"https://github.com/cmnbroad","followers_url":"https://api.github.com/users/cmnbroad/followers","following_url":"https://api.github.com/users/cmnbroad/following{/other_user}","gists_url":"https://api.github.com/users/cmnbroad/gists{/gist_id}","starred_url":"https://api.github.com/users/cmnbroad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmnbroad/subscriptions","organizations_url":"https://api.github.com/users/cmnbroad/orgs","repos_url":"https://api.github.com/users/cmnbroad/repos","events_url":"https://api.github.com/users/cmnbroad/events{/privacy}","received_events_url":"https://api.github.com/users/cmnbroad/received_events","type":"User","site_admin":false},"body":"Includes some DRY-refactoring to support cleaning up mate/reference index state management and javadoc.","created_at":"2015-12-08T15:58:09Z","updated_at":"2016-01-07T21:16:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2a68e4c1b391cc2252665a10953a344c6a431040","assignee":{"login":"droazen","id":798637,"avatar_url":"https://avatars.githubusercontent.com/u/798637?v=3","gravatar_id":"","url":"https://api.github.com/users/droazen","html_url":"https://github.com/droazen","followers_url":"https://api.github.com/users/droazen/followers","following_url":"https://api.github.com/users/droazen/following{/other_user}","gists_url":"https://api.github.com/users/droazen/gists{/gist_id}","starred_url":"https://api.github.com/users/droazen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/droazen/subscriptions","organizations_url":"https://api.github.com/users/droazen/orgs","repos_url":"https://api.github.com/users/droazen/repos","events_url":"https://api.github.com/users/droazen/events{/privacy}","received_events_url":"https://api.github.com/users/droazen/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/samtools/htsjdk/pulls/406/commits","review_comments_url":"https://api.github.com/repos/samtools/htsjdk/pulls/406/comments","review_comment_url":"https://api.github.com/repos/samtools/htsjdk/pulls/comments{/number}","comments_url":"https://api.github.com/repos/samtools/htsjdk/issues/406/comments","statuses_url":"https://api.github.com/repos/samtools/htsjdk/statuses/c0f147867cdd12ce8d882ff70f2fcdecabd4c863","head":{"label":"cmnbroad:cn_set_header","ref":"cn_set_header","sha":"c0f147867cdd12ce8d882ff70f2fcdecabd4c863","user":{"login":"cmnbroad","id":10062863,"avatar_url":"https://avatars.githubusercontent.com/u/10062863?v=3","gravatar_id":"","url":"https://api.github.com/users/cmnbroad","html_url":"https://github.com/cmnbroad","followers_url":"https://api.github.com/users/cmnbroad/followers","following_url":"https://api.github.com/users/cmnbroad/following{/other_user}","gists_url":"https://api.github.com/users/cmnbroad/gists{/gist_id}","starred_url":"https://api.github.com/users/cmnbroad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmnbroad/subscriptions","organizations_url":"https://api.github.com/users/cmnbroad/orgs","repos_url":"https://api.github.com/users/cmnbroad/repos","events_url":"https://api.github.com/users/cmnbroad/events{/privacy}","received_events_url":"https://api.github.com/users/cmnbroad/received_events","type":"User","site_admin":false},"repo":{"id":41918188,"name":"htsjdk","full_name":"cmnbroad/htsjdk","owner":{"login":"cmnbroad","id":10062863,"avatar_url":"https://avatars.githubusercontent.com/u/10062863?v=3","gravatar_id":"","url":"https://api.github.com/users/cmnbroad","html_url":"https://github.com/cmnbroad","followers_url":"https://api.github.com/users/cmnbroad/followers","following_url":"https://api.github.com/users/cmnbroad/following{/other_user}","gists_url":"https://api.github.com/users/cmnbroad/gists{/gist_id}","starred_url":"https://api.github.com/users/cmnbroad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmnbroad/subscriptions","organizations_url":"https://api.github.com/users/cmnbroad/orgs","repos_url":"https://api.github.com/users/cmnbroad/repos","events_url":"https://api.github.com/users/cmnbroad/events{/privacy}","received_events_url":"https://api.github.com/users/cmnbroad/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cmnbroad/htsjdk","description":"A Java API for high-throughput sequencing data (HTS) formats.","fork":true,"url":"https://api.github.com/repos/cmnbroad/htsjdk","forks_url":"https://api.github.com/repos/cmnbroad/htsjdk/forks","keys_url":"https://api.github.com/repos/cmnbroad/htsjdk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cmnbroad/htsjdk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cmnbroad/htsjdk/teams","hooks_url":"https://api.github.com/repos/cmnbroad/htsjdk/hooks","issue_events_url":"https://api.github.com/repos/cmnbroad/htsjdk/issues/events{/number}","events_url":"https://api.github.com/repos/cmnbroad/htsjdk/events","assignees_url":"https://api.github.com/repos/cmnbroad/htsjdk/assignees{/user}","branches_url":"https://api.github.com/repos/cmnbroad/htsjdk/branches{/branch}","tags_url":"https://api.github.com/repos/cmnbroad/htsjdk/tags","blobs_url":"https://api.github.com/repos/cmnbroad/htsjdk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cmnbroad/htsjdk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cmnbroad/htsjdk/git/refs{/sha}","trees_url":"https://api.github.com/repos/cmnbroad/htsjdk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cmnbroad/htsjdk/statuses/{sha}","languages_url":"https://api.github.com/repos/cmnbroad/htsjdk/languages","stargazers_url":"https://api.github.com/repos/cmnbroad/htsjdk/stargazers","contributors_url":"https://api.github.com/repos/cmnbroad/htsjdk/contributors","subscribers_url":"https://api.github.com/repos/cmnbroad/htsjdk/subscribers","subscription_url":"https://api.github.com/repos/cmnbroad/htsjdk/subscription","commits_url":"https://api.github.com/repos/cmnbroad/htsjdk/commits{/sha}","git_commits_url":"https://api.github.com/repos/cmnbroad/htsjdk/git/commits{/sha}","comments_url":"https://api.github.com/repos/cmnbroad/htsjdk/comments{/number}","issue_comment_url":"https://api.github.com/repos/cmnbroad/htsjdk/issues/comments{/number}","contents_url":"https://api.github.com/repos/cmnbroad/htsjdk/contents/{+path}","compare_url":"https://api.github.com/repos/cmnbroad/htsjdk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cmnbroad/htsjdk/merges","archive_url":"https://api.github.com/repos/cmnbroad/htsjdk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cmnbroad/htsjdk/downloads","issues_url":"https://api.github.com/repos/cmnbroad/htsjdk/issues{/number}","pulls_url":"https://api.github.com/repos/cmnbroad/htsjdk/pulls{/number}","milestones_url":"https://api.github.com/repos/cmnbroad/htsjdk/milestones{/number}","notifications_url":"https://api.github.com/repos/cmnbroad/htsjdk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cmnbroad/htsjdk/labels{/name}","releases_url":"https://api.github.com/repos/cmnbroad/htsjdk/releases{/id}","created_at":"2015-09-04T13:47:19Z","updated_at":"2015-09-04T13:47:22Z","pushed_at":"2016-01-07T18:54:39Z","git_url":"git://github.com/cmnbroad/htsjdk.git","ssh_url":"git@github.com:cmnbroad/htsjdk.git","clone_url":"https://github.com/cmnbroad/htsjdk.git","svn_url":"https://github.com/cmnbroad/htsjdk","homepage":"http://samtools.github.io/htsjdk/","size":55737,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"samtools:master","ref":"master","sha":"2fa3f624e1d5841f57c3090a00e4684b9776ac24","user":{"login":"samtools","id":1518450,"avatar_url":"https://avatars.githubusercontent.com/u/1518450?v=3","gravatar_id":"","url":"https://api.github.com/users/samtools","html_url":"https://github.com/samtools","followers_url":"https://api.github.com/users/samtools/followers","following_url":"https://api.github.com/users/samtools/following{/other_user}","gists_url":"https://api.github.com/users/samtools/gists{/gist_id}","starred_url":"https://api.github.com/users/samtools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samtools/subscriptions","organizations_url":"https://api.github.com/users/samtools/orgs","repos_url":"https://api.github.com/users/samtools/repos","events_url":"https://api.github.com/users/samtools/events{/privacy}","received_events_url":"https://api.github.com/users/samtools/received_events","type":"Organization","site_admin":false},"repo":{"id":19272315,"name":"htsjdk","full_name":"samtools/htsjdk","owner":{"login":"samtools","id":1518450,"avatar_url":"https://avatars.githubusercontent.com/u/1518450?v=3","gravatar_id":"","url":"https://api.github.com/users/samtools","html_url":"https://github.com/samtools","followers_url":"https://api.github.com/users/samtools/followers","following_url":"https://api.github.com/users/samtools/following{/other_user}","gists_url":"https://api.github.com/users/samtools/gists{/gist_id}","starred_url":"https://api.github.com/users/samtools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samtools/subscriptions","organizations_url":"https://api.github.com/users/samtools/orgs","repos_url":"https://api.github.com/users/samtools/repos","events_url":"https://api.github.com/users/samtools/events{/privacy}","received_events_url":"https://api.github.com/users/samtools/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/samtools/htsjdk","description":"A Java API for high-throughput sequencing data (HTS) formats.","fork":false,"url":"https://api.github.com/repos/samtools/htsjdk","forks_url":"https://api.github.com/repos/samtools/htsjdk/forks","keys_url":"https://api.github.com/repos/samtools/htsjdk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/samtools/htsjdk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/samtools/htsjdk/teams","hooks_url":"https://api.github.com/repos/samtools/htsjdk/hooks","issue_events_url":"https://api.github.com/repos/samtools/htsjdk/issues/events{/number}","events_url":"https://api.github.com/repos/samtools/htsjdk/events","assignees_url":"https://api.github.com/repos/samtools/htsjdk/assignees{/user}","branches_url":"https://api.github.com/repos/samtools/htsjdk/branches{/branch}","tags_url":"https://api.github.com/repos/samtools/htsjdk/tags","blobs_url":"https://api.github.com/repos/samtools/htsjdk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/samtools/htsjdk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/samtools/htsjdk/git/refs{/sha}","trees_url":"https://api.github.com/repos/samtools/htsjdk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/samtools/htsjdk/statuses/{sha}","languages_url":"https://api.github.com/repos/samtools/htsjdk/languages","stargazers_url":"https://api.github.com/repos/samtools/htsjdk/stargazers","contributors_url":"https://api.github.com/repos/samtools/htsjdk/contributors","subscribers_url":"https://api.github.com/repos/samtools/htsjdk/subscribers","subscription_url":"https://api.github.com/repos/samtools/htsjdk/subscription","commits_url":"https://api.github.com/repos/samtools/htsjdk/commits{/sha}","git_commits_url":"https://api.github.com/repos/samtools/htsjdk/git/commits{/sha}","comments_url":"https://api.github.com/repos/samtools/htsjdk/comments{/number}","issue_comment_url":"https://api.github.com/repos/samtools/htsjdk/issues/comments{/number}","contents_url":"https://api.github.com/repos/samtools/htsjdk/contents/{+path}","compare_url":"https://api.github.com/repos/samtools/htsjdk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/samtools/htsjdk/merges","archive_url":"https://api.github.com/repos/samtools/htsjdk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/samtools/htsjdk/downloads","issues_url":"https://api.github.com/repos/samtools/htsjdk/issues{/number}","pulls_url":"https://api.github.com/repos/samtools/htsjdk/pulls{/number}","milestones_url":"https://api.github.com/repos/samtools/htsjdk/milestones{/number}","notifications_url":"https://api.github.com/repos/samtools/htsjdk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/samtools/htsjdk/labels{/name}","releases_url":"https://api.github.com/repos/samtools/htsjdk/releases{/id}","created_at":"2014-04-29T10:11:28Z","updated_at":"2015-12-21T09:22:18Z","pushed_at":"2016-01-07T11:44:01Z","git_url":"git://github.com/samtools/htsjdk.git","ssh_url":"git@github.com:samtools/htsjdk.git","clone_url":"https://github.com/samtools/htsjdk.git","svn_url":"https://github.com/samtools/htsjdk","homepage":"http://samtools.github.io/htsjdk/","size":63490,"stargazers_count":69,"watchers_count":69,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":92,"mirror_url":null,"open_issues_count":82,"forks":92,"open_issues":82,"watchers":69,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/samtools/htsjdk/pulls/406"},"html":{"href":"https://github.com/samtools/htsjdk/pull/406"},"issue":{"href":"https://api.github.com/repos/samtools/htsjdk/issues/406"},"comments":{"href":"https://api.github.com/repos/samtools/htsjdk/issues/406/comments"},"review_comments":{"href":"https://api.github.com/repos/samtools/htsjdk/pulls/406/comments"},"review_comment":{"href":"https://api.github.com/repos/samtools/htsjdk/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/samtools/htsjdk/pulls/406/commits"},"statuses":{"href":"https://api.github.com/repos/samtools/htsjdk/statuses/c0f147867cdd12ce8d882ff70f2fcdecabd4c863"}}}}